Mon Mar 20 08:25:48 2006

Asterisk developer's documentation


Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

app_voicemail.c File Reference

Comedian Mail - Voicemail System. More...

#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <time.h>
#include <dirent.h>
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/config.h"
#include "asterisk/say.h"
#include "asterisk/module.h"
#include "asterisk/adsi.h"
#include "asterisk/app.h"
#include "asterisk/manager.h"
#include "asterisk/dsp.h"
#include "asterisk/localtime.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"

Go to the source code of this file.

Data Structures

struct  ast_vm_user
struct  baseio
struct  leave_vm_options
struct  vm_state
struct  vm_zone

Defines

#define ASTERISK_USERNAME   "asterisk"
#define BASELINELEN   72
#define BASEMAXINLINE   256
#define BASEMAXINLINE   256
#define COMMAND_TIMEOUT   5000
#define COPY(a, b, c, d, e, f, g, h)   (copy_file(g,h));
#define DELETE(a, b, c)   (vm_delete(c))
#define DISPOSE(a, b)
#define eol   "\r\n"
#define ERROR_LOCK_PATH   -100
#define EXISTS(a, b, c, d)   (ast_fileexists(c,NULL,d) > 0)
#define INTRO   "vm-intro"
#define MAX_DATETIME_FORMAT   512
#define MAX_NUM_CID_CONTEXTS   10
#define MAXMSG   100
#define MAXMSGLIMIT   9999
#define RENAME(a, b, c, d, e, f, g, h)   (rename_file(g,h));
#define RETRIEVE(a, b)
#define SENDMAIL   "/usr/sbin/sendmail -t"
#define STORE(a, b, c, d)
#define VM_ALLOCED   (1 << 13)
#define VM_ATTACH   (1 << 11)
#define VM_DELETE   (1 << 12)
#define VM_DIRECFORWARD   (1 << 10)
#define VM_ENVELOPE   (1 << 4)
#define VM_FORCEGREET   (1 << 8)
#define VM_FORCENAME   (1 << 7)
#define VM_OPERATOR   (1 << 1)
#define VM_PBXSKIP   (1 << 9)
#define VM_REVIEW   (1 << 0)
#define VM_SAYCID   (1 << 2)
#define VM_SAYDURATION   (1 << 5)
#define VM_SEARCH   (1 << 14)
#define VM_SKIPAFTERCMD   (1 << 6)
#define VM_SVMAIL   (1 << 3)
#define VOICEMAIL_CONFIG   "voicemail.conf"
#define VOICEMAIL_DIR_MODE   0700
#define VOICEMAIL_FILE_MODE   0600

Enumerations

enum  {
  OPT_SILENT = (1 << 0), OPT_BUSY_GREETING = (1 << 1), OPT_UNAVAIL_GREETING = (1 << 2), OPT_RECORDGAIN = (1 << 3),
  OPT_PREPEND_MAILBOX = (1 << 4), OPT_PRIORITY_JUMP = (1 << 5)
}
enum  { OPT_ARG_RECORDGAIN = 0, OPT_ARG_ARRAY_SIZE = 1 }

Functions

void adsi_begin (struct ast_channel *chan, int *useadsi)
void adsi_delete (struct ast_channel *chan, struct vm_state *vms)
void adsi_folders (struct ast_channel *chan, int start, char *label)
void adsi_goodbye (struct ast_channel *chan)
int adsi_load_vmail (struct ast_channel *chan, int *useadsi)
void adsi_login (struct ast_channel *chan)
int adsi_logo (unsigned char *buf)
void adsi_message (struct ast_channel *chan, struct vm_state *vms)
void adsi_password (struct ast_channel *chan)
void adsi_status (struct ast_channel *chan, struct vm_state *vms)
void adsi_status2 (struct ast_channel *chan, struct vm_state *vms)
int advanced_options (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain)
int append_mailbox (char *context, char *mbox, char *data)
void apply_option (struct ast_vm_user *vmu, const char *var, const char *value)
void apply_options (struct ast_vm_user *vmu, const char *options)
 AST_APP_OPTIONS (vm_app_options,{AST_APP_OPTION('s', OPT_SILENT), AST_APP_OPTION('b', OPT_BUSY_GREETING), AST_APP_OPTION('u', OPT_UNAVAIL_GREETING), AST_APP_OPTION_ARG('g', OPT_RECORDGAIN, OPT_ARG_RECORDGAIN), AST_APP_OPTION('p', OPT_PREPEND_MAILBOX), AST_APP_OPTION('j', OPT_PRIORITY_JUMP),})
 AST_MUTEX_DEFINE_STATIC (vmlock)
int base_encode (char *filename, FILE *so)
int change_password_realtime (struct ast_vm_user *vmu, const char *password)
int close_mailbox (struct vm_state *vms, struct ast_vm_user *vmu)
char * complete_show_voicemail_users (char *line, char *word, int pos, int state)
int copy (char *infile, char *outfile)
void copy_file (char *frompath, char *topath)
int copy_message (struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt)
int count_messages (struct ast_vm_user *vmu, char *dir)
int create_dirpath (char *dest, int len, char *context, char *ext, char *mailbox)
char * description (void)
 Provides a description of the module.
int dialout (struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)
ast_vm_userfind_user (struct ast_vm_user *ivm, const char *context, const char *mailbox)
ast_vm_userfind_user_realtime (struct ast_vm_user *ivm, const char *context, const char *mailbox)
int forward_message (struct ast_channel *chan, char *context, char *dir, int curmsg, struct ast_vm_user *sender, char *fmt, int flag, signed char record_gain)
void free_user (struct ast_vm_user *vmu)
void free_zone (struct vm_zone *z)
int get_date (char *s, int len)
int get_folder (struct ast_channel *chan, int start)
int get_folder2 (struct ast_channel *chan, char *fn, int start)
int handle_show_voicemail_users (int fd, int argc, char *argv[])
int handle_show_voicemail_zones (int fd, int argc, char *argv[])
int has_voicemail (const char *mailbox, const char *folder)
int inbuf (struct baseio *bio, FILE *fi)
int inchar (struct baseio *bio, FILE *fi)
int invent_message (struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes)
char * key ()
 Returns the ASTERISK_GPL_KEY.
int last_message_index (struct ast_vm_user *vmu, char *dir)
int leave_voicemail (struct ast_channel *chan, char *ext, struct leave_vm_options *options)
int load_config (void)
int load_module (void)
 Initialize the module.
int make_dir (char *dest, int len, char *context, char *ext, char *mailbox)
int make_file (char *dest, int len, char *dir, int num)
char * mbox (int id)
int messagecount (const char *mailbox, int *newmsgs, int *oldmsgs)
int notify_new_message (struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname)
int ochar (struct baseio *bio, int c, FILE *so)
int open_mailbox (struct vm_state *vms, struct ast_vm_user *vmu, int box)
int play_message (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
int play_message_callerid (struct ast_channel *chan, struct vm_state *vms, char *cid, char *context, int callback)
int play_message_category (struct ast_channel *chan, char *category)
int play_message_datetime (struct ast_channel *chan, struct ast_vm_user *vmu, char *origtime, char *filename)
int play_message_duration (struct ast_channel *chan, struct vm_state *vms, char *duration, int minduration)
int play_record_review (struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir, signed char record_gain)
void populate_defaults (struct ast_vm_user *vmu)
void prep_email_sub_vars (struct ast_channel *ast, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *dur, char *date, char *passdata, size_t passdatasize)
int reload (void)
 Reload stuff.
void rename_file (char *sfn, char *dfn)
int resequence_mailbox (struct ast_vm_user *vmu, char *dir)
int reset_user_pw (const char *context, const char *mailbox, const char *newpass)
void run_externnotify (char *context, char *extension)
int save_to_folder (struct ast_vm_user *vmu, char *dir, int msg, char *context, char *username, int box)
int say_and_wait (struct ast_channel *chan, int num, char *language)
int sendmail (char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail)
int sendpage (char *srcemail, char *pager, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, int duration, struct ast_vm_user *vmu)
int unload_module (void)
 Cleanup all module structures, sockets, etc.
int usecount (void)
 Provides a usecount.
int vm_authenticate (struct ast_channel *chan, char *mailbox, int mailbox_size, struct ast_vm_user *res_vmu, const char *context, const char *prefix, int skipuser, int maxlogins, int silent)
int vm_box_exists (struct ast_channel *chan, void *data)
int vm_browse_messages (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
int vm_browse_messages_en (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
int vm_browse_messages_es (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
int vm_browse_messages_gr (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
int vm_browse_messages_it (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
int vm_browse_messages_pt (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
void vm_change_password (struct ast_vm_user *vmu, const char *newpassword)
void vm_change_password_shell (struct ast_vm_user *vmu, char *newpassword)
int vm_delete (char *file)
int vm_exec (struct ast_channel *chan, void *data)
int vm_execmain (struct ast_channel *chan, void *data)
int vm_forwardoptions (struct ast_channel *chan, struct ast_vm_user *vmu, char *curdir, int curmsg, char *vmfts, char *context, signed char record_gain)
int vm_instructions (struct ast_channel *chan, struct vm_state *vms, int skipadvanced)
int vm_intro (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_cz (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_de (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_en (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_es (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_fr (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_gr (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_it (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_nl (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_no (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_pt (struct ast_channel *chan, struct vm_state *vms)
int vm_intro_se (struct ast_channel *chan, struct vm_state *vms)
int vm_lock_path (const char *path)
int vm_newuser (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
int vm_options (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
int vm_play_folder_name (struct ast_channel *chan, char *mbox)
int vm_play_folder_name_gr (struct ast_channel *chan, char *mbox)
int vm_tempgreeting (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
int vmauthenticate (struct ast_channel *chan, void *data)
int wait_file (struct ast_channel *chan, struct vm_state *vms, char *file)
int wait_file2 (struct ast_channel *chan, struct vm_state *vms, char *file)

Variables

char * addesc = "Comedian Mail"
unsigned char adsifdn [4] = "\x00\x00\x00\x0F"
unsigned char adsisec [4] = "\x9B\xDB\xF7\xAC"
int adsiver = 1
char * app = "VoiceMail"
char * app2 = "VoiceMailMain"
char * app3 = "MailboxExists"
char * app4 = "VMAuthenticate"
char callcontext [AST_MAX_CONTEXT]
char charset [32] = "ISO-8859-1"
char cidinternalcontexts [MAX_NUM_CID_CONTEXTS][64]
char * descrip_vm
char * descrip_vm_box_exists
char * descrip_vmain
char * descrip_vmauthenticate
char dialcontext [AST_MAX_CONTEXT]
char * emailbody = NULL
char emaildateformat [32] = "%A, %B %d, %Y at %r"
char * emailsubject = NULL
char emailtitle [100]
char exitcontext [AST_MAX_CONTEXT]
char ext_pass_cmd [128]
char externnotify [160]
char fromstring [100]
ast_flags globalflags = {0}
 LOCAL_USER_DECL
char mailcmd [160]
int maxgreet
int maxlogins
int maxmsg
int maxsilence
char * pagerbody = NULL
char pagerfromstring [100]
char * pagersubject = NULL
int saydurationminfo
char serveremail [80]
ast_cli_entry show_voicemail_users_cli
char show_voicemail_users_help []
ast_cli_entry show_voicemail_zones_cli
char show_voicemail_zones_help []
int silencethreshold = 128
int skipms
 STANDARD_LOCAL_USER
char * synopsis_vm
char * synopsis_vm_box_exists
char * synopsis_vmain
char * synopsis_vmauthenticate
char * tdesc = "Comedian Mail (Voicemail System)"
ast_vm_userusers
ast_vm_userusersl
enum { ... }  vm_option_args
enum { ... }  vm_option_flags
char VM_SPOOL_DIR [AST_CONFIG_MAX_PATH]
char vmfmts [80]
int vmmaxmessage
int vmminmessage
vm_zonezones = NULL
vm_zonezonesl = NULL


Detailed Description

Comedian Mail - Voicemail System.

See also

Definition in file app_voicemail.c.


Define Documentation

#define ASTERISK_USERNAME   "asterisk"
 

Definition at line 82 of file app_voicemail.c.

#define BASELINELEN   72
 

Definition at line 94 of file app_voicemail.c.

#define BASEMAXINLINE   256
 

Definition at line 95 of file app_voicemail.c.

#define BASEMAXINLINE   256
 

Definition at line 95 of file app_voicemail.c.

Referenced by inbuf().

#define COMMAND_TIMEOUT   5000
 

Definition at line 77 of file app_voicemail.c.

#define COPY a,
b,
c,
d,
e,
f,
g,
 )     (copy_file(g,h));
 

Definition at line 285 of file app_voicemail.c.

Referenced by copy_message(), and save_to_folder().

#define DELETE a,
b,
 )     (vm_delete(c))
 

Definition at line 286 of file app_voicemail.c.

Referenced by close_mailbox(), leave_voicemail(), notify_new_message(), play_record_review(), and vm_tempgreeting().

#define DISPOSE a,
 ) 
 

Definition at line 281 of file app_voicemail.c.

Referenced by advanced_options(), invent_message(), leave_voicemail(), play_message(), play_record_review(), and vm_tempgreeting().

#define eol   "\r\n"
 

Definition at line 96 of file app_voicemail.c.

Referenced by base_encode(), and ochar().

#define ERROR_LOCK_PATH   -100
 

Definition at line 117 of file app_voicemail.c.

#define EXISTS a,
b,
c,
 )     (ast_fileexists(c,NULL,d) > 0)
 

Definition at line 283 of file app_voicemail.c.

Referenced by close_mailbox(), copy_message(), leave_voicemail(), resequence_mailbox(), and save_to_folder().

#define INTRO   "vm-intro"
 

Definition at line 88 of file app_voicemail.c.

Referenced by leave_voicemail(), and play_record_review().

#define MAX_DATETIME_FORMAT   512
 

Definition at line 98 of file app_voicemail.c.

#define MAX_NUM_CID_CONTEXTS   10
 

Definition at line 99 of file app_voicemail.c.

#define MAXMSG   100
 

Definition at line 90 of file app_voicemail.c.

Referenced by apply_option(), and load_config().

#define MAXMSGLIMIT   9999
 

Definition at line 91 of file app_voicemail.c.

Referenced by apply_option(), and load_config().

#define RENAME a,
b,
c,
d,
e,
f,
g,
 )     (rename_file(g,h));
 

Definition at line 284 of file app_voicemail.c.

Referenced by close_mailbox(), and resequence_mailbox().

#define RETRIEVE a,
 ) 
 

Definition at line 280 of file app_voicemail.c.

Referenced by advanced_options(), forward_message(), invent_message(), leave_voicemail(), play_message(), and vm_tempgreeting().

#define SENDMAIL   "/usr/sbin/sendmail -t"
 

Definition at line 86 of file app_voicemail.c.

Referenced by load_config().

#define STORE a,
b,
c,
 ) 
 

Definition at line 282 of file app_voicemail.c.

Referenced by forward_message(), leave_voicemail(), and play_record_review().

#define VM_ALLOCED   (1 << 13)
 

Definition at line 114 of file app_voicemail.c.

Referenced by find_user(), find_user_realtime(), free_user(), and load_config().

#define VM_ATTACH   (1 << 11)
 

Definition at line 112 of file app_voicemail.c.

Referenced by apply_option(), forward_message(), load_config(), notify_new_message(), and sendmail().

#define VM_DELETE   (1 << 12)
 

Definition at line 113 of file app_voicemail.c.

Referenced by apply_option(), and notify_new_message().

#define VM_DIRECFORWARD   (1 << 10)
 

directory_forward

Definition at line 111 of file app_voicemail.c.

Referenced by forward_message(), and load_config().

#define VM_ENVELOPE   (1 << 4)
 

Definition at line 105 of file app_voicemail.c.

Referenced by apply_option(), load_config(), and play_message().

#define VM_FORCEGREET   (1 << 8)
 

Have new users record their greetings

Definition at line 109 of file app_voicemail.c.

Referenced by apply_option(), load_config(), vm_execmain(), and vm_newuser().

#define VM_FORCENAME   (1 << 7)
 

Have new users record their name

Definition at line 108 of file app_voicemail.c.

Referenced by apply_option(), load_config(), vm_execmain(), and vm_newuser().

#define VM_OPERATOR   (1 << 1)
 

Definition at line 102 of file app_voicemail.c.

Referenced by apply_option(), leave_voicemail(), load_config(), and play_record_review().

#define VM_PBXSKIP   (1 << 9)
 

Definition at line 110 of file app_voicemail.c.

Referenced by load_config(), and sendmail().

#define VM_REVIEW   (1 << 0)
 

Definition at line 101 of file app_voicemail.c.

Referenced by apply_option(), load_config(), and play_record_review().

#define VM_SAYCID   (1 << 2)
 

Definition at line 103 of file app_voicemail.c.

Referenced by apply_option(), load_config(), and play_message().

#define VM_SAYDURATION   (1 << 5)
 

Definition at line 106 of file app_voicemail.c.

Referenced by apply_option(), load_config(), and play_message().

#define VM_SEARCH   (1 << 14)
 

Definition at line 115 of file app_voicemail.c.

Referenced by find_user(), find_user_realtime(), and load_config().

#define VM_SKIPAFTERCMD   (1 << 6)
 

Definition at line 107 of file app_voicemail.c.

Referenced by load_config(), and vm_execmain().

#define VM_SVMAIL   (1 << 3)
 

Definition at line 104 of file app_voicemail.c.

Referenced by apply_option(), load_config(), and vm_execmain().

#define VOICEMAIL_CONFIG   "voicemail.conf"
 

Definition at line 81 of file app_voicemail.c.

#define VOICEMAIL_DIR_MODE   0700
 

Definition at line 78 of file app_voicemail.c.

#define VOICEMAIL_FILE_MODE   0600
 

Definition at line 79 of file app_voicemail.c.

Referenced by copy().


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
OPT_SILENT 
OPT_BUSY_GREETING 
OPT_UNAVAIL_GREETING 
OPT_RECORDGAIN 
OPT_PREPEND_MAILBOX 
OPT_PRIORITY_JUMP 

Definition at line 119 of file app_voicemail.c.

00119      {
00120    OPT_SILENT =           (1 << 0),
00121    OPT_BUSY_GREETING =    (1 << 1),
00122    OPT_UNAVAIL_GREETING = (1 << 2),
00123    OPT_RECORDGAIN =       (1 << 3),
00124    OPT_PREPEND_MAILBOX =  (1 << 4),
00125    OPT_PRIORITY_JUMP =    (1 << 5),
00126 } vm_option_flags;

anonymous enum
 

Enumeration values:
OPT_ARG_RECORDGAIN 
OPT_ARG_ARRAY_SIZE 

Definition at line 128 of file app_voicemail.c.

00128      {
00129    OPT_ARG_RECORDGAIN = 0,
00130    OPT_ARG_ARRAY_SIZE = 1,
00131 } vm_option_args;


Function Documentation

void adsi_begin struct ast_channel chan,
int *  useadsi
[static]
 

Definition at line 2858 of file app_voicemail.c.

References adsi_available(), adsi_load_session(), adsi_load_vmail(), adsifdn, adsiver, ast_log(), and LOG_WARNING.

Referenced by vm_authenticate(), and vm_execmain().

02859 {
02860    int x;
02861    if (!adsi_available(chan))
02862       return;
02863    x = adsi_load_session(chan, adsifdn, adsiver, 1);
02864    if (x < 0)
02865       return;
02866    if (!x) {
02867       if (adsi_load_vmail(chan, useadsi)) {
02868          ast_log(LOG_WARNING, "Unable to upload voicemail scripts\n");
02869          return;
02870       }
02871    } else
02872       *useadsi = 1;
02873 }

void adsi_delete struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 3045 of file app_voicemail.c.

References adsi_available(), ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_transmit_message(), adsi_voice_mode(), vm_state::curmsg, vm_state::deleted, and vm_state::lastmsg.

Referenced by vm_execmain().

03046 {
03047    int bytes=0;
03048    unsigned char buf[256];
03049    unsigned char keys[8];
03050 
03051    int x;
03052 
03053    if (!adsi_available(chan))
03054       return;
03055 
03056    /* New meaning for keys */
03057    for (x=0;x<5;x++)
03058       keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
03059 
03060    keys[6] = 0x0;
03061    keys[7] = 0x0;
03062 
03063    if (!vms->curmsg) {
03064       /* No prev key, provide "Folder" instead */
03065       keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
03066    }
03067    if (vms->curmsg >= vms->lastmsg) {
03068       /* If last message ... */
03069       if (vms->curmsg) {
03070          /* but not only message, provide "Folder" instead */
03071          keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
03072       } else {
03073          /* Otherwise if only message, leave blank */
03074          keys[3] = 1;
03075       }
03076    }
03077 
03078    /* If deleted, show "undeleted" */
03079    if (vms->deleted[vms->curmsg]) 
03080       keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
03081 
03082    /* Except "Exit" */
03083    keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
03084    bytes += adsi_set_keys(buf + bytes, keys);
03085    bytes += adsi_voice_mode(buf + bytes, 0);
03086 
03087    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
03088 }

void adsi_folders struct ast_channel chan,
int  start,
char *  label
[static]
 

Definition at line 2923 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_CENT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_set_line(), adsi_transmit_message(), and adsi_voice_mode().

Referenced by vm_execmain().

02924 {
02925    unsigned char buf[256];
02926    int bytes=0;
02927    unsigned char keys[8];
02928    int x,y;
02929 
02930    if (!adsi_available(chan))
02931       return;
02932 
02933    for (x=0;x<5;x++) {
02934       y = ADSI_KEY_APPS + 12 + start + x;
02935       if (y > ADSI_KEY_APPS + 12 + 4)
02936          y = 0;
02937       keys[x] = ADSI_KEY_SKT | y;
02938    }
02939    keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17);
02940    keys[6] = 0;
02941    keys[7] = 0;
02942 
02943    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, "");
02944    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
02945    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02946    bytes += adsi_set_keys(buf + bytes, keys);
02947    bytes += adsi_voice_mode(buf + bytes, 0);
02948 
02949    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02950 }

void adsi_goodbye struct ast_channel chan  )  [static]
 

Definition at line 3193 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_CENT, ADSI_JUST_LEFT, adsi_logo(), ADSI_MSG_DISPLAY, adsi_set_line(), adsi_transmit_message(), and adsi_voice_mode().

Referenced by vm_execmain().

03194 {
03195    unsigned char buf[256];
03196    int bytes=0;
03197 
03198    if (!adsi_available(chan))
03199       return;
03200    bytes += adsi_logo(buf + bytes);
03201    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
03202    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
03203    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
03204    bytes += adsi_voice_mode(buf + bytes, 0);
03205 
03206    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
03207 }

int adsi_load_vmail struct ast_channel chan,
int *  useadsi
[static]
 

Definition at line 2729 of file app_voicemail.c.

References addesc, adsi_begin_download(), ADSI_COMM_PAGE, adsi_data_mode(), adsi_display(), adsi_download_disconnect(), adsi_end_download(), ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_KEY_APPS, adsi_load_session(), adsi_load_soft_key(), adsi_logo(), ADSI_MSG_DISPLAY, ADSI_MSG_DOWNLOAD, adsi_set_line(), adsi_transmit_message(), adsi_voice_mode(), adsifdn, adsisec, adsiver, ast_log(), LOG_DEBUG, and mbox().

Referenced by adsi_begin().

02730 {
02731    unsigned char buf[256];
02732    int bytes=0;
02733    int x;
02734    char num[5];
02735 
02736    *useadsi = 0;
02737    bytes += adsi_data_mode(buf + bytes);
02738    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02739 
02740    bytes = 0;
02741    bytes += adsi_logo(buf);
02742    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
02743 #ifdef DISPLAY
02744    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, "   .", "");
02745 #endif
02746    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02747    bytes += adsi_data_mode(buf + bytes);
02748    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02749 
02750    if (adsi_begin_download(chan, addesc, adsifdn, adsisec, adsiver)) {
02751       bytes = 0;
02752       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", "");
02753       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
02754       bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02755       bytes += adsi_voice_mode(buf + bytes, 0);
02756       adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02757       return 0;
02758    }
02759 
02760 #ifdef DISPLAY
02761    /* Add a dot */
02762    bytes = 0;
02763    bytes += adsi_logo(buf);
02764    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
02765    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, "   ..", "");
02766    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02767    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02768 #endif
02769    bytes = 0;
02770    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1);
02771    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1);
02772    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advnced", "3", 1);
02773    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1);
02774    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1);
02775    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1);
02776    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
02777 
02778 #ifdef DISPLAY
02779    /* Add another dot */
02780    bytes = 0;
02781    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, "   ...", "");
02782    bytes += adsi_voice_mode(buf + bytes, 0);
02783 
02784    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02785    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02786 #endif
02787 
02788    bytes = 0;
02789    /* These buttons we load but don't use yet */
02790    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 6, "Previous", "Prev", "4", 1);
02791    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 8, "Repeat", "Repeat", "5", 1);
02792    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 7, "Delete", "Delete", "7", 1);
02793    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 9, "Next", "Next", "6", 1);
02794    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 10, "Save", "Save", "9", 1);
02795    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 11, "Undelete", "Restore", "7", 1);
02796    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
02797 
02798 #ifdef DISPLAY
02799    /* Add another dot */
02800    bytes = 0;
02801    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, "   ....", "");
02802    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02803    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02804 #endif
02805 
02806    bytes = 0;
02807    for (x=0;x<5;x++) {
02808       snprintf(num, sizeof(num), "%d", x);
02809       bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(x), mbox(x), num, 1);
02810    }
02811    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + 5, "Cancel", "Cancel", "#", 1);
02812    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
02813 
02814 #ifdef DISPLAY
02815    /* Add another dot */
02816    bytes = 0;
02817    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, "   .....", "");
02818    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02819    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02820 #endif
02821 
02822    if (adsi_end_download(chan)) {
02823       bytes = 0;
02824       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Download Unsuccessful.", "");
02825       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
02826       bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02827       bytes += adsi_voice_mode(buf + bytes, 0);
02828       adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02829       return 0;
02830    }
02831    bytes = 0;
02832    bytes += adsi_download_disconnect(buf + bytes);
02833    bytes += adsi_voice_mode(buf + bytes, 0);
02834    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
02835 
02836    ast_log(LOG_DEBUG, "Done downloading scripts...\n");
02837 
02838 #ifdef DISPLAY
02839    /* Add last dot */
02840    bytes = 0;
02841    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "   ......", "");
02842    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02843 #endif
02844    ast_log(LOG_DEBUG, "Restarting session...\n");
02845 
02846    bytes = 0;
02847    /* Load the session now */
02848    if (adsi_load_session(chan, adsifdn, adsiver, 1) == 1) {
02849       *useadsi = 1;
02850       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", "");
02851    } else
02852       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Failed!", "");
02853 
02854    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02855    return 0;
02856 }

void adsi_login struct ast_channel chan  )  [static]
 

Definition at line 2875 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, ADSI_DIR_FROM_LEFT, adsi_display(), adsi_input_control(), adsi_input_format(), ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_KEY_APPS, adsi_load_soft_key(), adsi_logo(), ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_set_line(), adsi_transmit_message(), and adsi_voice_mode().

Referenced by vm_authenticate().

02876 {
02877    unsigned char buf[256];
02878    int bytes=0;
02879    unsigned char keys[8];
02880    int x;
02881    if (!adsi_available(chan))
02882       return;
02883 
02884    for (x=0;x<8;x++)
02885       keys[x] = 0;
02886    /* Set one key for next */
02887    keys[3] = ADSI_KEY_APPS + 3;
02888 
02889    bytes += adsi_logo(buf + bytes);
02890    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, " ", "");
02891    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ", "");
02892    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02893    bytes += adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Mailbox: ******", "");
02894    bytes += adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 1, 1, ADSI_JUST_LEFT);
02895    bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Enter", "Enter", "#", 1);
02896    bytes += adsi_set_keys(buf + bytes, keys);
02897    bytes += adsi_voice_mode(buf + bytes, 0);
02898    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02899 }

int adsi_logo unsigned char *  buf  )  [static]
 

Definition at line 2721 of file app_voicemail.c.

References ADSI_COMM_PAGE, adsi_display(), and ADSI_JUST_CENT.

Referenced by adsi_goodbye(), adsi_load_vmail(), adsi_login(), vm_newuser(), vm_options(), and vm_tempgreeting().

02722 {
02723    int bytes = 0;
02724    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
02725    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002 LSS, Inc.", "");
02726    return bytes;
02727 }

void adsi_message struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 2952 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_set_line(), adsi_transmit_message(), adsi_voice_mode(), ast_callerid_parse(), ast_strlen_zero(), vm_state::curbox, vm_state::curmsg, vm_state::deleted, vm_state::fn, vm_state::lastmsg, name, strsep(), and val.

Referenced by play_message(), and vm_execmain().

02953 {
02954    int bytes=0;
02955    unsigned char buf[256]; 
02956    char buf1[256], buf2[256];
02957    char fn2[256];
02958 
02959    char cid[256]="";
02960    char *val;
02961    char *name, *num;
02962    char datetime[21]="";
02963    FILE *f;
02964 
02965    unsigned char keys[8];
02966 
02967    int x;
02968 
02969    if (!adsi_available(chan))
02970       return;
02971 
02972    /* Retrieve important info */
02973    snprintf(fn2, sizeof(fn2), "%s.txt", vms->fn);
02974    f = fopen(fn2, "r");
02975    if (f) {
02976       while (!feof(f)) {   
02977          fgets((char *)buf, sizeof(buf), f);
02978          if (!feof(f)) {
02979             char *stringp=NULL;
02980             stringp = (char *)buf;
02981             strsep(&stringp, "=");
02982             val = strsep(&stringp, "=");
02983             if (!ast_strlen_zero(val)) {
02984                if (!strcmp((char *)buf, "callerid"))
02985                   ast_copy_string(cid, val, sizeof(cid));
02986                if (!strcmp((char *)buf, "origdate"))
02987                   ast_copy_string(datetime, val, sizeof(datetime));
02988             }
02989          }
02990       }
02991       fclose(f);
02992    }
02993    /* New meaning for keys */
02994    for (x=0;x<5;x++)
02995       keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
02996    keys[6] = 0x0;
02997    keys[7] = 0x0;
02998 
02999    if (!vms->curmsg) {
03000       /* No prev key, provide "Folder" instead */
03001       keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
03002    }
03003    if (vms->curmsg >= vms->lastmsg) {
03004       /* If last message ... */
03005       if (vms->curmsg) {
03006          /* but not only message, provide "Folder" instead */
03007          keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
03008          bytes += adsi_voice_mode(buf + bytes, 0);
03009 
03010       } else {
03011          /* Otherwise if only message, leave blank */
03012          keys[3] = 1;
03013       }
03014    }
03015 
03016    if (!ast_strlen_zero(cid)) {
03017       ast_callerid_parse(cid, &name, &num);
03018       if (!name)
03019          name = num;
03020    } else
03021       name = "Unknown Caller";
03022 
03023    /* If deleted, show "undeleted" */
03024 
03025    if (vms->deleted[vms->curmsg])
03026       keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
03027 
03028    /* Except "Exit" */
03029    keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
03030    snprintf(buf1, sizeof(buf1), "%s%s", vms->curbox,
03031       strcasecmp(vms->curbox, "INBOX") ? " Messages" : "");
03032    snprintf(buf2, sizeof(buf2), "Message %d of %d", vms->curmsg + 1, vms->lastmsg + 1);
03033 
03034    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
03035    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
03036    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, name, "");
03037    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, datetime, "");
03038    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
03039    bytes += adsi_set_keys(buf + bytes, keys);
03040    bytes += adsi_voice_mode(buf + bytes, 0);
03041 
03042    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
03043 }

void adsi_password struct ast_channel chan  )  [static]
 

Definition at line 2901 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, ADSI_DIR_FROM_LEFT, adsi_input_control(), adsi_input_format(), ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_set_line(), adsi_transmit_message(), and adsi_voice_mode().

Referenced by vm_authenticate().

02902 {
02903    unsigned char buf[256];
02904    int bytes=0;
02905    unsigned char keys[8];
02906    int x;
02907    if (!adsi_available(chan))
02908       return;
02909 
02910    for (x=0;x<8;x++)
02911       keys[x] = 0;
02912    /* Set one key for next */
02913    keys[3] = ADSI_KEY_APPS + 3;
02914 
02915    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
02916    bytes += adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
02917    bytes += adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
02918    bytes += adsi_set_keys(buf + bytes, keys);
02919    bytes += adsi_voice_mode(buf + bytes, 0);
02920    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
02921 }

void adsi_status struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 3090 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_set_line(), adsi_transmit_message(), adsi_voice_mode(), vm_state::lastmsg, vm_state::newmessages, and vm_state::oldmessages.

Referenced by vm_execmain().

03091 {
03092    unsigned char buf[256] = "";
03093    char buf1[256] = "", buf2[256] = "";
03094    int bytes=0;
03095    unsigned char keys[8];
03096    int x;
03097 
03098    char *newm = (vms->newmessages == 1) ? "message" : "messages";
03099    char *oldm = (vms->oldmessages == 1) ? "message" : "messages";
03100    if (!adsi_available(chan))
03101       return;
03102    if (vms->newmessages) {
03103       snprintf(buf1, sizeof(buf1), "You have %d new", vms->newmessages);
03104       if (vms->oldmessages) {
03105          strncat(buf1, " and", sizeof(buf1) - strlen(buf1) - 1);
03106          snprintf(buf2, sizeof(buf2), "%d old %s.", vms->oldmessages, oldm);
03107       } else {
03108          snprintf(buf2, sizeof(buf2), "%s.", newm);
03109       }
03110    } else if (vms->oldmessages) {
03111       snprintf(buf1, sizeof(buf1), "You have %d old", vms->oldmessages);
03112       snprintf(buf2, sizeof(buf2), "%s.", oldm);
03113    } else {
03114       strcpy(buf1, "You have no messages.");
03115       buf2[0] = ' ';
03116       buf2[1] = '\0';
03117    }
03118    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
03119    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
03120    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
03121 
03122    for (x=0;x<6;x++)
03123       keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
03124    keys[6] = 0;
03125    keys[7] = 0;
03126 
03127    /* Don't let them listen if there are none */
03128    if (vms->lastmsg < 0)
03129       keys[0] = 1;
03130    bytes += adsi_set_keys(buf + bytes, keys);
03131 
03132    bytes += adsi_voice_mode(buf + bytes, 0);
03133 
03134    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
03135 }

void adsi_status2 struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 3137 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_set_line(), adsi_transmit_message(), adsi_voice_mode(), vm_state::curbox, and vm_state::lastmsg.

Referenced by vm_execmain().

03138 {
03139    unsigned char buf[256] = "";
03140    char buf1[256] = "", buf2[256] = "";
03141    int bytes=0;
03142    unsigned char keys[8];
03143    int x;
03144 
03145    char *mess = (vms->lastmsg == 0) ? "message" : "messages";
03146 
03147    if (!adsi_available(chan))
03148       return;
03149 
03150    /* Original command keys */
03151    for (x=0;x<6;x++)
03152       keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
03153 
03154    keys[6] = 0;
03155    keys[7] = 0;
03156 
03157    if ((vms->lastmsg + 1) < 1)
03158       keys[0] = 0;
03159 
03160    snprintf(buf1, sizeof(buf1), "%s%s has", vms->curbox,
03161       strcasecmp(vms->curbox, "INBOX") ? " folder" : "");
03162 
03163    if (vms->lastmsg + 1)
03164       snprintf(buf2, sizeof(buf2), "%d %s.", vms->lastmsg + 1, mess);
03165    else
03166       strcpy(buf2, "no messages.");
03167    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
03168    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
03169    bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, "", "");
03170    bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
03171    bytes += adsi_set_keys(buf + bytes, keys);
03172 
03173    bytes += adsi_voice_mode(buf + bytes, 0);
03174 
03175    adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
03176    
03177 }

int advanced_options struct ast_channel chan,
struct ast_vm_user vmu,
struct vm_state vms,
int  msg,
int  option,
signed char  record_gain
[static]
 

Definition at line 6381 of file app_voicemail.c.

References ast_callerid_parse(), ast_config_destroy(), ast_config_load(), ast_log(), ast_play_and_wait(), ast_strlen_zero(), ast_variable_retrieve(), ast_verbose(), ast_waitfordigit(), ast_vm_user::callback, ast_vm_user::context, vm_state::curdir, vm_state::curmsg, ast_vm_user::dialout, dialout(), DISPOSE, find_user(), vm_state::fn, vm_state::fn2, vm_state::heard, leave_voicemail(), LOG_WARNING, make_file(), name, play_message_callerid(), play_message_datetime(), leave_vm_options::record_gain, RETRIEVE, vm_state::starting, VERBOSE_PREFIX_3, and wait_file().

Referenced by vm_execmain().

06383 {
06384    int res = 0;
06385    char filename[256],*origtime, *cid, *context, *name, *num;
06386    struct ast_config *msg_cfg;
06387    int retries = 0;
06388 
06389    vms->starting = 0; 
06390    make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
06391 
06392    /* Retrieve info from VM attribute file */
06393 
06394    make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
06395    snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
06396    RETRIEVE(vms->curdir, vms->curmsg);
06397    msg_cfg = ast_config_load(filename);
06398    DISPOSE(vms->curdir, vms->curmsg);
06399    if (!msg_cfg) {
06400       ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
06401       return 0;
06402    }
06403 
06404    if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime")))
06405       return 0;
06406 
06407    cid = ast_variable_retrieve(msg_cfg, "message", "callerid");
06408 
06409    context = ast_variable_retrieve(msg_cfg, "message", "context");
06410    if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */
06411       context = ast_variable_retrieve(msg_cfg, "message","macrocontext");
06412 
06413    if (option == 3) {
06414 
06415       if (!res)
06416          res = play_message_datetime(chan, vmu, origtime, filename);
06417       if (!res)
06418          res = play_message_callerid(chan, vms, cid, context, 0);
06419    } else if (option == 2) { /* Call back */
06420 
06421       if (!ast_strlen_zero(cid)) {
06422          ast_callerid_parse(cid, &name, &num);
06423          while ((res > -1) && (res != 't')) {
06424             switch(res) {
06425                case '1':
06426                   if (num) {
06427                      /* Dial the CID number */
06428                      res = dialout(chan, vmu, num, vmu->callback);
06429                      if (res)
06430                         return 9;
06431                   } else {
06432                      res = '2';
06433                   }
06434                   break;
06435 
06436                case '2':
06437                   /* Want to enter a different number, can only do this if there's a dialout context for this user */
06438                   if (!ast_strlen_zero(vmu->dialout)) {
06439                      res = dialout(chan, vmu, NULL, vmu->dialout);
06440                      if (res)
06441                         return 9;
06442                   } else {
06443                      ast_verbose( VERBOSE_PREFIX_3 "Caller can not specify callback number - no dialout context available\n");
06444                      res = ast_play_and_wait(chan, "vm-sorry");
06445                   }
06446                   return res;
06447                case '*':
06448                   res = 't';
06449                   break;
06450                case '3':
06451                case '4':
06452                case '5':
06453                case '6':
06454                case '7':
06455                case '8':
06456                case '9':
06457                case '0':
06458 
06459                   res = ast_play_and_wait(chan, "vm-sorry");
06460                   retries++;
06461                   break;
06462                default:
06463                   if (num) {
06464                      ast_verbose( VERBOSE_PREFIX_3 "Confirm CID number '%s' is number to use for callback\n", num);
06465                      res = ast_play_and_wait(chan, "vm-num-i-have");
06466                      if (!res)
06467                         res = play_message_callerid(chan, vms, num, vmu->context, 1);
06468                      if (!res)
06469                         res = ast_play_and_wait(chan, "vm-tocallnum");
06470                      /* Only prompt for a caller-specified number if there is a dialout context specified */
06471                      if (!ast_strlen_zero(vmu->dialout)) {
06472                         if (!res)
06473                            res = ast_play_and_wait(chan, "vm-calldiffnum");
06474                      }
06475                   } else {
06476                      res = ast_play_and_wait(chan, "vm-nonumber");
06477                      if (!ast_strlen_zero(vmu->dialout)) {
06478                         if (!res)
06479                            res = ast_play_and_wait(chan, "vm-toenternumber");
06480                      }
06481                   }
06482                   if (!res)
06483                      res = ast_play_and_wait(chan, "vm-star-cancel");
06484                   if (!res)
06485                      res = ast_waitfordigit(chan, 6000);
06486                   if (!res)
06487                      retries++;
06488                   if (retries > 3)
06489                      res = 't';
06490                      break; 
06491 
06492                   }
06493                if (res == 't')
06494                   res = 0;
06495                else if (res == '*')
06496                   res = -1;
06497             }
06498          }
06499 
06500    }
06501    else if (option == 1) { /* Reply */
06502       /* Send reply directly to sender */
06503       if (!ast_strlen_zero(cid)) {
06504          ast_callerid_parse(cid, &name, &num);
06505          if (!num) {
06506             ast_verbose(VERBOSE_PREFIX_3 "No CID number available, no reply sent\n");
06507             if (!res)
06508                res = ast_play_and_wait(chan, "vm-nonumber");
06509             return res;
06510          } else {
06511             if (find_user(NULL, vmu->context, num)) {
06512                struct leave_vm_options leave_options;
06513 
06514                ast_verbose(VERBOSE_PREFIX_3 "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
06515                
06516                memset(&leave_options, 0, sizeof(leave_options));
06517                leave_options.record_gain = record_gain;
06518                res = leave_voicemail(chan, num, &leave_options);
06519                if (!res)
06520                   res = 't';
06521                return res;
06522             } else {
06523                /* Sender has no mailbox, can't reply */
06524                ast_verbose( VERBOSE_PREFIX_3 "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
06525                ast_play_and_wait(chan, "vm-nobox");
06526                res = 't';
06527                return res;
06528             }
06529          } 
06530          res = 0;
06531       }
06532    }
06533 
06534    ast_config_destroy(msg_cfg);
06535 
06536    if (!res) {
06537       make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
06538       vms->heard[msg] = 1;
06539       res = wait_file(chan, vms, vms->fn);
06540    }
06541    return res;
06542 }

int append_mailbox char *  context,
char *  mbox,
char *  data
[static]
 

Definition at line 5574 of file app_voicemail.c.

References apply_options(), ast_vm_user::context, ast_vm_user::email, ast_vm_user::fullname, ast_vm_user::mailbox, malloc, mbox(), ast_vm_user::next, ast_vm_user::pager, ast_vm_user::password, populate_defaults(), s, strsep(), users, and usersl.

Referenced by load_config().

05575 {
05576    /* Assumes lock is already held */
05577    char tmp[256] = "";
05578    char *stringp;
05579    char *s;
05580    struct ast_vm_user *vmu;
05581 
05582    ast_copy_string(tmp, data, sizeof(tmp));
05583    vmu = malloc(sizeof(struct ast_vm_user));
05584    if (vmu) {
05585       memset(vmu, 0, sizeof(struct ast_vm_user));
05586       ast_copy_string(vmu->context, context, sizeof(vmu->context));
05587       ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
05588 
05589       populate_defaults(vmu);
05590 
05591       stringp = tmp;
05592       if ((s = strsep(&stringp, ","))) 
05593          ast_copy_string(vmu->password, s, sizeof(vmu->password));
05594       if (stringp && (s = strsep(&stringp, ","))) 
05595          ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
05596       if (stringp && (s = strsep(&stringp, ","))) 
05597          ast_copy_string(vmu->email, s, sizeof(vmu->email));
05598       if (stringp && (s = strsep(&stringp, ","))) 
05599          ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
05600       if (stringp && (s = strsep(&stringp, ","))) 
05601          apply_options(vmu, s);
05602       
05603       vmu->next = NULL;
05604       if (usersl)
05605          usersl->next = vmu;
05606       else
05607          users = vmu;
05608       usersl = vmu;
05609    }
05610    return 0;
05611 }

void apply_option struct ast_vm_user vmu,
const char *  var,
const char *  value
[static]
 

Definition at line 439 of file app_voicemail.c.

References apply_options(), ast_log(), ast_set2_flag, ast_true(), ast_vm_user::callback, ast_vm_user::dialout, ast_vm_user::exit, ast_vm_user::language, LOG_WARNING, MAXMSG, ast_vm_user::maxmsg, MAXMSGLIMIT, ast_vm_user::saydurationm, ast_vm_user::serveremail, var, VM_ATTACH, VM_DELETE, VM_ENVELOPE, VM_FORCEGREET, VM_FORCENAME, VM_OPERATOR, VM_REVIEW, VM_SAYCID, VM_SAYDURATION, VM_SVMAIL, and ast_vm_user::zonetag.

Referenced by apply_options(), and find_user_realtime().

00440 {
00441    int x;
00442    if (!strcasecmp(var, "attach")) {
00443       ast_set2_flag(vmu, ast_true(value), VM_ATTACH); 
00444    } else if (!strcasecmp(var, "serveremail")) {
00445       ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
00446    } else if (!strcasecmp(var, "language")) {
00447       ast_copy_string(vmu->language, value, sizeof(vmu->language));
00448    } else if (!strcasecmp(var, "tz")) {
00449       ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
00450    } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
00451       ast_set2_flag(vmu, ast_true(value), VM_DELETE); 
00452    } else if (!strcasecmp(var, "saycid")){
00453       ast_set2_flag(vmu, ast_true(value), VM_SAYCID); 
00454    } else if (!strcasecmp(var,"sendvoicemail")){
00455       ast_set2_flag(vmu, ast_true(value), VM_SVMAIL); 
00456    } else if (!strcasecmp(var, "review")){
00457       ast_set2_flag(vmu, ast_true(value), VM_REVIEW); 
00458    } else if (!strcasecmp(var, "operator")){
00459       ast_set2_flag(vmu, ast_true(value), VM_OPERATOR);  
00460    } else if (!strcasecmp(var, "envelope")){
00461       ast_set2_flag(vmu, ast_true(value), VM_ENVELOPE);  
00462    } else if (!strcasecmp(var, "sayduration")){
00463       ast_set2_flag(vmu, ast_true(value), VM_SAYDURATION);  
00464    } else if (!strcasecmp(var, "saydurationm")){
00465       if (sscanf(value, "%d", &x) == 1) {
00466          vmu->saydurationm = x;
00467       } else {
00468          ast_log(LOG_WARNING, "Invalid min duration for say duration\n");
00469       }
00470    } else if (!strcasecmp(var, "forcename")){
00471       ast_set2_flag(vmu, ast_true(value), VM_FORCENAME); 
00472    } else if (!strcasecmp(var, "forcegreetings")){
00473       ast_set2_flag(vmu, ast_true(value), VM_FORCEGREET);   
00474    } else if (!strcasecmp(var, "callback")) {
00475       ast_copy_string(vmu->callback, value, sizeof(vmu->callback));
00476    } else if (!strcasecmp(var, "dialout")) {
00477       ast_copy_string(vmu->dialout, value, sizeof(vmu->dialout));
00478    } else if (!strcasecmp(var, "exitcontext")) {
00479       ast_copy_string(vmu->exit, value, sizeof(vmu->exit));
00480    } else if (!strcasecmp(var, "maxmsg")) {
00481       vmu->maxmsg = atoi(value);
00482       if (vmu->maxmsg <= 0) {
00483          ast_log(LOG_WARNING, "Invalid number of messages per folder maxmsg=%s. Using default value %i\n", value, MAXMSG);
00484          vmu->maxmsg = MAXMSG;
00485       } else if (vmu->maxmsg > MAXMSGLIMIT) {
00486          ast_log(LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value maxmsg=%s\n", MAXMSGLIMIT, value);
00487          vmu->maxmsg = MAXMSGLIMIT;
00488       }
00489    } else if (!strcasecmp(var, "options")) {
00490       apply_options(vmu, value);
00491    }
00492 }

void apply_options struct ast_vm_user vmu,
const char *  options
[static]
 

Definition at line 510 of file app_voicemail.c.

References apply_option(), ast_strdupa, s, strsep(), and var.

Referenced by append_mailbox(), and apply_option().

00511 {  /* Destructively Parse options and apply */
00512    char *stringp;
00513    char *s;
00514    char *var, *value;
00515    stringp = ast_strdupa(options);
00516    while ((s = strsep(&stringp, "|"))) {
00517       value = s;
00518       if ((var = strsep(&value, "=")) && value) {
00519          apply_option(vmu, var, value);
00520       }
00521    }  
00522 }

AST_APP_OPTIONS vm_app_options   ) 
 

AST_MUTEX_DEFINE_STATIC vmlock   ) 
 

int base_encode char *  filename,
FILE *  so
[static]
 

Definition at line 1555 of file app_voicemail.c.

References ast_log(), eol, inchar(), baseio::iocp, LOG_WARNING, ochar(), and so.

Referenced by sendmail().

01556 {
01557    unsigned char dtable[BASEMAXINLINE];
01558    int i,hiteof= 0;
01559    FILE *fi;
01560    struct baseio bio;
01561 
01562    memset(&bio, 0, sizeof(bio));
01563    bio.iocp = BASEMAXINLINE;
01564 
01565    if (!(fi = fopen(filename, "rb"))) {
01566       ast_log(LOG_WARNING, "Failed to open log file: %s: %s\n", filename, strerror(errno));
01567       return -1;
01568    }
01569 
01570    for (i= 0;i<9;i++) {
01571       dtable[i]= 'A'+i;
01572       dtable[i+9]= 'J'+i;
01573       dtable[26+i]= 'a'+i;
01574       dtable[26+i+9]= 'j'+i;
01575    }
01576    for (i= 0;i<8;i++) {
01577       dtable[i+18]= 'S'+i;
01578       dtable[26+i+18]= 's'+i;
01579    }
01580    for (i= 0;i<10;i++) {
01581       dtable[52+i]= '0'+i;
01582    }
01583    dtable[62]= '+';
01584    dtable[63]= '/';
01585 
01586    while (!hiteof){
01587       unsigned char igroup[3],ogroup[4];
01588       int c,n;
01589 
01590       igroup[0]= igroup[1]= igroup[2]= 0;
01591 
01592       for (n= 0;n<3;n++) {
01593          if ((c = inchar(&bio, fi)) == EOF) {
01594             hiteof= 1;
01595             break;
01596          }
01597 
01598          igroup[n]= (unsigned char)c;
01599       }
01600 
01601       if (n> 0) {
01602          ogroup[0]= dtable[igroup[0]>>2];
01603          ogroup[1]= dtable[((igroup[0]&3)<<4)|(igroup[1]>>4)];
01604          ogroup[2]= dtable[((igroup[1]&0xF)<<2)|(igroup[2]>>6)];
01605          ogroup[3]= dtable[igroup[2]&0x3F];
01606 
01607          if (n<3) {
01608             ogroup[3]= '=';
01609 
01610             if (n<2)
01611                ogroup[2]= '=';
01612          }
01613 
01614          for (i= 0;i<4;i++)
01615             ochar(&bio, ogroup[i], so);
01616       }
01617    }
01618 
01619    if (fputs(eol,so)==EOF)
01620       return 0;
01621 
01622    fclose(fi);
01623 
01624    return 1;
01625 }

int change_password_realtime struct ast_vm_user vmu,
const char *  password
[static]
 

Definition at line 494 of file app_voicemail.c.

References ast_strlen_zero(), ast_update_realtime(), ast_vm_user::password, and ast_vm_user::uniqueid.

Referenced by vm_change_password().

00495 {
00496    int res;
00497    if (!ast_strlen_zero(vmu->uniqueid)) {
00498       res = ast_update_realtime("voicemail", "uniqueid", vmu->uniqueid, "password", password, NULL);
00499       if (res > 0) {
00500          ast_copy_string(vmu->password, password, sizeof(vmu->password));
00501          res = 0;
00502       } else if (!res) {
00503          res = -1;
00504       }
00505       return res;
00506    }
00507    return -1;
00508 }

int close_mailbox struct vm_state vms,
struct ast_vm_user vmu
[static]
 

Definition at line 3876 of file app_voicemail.c.

References ast_unlock_path(), ast_vm_user::context, vm_state::curbox, vm_state::curdir, vm_state::curmsg, DELETE, vm_state::deleted, EXISTS, vm_state::fn, vm_state::fn2, vm_state::heard, vm_state::lastmsg, ast_vm_user::mailbox, make_file(), ast_vm_user::maxmsg, RENAME, save_to_folder(), vm_state::username, and vm_lock_path().

Referenced by vm_execmain().

03877 {
03878    int x, nummsg;
03879    int res = 0;
03880 
03881    if (vms->lastmsg <= -1)
03882       goto done;
03883 
03884    /* Get the deleted messages fixed */ 
03885    if (vm_lock_path(vms->curdir))
03886       return ERROR_LOCK_PATH;
03887    
03888    vms->curmsg = -1; 
03889    for (x=0;x < vmu->maxmsg;x++) { 
03890       if (!vms->deleted[x] && (strcasecmp(vms->curbox, "INBOX") || !vms->heard[x])) { 
03891          /* Save this message.  It's not in INBOX or hasn't been heard */ 
03892          make_file(vms->fn, sizeof(vms->fn), vms->curdir, x); 
03893          if (!EXISTS(vms->curdir, x, vms->fn, NULL)) 
03894             break;
03895          vms->curmsg++; 
03896          make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg); 
03897          if (strcmp(vms->fn, vms->fn2)) { 
03898             RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, vms->fn2);
03899          } 
03900       } else if (!strcasecmp(vms->curbox, "INBOX") && vms->heard[x] && !vms->deleted[x]) { 
03901          /* Move to old folder before deleting */ 
03902          res = save_to_folder(vmu, vms->curdir, x, vmu->context, vms->username, 1);
03903          if (res == ERROR_LOCK_PATH) {
03904             /* If save failed do not delete the message */
03905             vms->deleted[x] = 0;
03906             vms->heard[x] = 0;
03907             --x;
03908          } 
03909       } 
03910    } 
03911 
03912    /* Delete ALL remaining messages */
03913    nummsg = x - 1;
03914    for (x = vms->curmsg + 1; x <= nummsg; x++) {
03915       make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
03916       if (EXISTS(vms->curdir, x, vms->fn, NULL))
03917          DELETE(vms->curdir, x, vms->fn);
03918    }
03919    ast_unlock_path(vms->curdir);
03920 
03921 done:
03922    if (vms->deleted)
03923       memset(vms->deleted, 0, sizeof(vms->deleted)); 
03924    if (vms->heard)
03925       memset(vms->heard, 0, sizeof(vms->heard)); 
03926 
03927    return 0;
03928 }

char* complete_show_voicemail_users char *  line,
char *  word,
int  pos,
int  state
[static]
 

Definition at line 5787 of file app_voicemail.c.

References ast_vm_user::context, ast_vm_user::next, and strdup.

05788 {
05789    int which = 0;
05790    struct ast_vm_user *vmu = users;
05791    char *context = "";
05792 
05793    /* 0 - show; 1 - voicemail; 2 - users; 3 - for; 4 - <context> */
05794    if (pos > 4)
05795       return NULL;
05796    if (pos == 3) {
05797       if (state == 0)
05798          return strdup("for");
05799       else
05800          return NULL;
05801    }
05802    while (vmu) {
05803       if (!strncasecmp(word, vmu->context, strlen(word))) {
05804          if (context && strcmp(context, vmu->context)) {
05805             if (++which > state) {
05806                return strdup(vmu->context);
05807             }
05808             context = vmu->context;
05809          }
05810       }
05811       vmu = vmu->next;
05812    }
05813    return NULL;
05814 }

int copy char *  infile,
char *  outfile
[static]
 

Definition at line 1407 of file app_voicemail.c.

References ast_log(), LOG_WARNING, and VOICEMAIL_FILE_MODE.

Referenced by ast_filehelper(), and copy_file().

01408 {
01409    int ifd;
01410    int ofd;
01411    int res;
01412    int len;
01413    char buf[4096];
01414 
01415 #ifdef HARDLINK_WHEN_POSSIBLE
01416    /* Hard link if possible; saves disk space & is faster */
01417    if (link(infile, outfile)) {
01418 #endif
01419       if ((ifd = open(infile, O_RDONLY)) < 0) {
01420          ast_log(LOG_WARNING, "Unable to open %s in read-only mode\n", infile);
01421          return -1;
01422       }
01423       if ((ofd = open(outfile, O_WRONLY | O_TRUNC | O_CREAT, VOICEMAIL_FILE_MODE)) < 0) {
01424          ast_log(LOG_WARNING, "Unable to open %s in write-only mode\n", outfile);
01425          close(ifd);
01426          return -1;
01427       }
01428       do {
01429          len = read(ifd, buf, sizeof(buf));
01430          if (len < 0) {
01431             ast_log(LOG_WARNING, "Read failed on %s: %s\n", infile, strerror(errno));
01432             close(ifd);
01433             close(ofd);
01434             unlink(outfile);
01435          }
01436          if (len) {
01437             res = write(ofd, buf, len);
01438             if (errno == ENOMEM || errno == ENOSPC || res != len) {
01439                ast_log(LOG_WARNING, "Write failed on %s (%d of %d): %s\n", outfile, res, len, strerror(errno));
01440                close(ifd);
01441                close(ofd);
01442                unlink(outfile);
01443             }
01444          }
01445       } while (len);
01446       close(ifd);
01447       close(ofd);
01448       return 0;
01449 #ifdef HARDLINK_WHEN_POSSIBLE
01450    } else {
01451       /* Hard link succeeded */
01452       return 0;
01453    }
01454 #endif
01455 }

void copy_file char *  frompath,
char *  topath
[static]
 

Definition at line 1457 of file app_voicemail.c.

References ast_filecopy(), and copy().

01458 {
01459    char frompath2[256],topath2[256];
01460    ast_filecopy(frompath, topath, NULL);
01461    snprintf(frompath2, sizeof(frompath2), "%s.txt", frompath);
01462    snprintf(topath2, sizeof(topath2), "%s.txt", topath);
01463    copy(frompath2, topath2);
01464 }

int copy_message struct ast_channel chan,
struct ast_vm_user vmu,
int  imbox,
int  msgnum,
long  duration,
struct ast_vm_user recip,
char *  fmt
[static]
 

Definition at line 2307 of file app_voicemail.c.

References ast_log(), ast_unlock_path(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_vm_user::context, COPY, create_dirpath(), EXISTS, fmt, ast_channel::language, LOG_ERROR, LOG_NOTICE, ast_vm_user::mailbox, make_dir(), make_file(), ast_vm_user::maxmsg, mbox(), notify_new_message(), and vm_lock_path().

Referenced by leave_voicemail().

02308 {
02309    char fromdir[256], todir[256], frompath[256], topath[256];
02310    char *frombox = mbox(imbox);
02311    int recipmsgnum;
02312 
02313    ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context);
02314 
02315    create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX");
02316   
02317    make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox);
02318    make_file(frompath, sizeof(frompath), fromdir, msgnum);
02319 
02320    if (vm_lock_path(todir))
02321       return ERROR_LOCK_PATH;
02322 
02323    recipmsgnum = 0;
02324    do {
02325       make_file(topath, sizeof(topath), todir, recipmsgnum);
02326       if (!EXISTS(todir, recipmsgnum, topath, chan->language))
02327          break;
02328       recipmsgnum++;
02329    } while (recipmsgnum < recip->maxmsg);
02330    if (recipmsgnum < recip->maxmsg) {
02331       COPY(fromdir, msgnum, todir, recipmsgnum, recip->mailbox, recip->context, frompath, topath);
02332    } else {
02333       ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
02334    }
02335    ast_unlock_path(todir);
02336    notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
02337    
02338    return 0;
02339 }

int count_messages struct ast_vm_user vmu,
char *  dir
[static]
 

Definition at line 1374 of file app_voicemail.c.

References ast_unlock_path(), and vm_lock_path().

Referenced by forward_message(), and open_mailbox().

01375 {
01376    /* Find all .txt files - even if they are not in sequence from 0000 */
01377 
01378    int vmcount = 0;
01379    DIR *vmdir = NULL;
01380    struct dirent *vment = NULL;
01381 
01382    if (vm_lock_path(dir))
01383       return ERROR_LOCK_PATH;
01384 
01385    if ((vmdir = opendir(dir))) {
01386       while ((vment = readdir(vmdir))) {
01387          if (strlen(vment->d_name) > 7 && !strncmp(vment->d_name + 7, ".txt", 4)) 
01388             vmcount++;
01389       }
01390       closedir(vmdir);
01391    }
01392    ast_unlock_path(dir);
01393    
01394    return vmcount;
01395 }

int create_dirpath char *  dest,
int  len,
char *  context,
char *  ext,
char *  mailbox
[static]
 

basically mkdir -p $dest/$context/$ext/$mailbox String. base directory. String. Ignored if is null or empty string. String. Ignored if is null or empty string. String. Ignored if is null or empty string.

Returns:
0 on failure, 1 on success.

Definition at line 790 of file app_voicemail.c.

References ast_log(), LOG_WARNING, and make_dir().

Referenced by copy_message(), leave_voicemail(), save_to_folder(), and vm_execmain().

00791 {
00792    mode_t   mode = VOICEMAIL_DIR_MODE;
00793 
00794    if(context && context[0] != '\0') {
00795       make_dir(dest, len, context, "", "");
00796       if(mkdir(dest, mode) && errno != EEXIST) {
00797          ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno));
00798          return 0;
00799       }
00800    }
00801    if(ext && ext[0] != '\0') {
00802       make_dir(dest, len, context, ext, "");
00803       if(mkdir(dest, mode) && errno != EEXIST) {
00804          ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno));
00805          return 0;
00806       }
00807    }
00808    if(mailbox && mailbox[0] != '\0') {
00809       make_dir(dest, len, context, ext, mailbox);
00810       if(mkdir(dest, mode) && errno != EEXIST) {
00811          ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dest, strerror(errno));
00812          return 0;
00813       }
00814    }
00815    return 1;
00816 }

char* description void   ) 
 

Provides a description of the module.

Returns:
a short description of your module

Definition at line 6319 of file app_voicemail.c.

06320 {
06321    return tdesc;
06322 }

int dialout struct ast_channel chan,
struct ast_vm_user vmu,
char *  num,
char *  outgoing_context
[static]
 

Definition at line 6324 of file app_voicemail.c.

References ast_play_and_wait(), ast_readstring(), ast_strlen_zero(), ast_verbose(), ast_waitfordigit(), ast_channel::context, ast_channel::exten, ast_channel::priority, and VERBOSE_PREFIX_3.

Referenced by advanced_options(), and vm_execmain().

06325 {
06326    int cmd = 0;
06327    char destination[80] = "";
06328    int retries = 0;
06329 
06330    if (!num) {
06331       ast_verbose( VERBOSE_PREFIX_3 "Destination number will be entered manually\n");
06332       while (retries < 3 && cmd != 't') {
06333          destination[1] = '\0';
06334          destination[0] = cmd = ast_play_and_wait(chan,"vm-enter-num-to-call");
06335          if (!cmd)
06336             destination[0] = cmd = ast_play_and_wait(chan, "vm-then-pound");
06337          if (!cmd)
06338             destination[0] = cmd = ast_play_and_wait(chan, "vm-star-cancel");
06339          if (!cmd) {
06340             cmd = ast_waitfordigit(chan, 6000);
06341             if (cmd)
06342                destination[0] = cmd;
06343          }
06344          if (!cmd) {
06345             retries++;
06346          } else {
06347 
06348             if (cmd < 0)
06349                return 0;
06350             if (cmd == '*') {
06351                ast_verbose( VERBOSE_PREFIX_3 "User hit '*' to cancel outgoing call\n");
06352                return 0;
06353             }
06354             if ((cmd = ast_readstring(chan,destination + strlen(destination),sizeof(destination)-1,6000,10000,"#")) < 0) 
06355                retries++;
06356             else
06357                cmd = 't';
06358          }
06359       }
06360       if (retries >= 3) {
06361          return 0;
06362       }
06363       
06364    } else {
06365       ast_verbose( VERBOSE_PREFIX_3 "Destination number is CID number '%s'\n", num);
06366       ast_copy_string(destination, num, sizeof(destination));
06367    }
06368 
06369    if (!ast_strlen_zero(destination)) {
06370       if (destination[strlen(destination) -1 ] == '*')
06371          return 0; 
06372       ast_verbose( VERBOSE_PREFIX_3 "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, chan->context);
06373       ast_copy_string(chan->exten, destination, sizeof(chan->exten));
06374       ast_copy_string(chan->context, outgoing_context, sizeof(chan->context));
06375       chan->priority = 0;
06376       return 9;
06377    }
06378    return 0;
06379 }

struct ast_vm_user* find_user struct ast_vm_user ivm,
const char *  context,
const char *  mailbox
[static]
 

Definition at line 574 of file app_voicemail.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_set2_flag, ast_test_flag, find_user_realtime(), globalflags, malloc, ast_vm_user::next, VM_ALLOCED, and VM_SEARCH.

Referenced by admin_exec(), advanced_options(), check_user_full(), forward_message(), leave_voicemail(), setup_incoming_call(), sip_show_user(), update_call_counter(), vm_authenticate(), vm_box_exists(), and vm_execmain().

00575 {
00576    /* This function could be made to generate one from a database, too */
00577    struct ast_vm_user *vmu=NULL, *cur;
00578    ast_mutex_lock(&vmlock);
00579    cur = users;
00580 
00581    if (!context && !ast_test_flag((&globalflags), VM_SEARCH))
00582       context = "default";
00583 
00584    while (cur) {
00585       if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mailbox, cur->mailbox))
00586          break;
00587       if (context && (!strcasecmp(context, cur->context)) && (!strcasecmp(mailbox, cur->mailbox)))
00588          break;
00589       cur=cur->next;
00590    }
00591    if (cur) {
00592       if (ivm)
00593          vmu = ivm;
00594       else
00595          /* Make a copy, so that on a reload, we have no race */
00596          vmu = malloc(sizeof(struct ast_vm_user));
00597       if (vmu) {
00598          memcpy(vmu, cur, sizeof(struct ast_vm_user));
00599          ast_set2_flag(vmu, !ivm, VM_ALLOCED);  
00600          vmu->next = NULL;
00601       }
00602    } else
00603       vmu = find_user_realtime(ivm, context, mailbox);
00604    ast_mutex_unlock(&vmlock);
00605    return vmu;
00606 }

struct ast_vm_user* find_user_realtime struct ast_vm_user ivm,
const char *  context,
const char *  mailbox
[static]
 

Definition at line 524 of file app_voicemail.c.

References apply_option(), ast_load_realtime(), ast_set_flag, ast_test_flag, ast_vm_user::context, ast_vm_user::email, free, ast_vm_user::fullname, globalflags, ast_vm_user::mailbox, malloc, ast_variable::name, ast_variable::next, ast_vm_user::pager, ast_vm_user::password, populate_defaults(), ast_vm_user::uniqueid, ast_variable::value, var, VM_ALLOCED, and VM_SEARCH.

Referenced by find_user().

00525 {
00526    struct ast_variable *var, *tmp;
00527    struct ast_vm_user *retval;
00528 
00529    if (ivm)
00530       retval=ivm;
00531    else
00532       retval=malloc(sizeof(struct ast_vm_user));
00533 
00534    if (retval) {
00535       memset(retval, 0, sizeof(struct ast_vm_user));
00536       if (!ivm)
00537          ast_set_flag(retval, VM_ALLOCED);   
00538       if (mailbox) 
00539          ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
00540       populate_defaults(retval);
00541       if (!context && ast_test_flag((&globalflags), VM_SEARCH))
00542          var = ast_load_realtime("voicemail", "mailbox", mailbox, NULL);
00543       else
00544          var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, NULL);
00545       if (var) {
00546          tmp = var;
00547          while(tmp) {
00548             printf("%s => %s\n", tmp->name, tmp->value);
00549             if (!strcasecmp(tmp->name, "password")) {
00550                ast_copy_string(retval->password, tmp->value, sizeof(retval->password));
00551             } else if (!strcasecmp(tmp->name, "uniqueid")) {
00552                ast_copy_string(retval->uniqueid, tmp->value, sizeof(retval->uniqueid));
00553             } else if (!strcasecmp(tmp->name, "pager")) {
00554                ast_copy_string(retval->pager, tmp->value, sizeof(retval->pager));
00555             } else if (!strcasecmp(tmp->name, "email")) {
00556                ast_copy_string(retval->email, tmp->value, sizeof(retval->email));
00557             } else if (!strcasecmp(tmp->name, "fullname")) {
00558                ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname));
00559             } else if (!strcasecmp(tmp->name, "context")) {
00560                ast_copy_string(retval->context, tmp->value, sizeof(retval->context));
00561             } else
00562                apply_option(retval, tmp->name, tmp->value);
00563             tmp = tmp->next;
00564          } 
00565       } else { 
00566          if (!ivm) 
00567             free(retval);
00568          retval = NULL;
00569       }  
00570    } 
00571    return retval;
00572 }

int forward_message struct ast_channel chan,
char *  context,
char *  dir,
int  curmsg,
struct ast_vm_user sender,
char *  fmt,
int  flag,
signed char  record_gain
[static]
 

Definition at line 3349 of file app_voicemail.c.

References app, ast_clear_flag, ast_config_destroy(), ast_config_load(), ast_log(), ast_play_and_wait(), ast_readstring(), ast_safe_system(), ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_variable_retrieve(), ast_waitfordigit(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, count_messages(), EVENT_FLAG_CALL, ast_channel::exten, find_user(), fmt, free_user(), ast_vm_user::fullname, globalflags, has_voicemail(), ast_channel::language, leave_voicemail(), LOG_DEBUG, LOG_WARNING, manager_event(), ast_vm_user::next, pbx_exec(), pbx_findapp(), ast_channel::priority, leave_vm_options::record_gain, RETRIEVE, run_externnotify(), s, sendmail(), sendpage(), STORE, strsep(), VM_ATTACH, VM_DIRECFORWARD, vm_forwardoptions(), VM_SPOOL_DIR, and vmfmts.

Referenced by vm_execmain().

03351 {
03352    char username[70]="";
03353    char sys[256];
03354    char todir[256];
03355    int todircount=0;
03356    int duration;
03357    struct ast_config *mif;
03358    char miffile[256];
03359    char fn[256];
03360    char callerid[512];
03361    char ext_context[256]="";
03362    int res = 0, cmd = 0;
03363    struct ast_vm_user *receiver = NULL, *extensions = NULL, *vmtmp = NULL, *vmfree;
03364    char tmp[256];
03365    char *stringp, *s;
03366    int saved_messages = 0, found = 0;
03367    int valid_extensions = 0;
03368    
03369    while (!res && !valid_extensions) {
03370       int use_directory = 0;
03371       if(ast_test_flag((&globalflags), VM_DIRECFORWARD)) {
03372          int done = 0;
03373          int retries = 0;
03374          cmd=0;
03375          while((cmd >= 0) && !done ){
03376             if (cmd)
03377                retries = 0;
03378             switch (cmd) {
03379             case '1': 
03380                use_directory = 0;
03381                done = 1;
03382                break;
03383             case '2': 
03384                use_directory = 1;
03385                done=1;
03386                break;
03387             case '*': 
03388                cmd = 't';
03389                done = 1;
03390                break;
03391             default: 
03392                /* Press 1 to enter an extension press 2 to use the directory */
03393                cmd = ast_play_and_wait(chan,"vm-forward");
03394                if (!cmd)
03395                   cmd = ast_waitfordigit(chan,3000);
03396                if (!cmd)
03397                   retries++;
03398                if (retries > 3)
03399                {
03400                   cmd = 't';
03401                   done = 1;
03402                }
03403                
03404              }
03405          }
03406          if( cmd<0 || cmd=='t' )
03407             break;
03408       }
03409       
03410       if (use_directory) {
03411          /* use app_directory */
03412          
03413          char old_context[sizeof(chan->context)];
03414          char old_exten[sizeof(chan->exten)];
03415          int old_priority;
03416          struct ast_app* app;
03417 
03418          
03419          app = pbx_findapp("Directory");
03420          if (app) {
03421             /* make mackup copies */
03422             memcpy(old_context, chan->context, sizeof(chan->context));
03423             memcpy(old_exten, chan->exten, sizeof(chan->exten));
03424             old_priority = chan->priority;
03425             
03426             /* call the the Directory, changes the channel */
03427             res = pbx_exec(chan, app, context ? context : "default", 1);
03428             
03429             ast_copy_string(username, chan->exten, sizeof(username));
03430             
03431             /* restore the old context, exten, and priority */
03432             memcpy(chan->context, old_context, sizeof(chan->context));
03433             memcpy(chan->exten, old_exten, sizeof(chan->exten));
03434             chan->priority = old_priority;
03435             
03436          } else {
03437             ast_log(LOG_WARNING, "Could not find the Directory application, disabling directory_forward\n");
03438             ast_clear_flag((&globalflags), VM_DIRECFORWARD);   
03439          }
03440       } else   {
03441          /* Ask for an extension */
03442          res = ast_streamfile(chan, "vm-extension", chan->language); /* "extension" */
03443          if (res)
03444             break;
03445          if ((res = ast_readstring(chan, username, sizeof(username) - 1, 2000, 10000, "#") < 0))
03446             break;
03447       }
03448       
03449       /* start all over if no username */
03450       if (ast_strlen_zero(username))
03451          continue;
03452       stringp = username;
03453       s = strsep(&stringp, "*");
03454       /* start optimistic */
03455       valid_extensions = 1;
03456       while (s) {
03457          /* find_user is going to malloc since we have a NULL as first argument */
03458          if ((receiver = find_user(NULL, context, s))) {
03459             if (!extensions)
03460                vmtmp = extensions = receiver;
03461             else {
03462                vmtmp->next = receiver;
03463                vmtmp = receiver;
03464             }
03465             found++;
03466          } else {
03467             valid_extensions = 0;
03468             break;
03469          }
03470          s = strsep(&stringp, "*");
03471       }
03472       /* break from the loop of reading the extensions */
03473       if (valid_extensions)
03474          break;
03475       /* "I am sorry, that's not a valid extension.  Please try again." */
03476       res = ast_play_and_wait(chan, "pbx-invalid");
03477    }
03478    /* check if we're clear to proceed */
03479    if (!extensions || !valid_extensions)
03480       return res;
03481    vmtmp = extensions;
03482    if (flag==1) {
03483       struct leave_vm_options leave_options;
03484 
03485       /* Send VoiceMail */
03486       memset(&leave_options, 0, sizeof(leave_options));
03487       leave_options.record_gain = record_gain;
03488       cmd = leave_voicemail(chan, username, &leave_options);
03489    } else {
03490       /* Forward VoiceMail */
03491       RETRIEVE(dir, curmsg);
03492       cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context, record_gain);
03493       if (!cmd) {
03494          while (!res && vmtmp) {
03495             /* if (ast_play_and_wait(chan, "vm-savedto"))
03496                break;
03497             */
03498             snprintf(todir, sizeof(todir), "%s%s/%s/INBOX",  VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox);
03499             snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir);
03500             snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->mailbox, vmtmp->context);
03501             ast_log(LOG_DEBUG, "%s", sys);
03502             ast_safe_system(sys);
03503       
03504             res = count_messages(receiver, todir);
03505 
03506             if ( (res == ERROR_LOCK_PATH) || (res < 0) ) {
03507                if (res == ERROR_LOCK_PATH)
03508                   ast_log(LOG_WARNING, "Unable to lock the directory %s to forward the requested vmail msg!\n", todir);
03509                else
03510                   ast_log(LOG_WARNING, "Unable to determine how many msgs are in the destination folder!\n");
03511                break;
03512             }
03513             todircount = res;
03514             ast_copy_string(tmp, fmt, sizeof(tmp));
03515             stringp = tmp;
03516             while ((s = strsep(&stringp, "|"))) {
03517                /* XXX This is a hack -- we should use build_filename or similar XXX */
03518                if (!strcasecmp(s, "wav49"))
03519                   s = "WAV";
03520                snprintf(sys, sizeof(sys), "cp %s/msg%04d.%s %s/msg%04d.%s\n", dir, curmsg, s, todir, todircount, s);
03521                ast_log(LOG_DEBUG, "%s", sys);
03522                ast_safe_system(sys);
03523             }
03524             snprintf(sys, sizeof(sys), "cp %s/msg%04d.txt %s/msg%04d.txt\n", dir, curmsg, todir, todircount);
03525             ast_log(LOG_DEBUG, "%s", sys);
03526             ast_safe_system(sys);
03527             snprintf(fn, sizeof(fn), "%s/msg%04d", todir,todircount);
03528 
03529             STORE(todir, vmtmp->mailbox, vmtmp->context, todircount);
03530    
03531             /* load the information on the source message so we can send an e-mail like a new message */
03532             snprintf(miffile, sizeof(miffile), "%s/msg%04d.txt", dir, curmsg);
03533             if ((mif=ast_config_load(miffile))) {
03534    
03535                /* set callerid and duration variables */
03536                snprintf(callerid, sizeof(callerid), "FWD from: %s from %s", sender->fullname, ast_variable_retrieve(mif, NULL, "callerid"));
03537                s = ast_variable_retrieve(mif, NULL, "duration");
03538                if (s)
03539                   duration = atoi(s);
03540                else
03541                   duration = 0;
03542                if (!ast_strlen_zero(vmtmp->email)) {
03543                   int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
03544                   char *myserveremail = serveremail;
03545                   attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH);
03546                   if (!ast_strlen_zero(vmtmp->serveremail))
03547                      myserveremail = vmtmp->serveremail;
03548                   sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, fn, tmp, duration, attach_user_voicemail);
03549                }
03550 
03551                if (!ast_strlen_zero(vmtmp->pager)) {
03552                   char *myserveremail = serveremail;
03553                   if (!ast_strlen_zero(vmtmp->serveremail))
03554                      myserveremail = vmtmp->serveremail;
03555                   sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, duration, vmtmp);
03556                }
03557               
03558                ast_config_destroy(mif); /* or here */
03559             }
03560             /* Leave voicemail for someone */
03561             manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL));
03562             run_externnotify(vmtmp->context, vmtmp->mailbox);
03563    
03564             saved_messages++;
03565             vmfree = vmtmp;
03566             vmtmp = vmtmp->next;
03567             free_user(vmfree);
03568          }
03569          if (saved_messages > 0) {
03570             /* give confirmation that the message was saved */
03571             /* commented out since we can't forward batches yet
03572             if (saved_messages == 1)
03573                res = ast_play_and_wait(chan, "vm-message");
03574             else
03575                res = ast_play_and_wait(chan, "vm-messages");
03576             if (!res)
03577                res = ast_play_and_wait(chan, "vm-saved"); */
03578             res = ast_play_and_wait(chan, "vm-msgsaved");
03579          }  
03580       }
03581    }
03582    return res ? res : cmd;
03583 }

void free_user struct ast_vm_user vmu  )  [static]
 

Definition at line 1970 of file app_voicemail.c.

References ast_test_flag, free, and VM_ALLOCED.

Referenced by forward_message(), leave_voicemail(), load_config(), and vm_execmain().

01971 {
01972    if (ast_test_flag(vmu, VM_ALLOCED))
01973       free(vmu);
01974 }

void free_zone struct vm_zone z  )  [static]
 

Definition at line 1976 of file app_voicemail.c.

References free.

Referenced by ast_register_indication_country(), ast_unregister_indication_country(), and load_config().

01977 {
01978    free(z);
01979 }

int get_date char *  s,
int  len
[static]
 

Definition at line 1921 of file app_voicemail.c.

References s.

01922 {
01923    struct tm tm;
01924    time_t t;
01925    t = time(0);
01926    localtime_r(&t,&tm);
01927    return strftime(s, len, "%a %b %e %r %Z %Y", &tm);
01928 }

int get_folder struct ast_channel chan,
int  start
[static]
 

Definition at line 3213 of file app_voicemail.c.

References AST_DIGIT_ANY, ast_play_and_wait(), ast_say_number(), ast_waitfordigit(), ast_channel::language, mbox(), and vm_play_folder_name().

Referenced by get_folder2().

03214 {
03215    int x;
03216    int d;
03217    char fn[256];
03218    d = ast_play_and_wait(chan, "vm-press");  /* "Press" */
03219    if (d)
03220       return d;
03221    for (x = start; x< 5; x++) {  /* For all folders */
03222       if ((d = ast_say_number(chan, x, AST_DIGIT_ANY, chan->language, (char *) NULL)))
03223          return d;
03224       d = ast_play_and_wait(chan, "vm-for"); /* "for" */
03225       if (d)
03226          return d;
03227       snprintf(fn, sizeof(fn), "vm-%s", mbox(x));  /* Folder name */
03228       d = vm_play_folder_name(chan, fn);
03229       if (d)
03230          return d;
03231       d = ast_waitfordigit(chan, 500);
03232       if (d)
03233          return d;
03234    }
03235    d = ast_play_and_wait(chan, "vm-tocancel"); /* "or pound to cancel" */
03236    if (d)
03237       return d;
03238    d = ast_waitfordigit(chan, 4000);
03239    return d;
03240 }

int get_folder2 struct ast_channel chan,
char *  fn,
int  start
[static]
 

Definition at line 3242 of file app_voicemail.c.

References ast_play_and_wait(), and get_folder().

Referenced by vm_execmain().

03243 {
03244    int res = 0;
03245    res = ast_play_and_wait(chan, fn);  /* Folder name */
03246    while (((res < '0') || (res > '9')) &&
03247          (res != '#') && (res >= 0)) {
03248       res = get_folder(chan, 0);
03249    }
03250    return res;
03251 }

int handle_show_voicemail_users int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 5713 of file app_voicemail.c.

References ast_cli(), ast_vm_user::context, ast_vm_user::fullname, ast_vm_user::mailbox, make_dir(), ast_vm_user::next, and ast_vm_user::zonetag.

05714 {
05715    struct ast_vm_user *vmu = users;
05716    char *output_format = "%-10s %-5s %-25s %-10s %6s\n";
05717 
05718    if ((argc < 3) || (argc > 5) || (argc == 4)) return RESULT_SHOWUSAGE;
05719    else if ((argc == 5) && strcmp(argv[3],"for")) return RESULT_SHOWUSAGE;
05720 
05721    if (vmu) {
05722       if (argc == 3)
05723          ast_cli(fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
05724       else {
05725          int count = 0;
05726          while (vmu) {
05727             if (!strcmp(argv[4],vmu->context))
05728                count++;
05729             vmu = vmu->next;
05730          }
05731          if (count) {
05732             vmu = users;
05733             ast_cli(fd, output_format, "Context", "Mbox", "User", "Zone", "NewMsg");
05734          } else {
05735             ast_cli(fd, "No such voicemail context \"%s\"\n", argv[4]);
05736             return RESULT_FAILURE;
05737          }
05738       }
05739       while (vmu) {
05740          char dirname[256];
05741          DIR *vmdir;
05742          struct dirent *vment;
05743          int vmcount = 0;
05744          char count[12];
05745 
05746          if ((argc == 3) || ((argc == 5) && !strcmp(argv[4],vmu->context))) {
05747             make_dir(dirname, 255, vmu->context, vmu->mailbox, "INBOX");
05748             if ((vmdir = opendir(dirname))) {
05749                /* No matter what the format of VM, there will always be a .txt file for each message. */
05750                while ((vment = readdir(vmdir)))
05751                   if (strlen(vment->d_name) > 7 && !strncmp(vment->d_name + 7,".txt",4))
05752                      vmcount++;
05753                closedir(vmdir);
05754             }
05755             snprintf(count,sizeof(count),"%d",vmcount);
05756             ast_cli(fd, output_format, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count);
05757          }
05758          vmu = vmu->next;
05759       }
05760    } else {
05761       ast_cli(fd, "There are no voicemail users currently defined\n");
05762       return RESULT_FAILURE;
05763    }
05764    return RESULT_SUCCESS;
05765 }

int handle_show_voicemail_zones int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 5767 of file app_voicemail.c.

References ast_cli(), vm_zone::msg_format, vm_zone::name, vm_zone::next, and vm_zone::timezone.

05768 {
05769    struct vm_zone *zone = zones;
05770    char *output_format = "%-15s %-20s %-45s\n";
05771 
05772    if (argc != 3) return RESULT_SHOWUSAGE;
05773 
05774    if (zone) {
05775       ast_cli(fd, output_format, "Zone", "Timezone", "Message Format");
05776       while (zone) {
05777          ast_cli(fd, output_format, zone->name, zone->timezone, zone->msg_format);
05778          zone = zone->next;
05779       }
05780    } else {
05781       ast_cli(fd, "There are no voicemail zones currently defined\n");
05782       return RESULT_FAILURE;
05783    }
05784    return RESULT_SUCCESS;
05785 }

int has_voicemail const char *  mailbox,
const char *  folder
[static]
 

Definition at line 2184 of file app_voicemail.c.

References ast_strlen_zero(), strsep(), and VM_SPOOL_DIR.

Referenced by do_housekeeping(), do_monitor(), forward_message(), handle_hd_hf(), handle_init_event(), handle_request(), load_module(), mgcp_hangup(), mgcp_request(), vm_execmain(), and zt_handle_event().

02185 {
02186    DIR *dir;
02187    struct dirent *de;
02188    char fn[256];
02189    char tmp[256]="";
02190    char *mb, *cur;
02191    char *context;
02192    int ret;
02193    if (!folder)
02194       folder = "INBOX";
02195    /* If no mailbox, return immediately */
02196    if (ast_strlen_zero(mailbox))
02197       return 0;
02198    if (strchr(mailbox, ',')) {
02199       ast_copy_string(tmp, mailbox, sizeof(tmp));
02200       mb = tmp;
02201       ret = 0;
02202       while((cur = strsep(&mb, ","))) {
02203          if (!ast_strlen_zero(cur)) {
02204             if (has_voicemail(cur, folder))
02205                return 1; 
02206          }
02207       }
02208       return 0;
02209    }
02210    ast_copy_string(tmp, mailbox, sizeof(tmp));
02211    context = strchr(tmp, '@');
02212    if (context) {
02213       *context = '\0';
02214       context++;
02215    } else
02216       context = "default";
02217    snprintf(fn, sizeof(fn), "%s/%s/%s/%s", VM_SPOOL_DIR, context, tmp, folder);
02218    dir = opendir(fn);
02219    if (!dir)
02220       return 0;
02221    while ((de = readdir(dir))) {
02222       if (!strncasecmp(de->d_name, "msg", 3))
02223          break;
02224    }
02225    closedir(dir);
02226    if (de)
02227       return 1;
02228    return 0;
02229 }

int inbuf struct baseio bio,
FILE *  fi
[static]
 

Definition at line 1505 of file app_voicemail.c.

References baseio::ateof, BASEMAXINLINE, baseio::iobuf, baseio::iocp, and baseio::iolen.

Referenced by inchar(), and vm_change_password().

01506 {
01507    int l;
01508 
01509    if (bio->ateof)
01510       return 0;
01511 
01512    if ((l = fread(bio->iobuf,1,BASEMAXINLINE,fi)) <= 0) {
01513       if (ferror(fi))
01514          return -1;
01515 
01516       bio->ateof = 1;
01517       return 0;
01518    }
01519 
01520    bio->iolen= l;
01521    bio->iocp= 0;
01522 
01523    return 1;
01524 }

int inchar struct baseio bio,
FILE *  fi
[static]
 

Definition at line 1527 of file app_voicemail.c.

References inbuf(), baseio::iobuf, baseio::iocp, and baseio::iolen.

Referenced by base_encode().

01528 {
01529    if (bio->iocp>=bio->iolen) {
01530       if (!inbuf(bio, fi))
01531          return EOF;
01532    }
01533 
01534    return bio->iobuf[bio->iocp++];
01535 }

int invent_message struct ast_channel chan,
char *  context,
char *  ext,
int  busy,
char *  ecodes
[static]
 

Definition at line 1930 of file app_voicemail.c.

References ast_fileexists(), ast_say_digit_str(), ast_streamfile(), ast_waitstream(), DISPOSE, ast_channel::language, RETRIEVE, and VM_SPOOL_DIR.

Referenced by leave_voicemail().

01931 {
01932    int res;
01933    char fn[256];
01934    snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext);
01935    RETRIEVE(fn, -1);
01936    if (ast_fileexists(fn, NULL, NULL) > 0) {
01937       res = ast_streamfile(chan, fn, chan->language);
01938       if (res) {
01939          DISPOSE(fn, -1);
01940          return -1;
01941       }
01942       res = ast_waitstream(chan, ecodes);
01943       if (res) {
01944          DISPOSE(fn, -1);
01945          return res;
01946       }
01947    } else {
01948       /* Dispose just in case */
01949       DISPOSE(fn, -1);
01950       res = ast_streamfile(chan, "vm-theperson", chan->language);
01951       if (res)
01952          return -1;
01953       res = ast_waitstream(chan, ecodes);
01954       if (res)
01955          return res;
01956       res = ast_say_digit_str(chan, ext, ecodes, chan->language);
01957       if (res)
01958          return res;
01959    }
01960    if (busy)
01961       res = ast_streamfile(chan, "vm-isonphone", chan->language);
01962    else
01963       res = ast_streamfile(chan, "vm-isunavail", chan->language);
01964    if (res)
01965       return -1;
01966    res = ast_waitstream(chan, ecodes);
01967    return res;
01968 }

char* key void   ) 
 

Returns the ASTERISK_GPL_KEY.

This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:

 char *key(void) {
         return ASTERISK_GPL_KEY;
 }

Returns:
ASTERISK_GPL_KEY

Definition at line 6728 of file app_voicemail.c.

06729 {
06730    return ASTERISK_GPL_KEY;
06731 }

int last_message_index struct ast_vm_user vmu,
char *  dir
[static]
 

Definition at line 1469 of file app_voicemail.c.

References ast_fileexists(), ast_unlock_path(), make_file(), ast_vm_user::maxmsg, and vm_lock_path().

Referenced by open_mailbox().

01470 {
01471    int x;
01472    char fn[256];
01473 
01474    if (vm_lock_path(dir))
01475       return ERROR_LOCK_PATH;
01476 
01477    for (x = 0; x < vmu->maxmsg; x++) {
01478       make_file(fn, sizeof(fn), dir, x);
01479       if (ast_fileexists(fn, NULL, NULL) < 1)
01480          break;
01481    }
01482    ast_unlock_path(dir);
01483 
01484    return x - 1;
01485 }

int leave_voicemail struct ast_channel chan,
char *  ext,
struct leave_vm_options options
[static]
 

Definition at line 2368 of file app_voicemail.c.

References ast_callerid_merge(), ast_exists_extension(), ast_fileexists(), ast_goto_if_exists(), ast_log(), ast_play_and_wait(), ast_set_flag, ast_stopstream(), ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_unlock_path(), ast_verbose(), ast_waitstream(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_vm_user::context, ast_channel::context, copy_message(), create_dirpath(), DELETE, DISPOSE, EXISTS, ast_vm_user::exit, ast_channel::exten, find_user(), fmt, free_user(), get_date(), INTRO, invent_message(), ast_channel::language, LOG_DEBUG, LOG_WARNING, ast_channel::macrocontext, ast_vm_user::mailbox, make_file(), ast_vm_user::maxmsg, ast_channel::name, notify_new_message(), OPT_BUSY_GREETING, OPT_PRIORITY_JUMP, OPT_SILENT, OPT_UNAVAIL_GREETING, option_verbose, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), play_record_review(), ast_channel::priority, leave_vm_options::record_gain, RETRIEVE, STORE, strsep(), VERBOSE_PREFIX_3, vm_lock_path(), VM_OPERATOR, VM_SPOOL_DIR, vmfmts, vmmaxmessage, and vmminmessage.

Referenced by advanced_options(), forward_message(), and vm_exec().

02369 {
02370    char txtfile[256];
02371    char callerid[256];
02372    FILE *txt;
02373    int res = 0;
02374    int msgnum;
02375    int duration = 0;
02376    int ausemacro = 0;
02377    int ousemacro = 0;
02378    char date[256];
02379    char dir[256];
02380    char fn[256];
02381    char prefile[256]="";
02382    char tempfile[256]="";
02383    char ext_context[256] = "";
02384    char fmt[80];
02385    char *context;
02386    char ecodes[16] = "#";
02387    char tmp[256] = "", *tmpptr;
02388    struct ast_vm_user *vmu;
02389    struct ast_vm_user svm;
02390    char *category = NULL;
02391 
02392    ast_copy_string(tmp, ext, sizeof(tmp));
02393    ext = tmp;
02394    context = strchr(tmp, '@');
02395    if (context) {
02396       *context = '\0';
02397       context++;
02398       tmpptr = strchr(context, '&');
02399    } else {
02400       tmpptr = strchr(ext, '&');
02401    }
02402 
02403    if (tmpptr) {
02404       *tmpptr = '\0';
02405       tmpptr++;
02406    }
02407 
02408    category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY");
02409 
02410    if (!(vmu = find_user(&svm, context, ext))) {
02411       ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext);
02412       if (ast_test_flag(options, OPT_PRIORITY_JUMP) || option_priority_jumping)
02413          ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
02414       pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
02415       return res;
02416    }
02417 
02418    /* Setup pre-file if appropriate */
02419    if (strcmp(vmu->context, "default"))
02420       snprintf(ext_context, sizeof(ext_context), "%s@%s", ext, vmu->context);
02421    else
02422       ast_copy_string(ext_context, vmu->context, sizeof(ext_context));
02423    if (ast_test_flag(options, OPT_BUSY_GREETING))
02424       snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, ext);
02425    else if (ast_test_flag(options, OPT_UNAVAIL_GREETING))
02426       snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, ext);
02427    snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, ext);
02428    RETRIEVE(tempfile, -1);
02429    if (ast_fileexists(tempfile, NULL, NULL) > 0)
02430       ast_copy_string(prefile, tempfile, sizeof(prefile));
02431    DISPOSE(tempfile, -1);
02432    /* It's easier just to try to make it than to check for its existence */
02433    create_dirpath(dir, sizeof(dir), vmu->context, ext, "INBOX");
02434 
02435    /* Check current or macro-calling context for special extensions */
02436    if (!ast_strlen_zero(vmu->exit)) {
02437       if (ast_exists_extension(chan, vmu->exit, "o", 1, chan->cid.cid_num))
02438          strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
02439    } else if (ast_exists_extension(chan, chan->context, "o", 1, chan->cid.cid_num))
02440       strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
02441    else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "o", 1, chan->cid.cid_num)) {
02442       strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
02443       ousemacro = 1;
02444    }
02445 
02446    if (!ast_strlen_zero(vmu->exit)) {
02447       if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->cid.cid_num))
02448          strncat(ecodes, "*", sizeof(ecodes) -  strlen(ecodes) - 1);
02449    } else if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num))
02450       strncat(ecodes, "*", sizeof(ecodes) -  strlen(ecodes) - 1);
02451    else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) {
02452       strncat(ecodes, "*", sizeof(ecodes) -  strlen(ecodes) - 1);
02453       ausemacro = 1;
02454    }
02455 
02456    /* Play the beginning intro if desired */
02457    if (!ast_strlen_zero(prefile)) {
02458       RETRIEVE(prefile, -1);
02459       if (ast_fileexists(prefile, NULL, NULL) > 0) {
02460          if (ast_streamfile(chan, prefile, chan->language) > -1) 
02461             res = ast_waitstream(chan, ecodes);
02462       } else {
02463          ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
02464          res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
02465       }
02466       DISPOSE(prefile, -1);
02467       if (res < 0) {
02468          ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
02469          free_user(vmu);
02470          pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
02471          return -1;
02472       }
02473    }
02474    if (res == '#') {
02475       /* On a '#' we skip the instructions */
02476       ast_set_flag(options, OPT_SILENT);
02477       res = 0;
02478    }
02479    if (!res && !ast_test_flag(options, OPT_SILENT)) {
02480       res = ast_streamfile(chan, INTRO, chan->language);
02481       if (!res)
02482          res = ast_waitstream(chan, ecodes);
02483       if (res == '#') {
02484          ast_set_flag(options, OPT_SILENT);
02485          res = 0;
02486       }
02487    }
02488    if (res > 0)
02489       ast_stopstream(chan);
02490    /* Check for a '*' here in case the caller wants to escape from voicemail to something
02491       other than the operator -- an automated attendant or mailbox login for example */
02492    if (res == '*') {
02493       chan->exten[0] = 'a';
02494       chan->exten[1] = '\0';
02495       if (!ast_strlen_zero(vmu->exit)) {
02496          ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
02497       } else if (ausemacro && !ast_strlen_zero(chan->macrocontext)) {
02498          ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
02499       }
02500       chan->priority = 0;
02501       free_user(vmu);
02502       pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
02503       return 0;
02504    }
02505    /* Check for a '0' here */
02506    if (res == '0') {
02507    transfer:
02508       if (ast_test_flag(vmu, VM_OPERATOR)) {
02509          chan->exten[0] = 'o';
02510          chan->exten[1] = '\0';
02511          if (!ast_strlen_zero(vmu->exit)) {
02512             ast_copy_string(chan->context, vmu->exit, sizeof(chan->context));
02513          } else if (ousemacro && !ast_strlen_zero(chan->macrocontext)) {
02514             ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context));
02515          }
02516          ast_play_and_wait(chan, "transfer");
02517          chan->priority = 0;
02518          free_user(vmu);
02519          pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
02520          return 0;
02521       } else {
02522          ast_play_and_wait(chan, "vm-sorry");
02523          pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
02524          return 0;
02525       }
02526    }
02527    if (res < 0) {
02528       free_user(vmu);
02529       pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
02530       return -1;
02531    }
02532    /* The meat of recording the message...  All the announcements and beeps have been played*/
02533    ast_copy_string(fmt, vmfmts, sizeof(fmt));
02534    if (!ast_strlen_zero(fmt)) {
02535       msgnum = 0;
02536 
02537       if (vm_lock_path(dir)) {
02538          free_user(vmu);
02539          return ERROR_LOCK_PATH;
02540       }
02541 
02542       /* 
02543        * This operation can be very expensive if done say over NFS or if the mailbox has 100+ messages
02544        * in the mailbox.  So we should get this first so we don't cut off the first few seconds of the 
02545        * message.  
02546        */
02547       do {
02548          make_file(fn, sizeof(fn), dir, msgnum);
02549          if (!EXISTS(dir,msgnum,fn,chan->language))
02550             break;
02551          msgnum++;
02552       } while (msgnum < vmu->maxmsg);
02553 
02554       /* Now play the beep once we have the message number for our next message. */
02555       if (res >= 0) {
02556          /* Unless we're *really* silent, try to send the beep */
02557          res = ast_streamfile(chan, "beep", chan->language);
02558          if (!res)
02559             res = ast_waitstream(chan, "");
02560       }
02561       if (msgnum < vmu->maxmsg) {
02562          /* assign a variable with the name of the voicemail file */   
02563          pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", fn);
02564             
02565          /* Store information */
02566          snprintf(txtfile, sizeof(txtfile), "%s.txt", fn);
02567          txt = fopen(txtfile, "w+");
02568          if (txt) {
02569             get_date(date, sizeof(date));
02570             fprintf(txt, 
02571                ";\n"
02572                "; Message Information file\n"
02573                ";\n"
02574                "[message]\n"
02575                "origmailbox=%s\n"
02576                "context=%s\n"
02577                "macrocontext=%s\n"
02578                "exten=%s\n"
02579                "priority=%d\n"
02580                "callerchan=%s\n"
02581                "callerid=%s\n"
02582                "origdate=%s\n"
02583                "origtime=%ld\n"
02584                "category=%s\n",
02585                ext,
02586                chan->context,
02587                chan->macrocontext, 
02588                chan->exten,
02589                chan->priority,
02590                chan->name,
02591                ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"),
02592                date, (long)time(NULL),
02593                category ? category : ""); 
02594          } else
02595             ast_log(LOG_WARNING, "Error opening text file for output\n");
02596          res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration, dir, options->record_gain);
02597          if (res == '0') {
02598             if (txt)
02599                fclose(txt);
02600             goto transfer;
02601          }
02602          if (res > 0)
02603             res = 0;
02604          if (txt) {
02605             fprintf(txt, "duration=%d\n", duration);
02606             fclose(txt);
02607          }
02608             
02609          if (duration < vmminmessage) {
02610             if (option_verbose > 2) 
02611                ast_verbose( VERBOSE_PREFIX_3 "Recording was %d seconds long but needs to be at least %d - abandoning\n", duration, vmminmessage);
02612             DELETE(dir,msgnum,fn);
02613             /* XXX We should really give a prompt too short/option start again, with leave_vm_out called only after a timeout XXX */
02614             pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
02615             goto leave_vm_out;
02616          }
02617          /* Are there to be more recipients of this message? */
02618          while (tmpptr) {
02619             struct ast_vm_user recipu, *recip;
02620             char *exten, *context;
02621                
02622             exten = strsep(&tmpptr, "&");
02623             context = strchr(exten, '@');
02624             if (context) {
02625                *context = '\0';
02626                context++;
02627             }
02628             if ((recip = find_user(&recipu, context, exten))) {
02629                copy_message(chan, vmu, 0, msgnum, duration, recip, fmt);
02630                free_user(recip);
02631             }
02632          }
02633          if (ast_fileexists(fn, NULL, NULL)) {
02634             STORE(dir, vmu->mailbox, vmu->context, msgnum);
02635             notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
02636             DISPOSE(dir, msgnum);
02637          }
02638          pbx_builtin_setvar_helper(chan, "VMSTATUS", "SUCCESS");
02639       } else {
02640          ast_unlock_path(dir);
02641          res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
02642          if (!res)
02643             res = ast_waitstream(chan, "");
02644          ast_log(LOG_WARNING, "No more messages possible\n");
02645          pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
02646       }
02647    } else
02648       ast_log(LOG_WARNING, "No format for saving voicemail?\n");
02649  leave_vm_out:
02650    free_user(vmu);
02651    
02652    return res;
02653 }

int load_config void   )  [static]
 

Definition at line 5826 of file app_voicemail.c.

References adsifdn, adsisec, adsiver, append_mailbox(), ast_category_browse(), ast_config_destroy(), ast_config_load(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_set2_flag, ast_set_flag, ast_strdupa, ast_strlen_zero(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), callcontext, cfg, charset, cidinternalcontexts, dialcontext, emailbody, emaildateformat, emailsubject, emailtitle, exitcontext, ext_pass_cmd, externnotify, fmt, free, free_user(), free_zone(), fromstring, globalflags, ast_variable::lineno, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, mailcmd, malloc, maxgreet, maxlogins, MAXMSG, maxmsg, MAXMSGLIMIT, maxsilence, vm_zone::msg_format, vm_zone::name, ast_variable::name, ast_variable::next, vm_zone::next, ast_vm_user::next, pagerbody, pagerfromstring, pagersubject, s, saydurationminfo, SENDMAIL, serveremail, silencethreshold, skipms, strdup, strsep(), vm_zone::timezone, users, usersl, ast_variable::value, var, VM_ALLOCED, VM_ATTACH, VM_DIRECFORWARD, VM_ENVELOPE, VM_FORCEGREET, VM_FORCENAME, VM_OPERATOR, VM_PBXSKIP, VM_REVIEW, VM_SAYCID, VM_SAYDURATION, VM_SEARCH, VM_SKIPAFTERCMD, VM_SVMAIL, vmfmts, vmmaxmessage, vmminmessage, VOICEMAIL_CONFIG, zones, and zonesl.

05827 {
05828    struct ast_vm_user *cur, *l;
05829    struct vm_zone *zcur, *zl;
05830    struct ast_config *cfg;
05831    char *cat;
05832    struct ast_variable *var;
05833    char *notifystr = NULL;
05834    char *astattach;
05835    char *astsearch;
05836    char *astsaycid;
05837    char *send_voicemail;
05838    char *astcallop;
05839    char *astreview;
05840    char *astskipcmd;
05841    char *asthearenv;
05842    char *astsaydurationinfo;
05843    char *astsaydurationminfo;
05844    char *silencestr;
05845    char *maxmsgstr;
05846    char *astdirfwd;
05847    char *thresholdstr;
05848    char *fmt;
05849    char *astemail;
05850    char *astmailcmd = SENDMAIL;
05851    char *s,*q,*stringp;
05852    char *dialoutcxt = NULL;
05853    char *callbackcxt = NULL;  
05854    char *exitcxt = NULL;   
05855    char *extpc;
05856    char *emaildateformatstr;
05857    int x;
05858    int tmpadsi[4];
05859 
05860    cfg = ast_config_load(VOICEMAIL_CONFIG);
05861    ast_mutex_lock(&vmlock);
05862    cur = users;
05863    while (cur) {
05864       l = cur;
05865       cur = cur->next;
05866       ast_set_flag(l, VM_ALLOCED);  
05867       free_user(l);
05868    }
05869    zcur = zones;
05870    while (zcur) {
05871       zl = zcur;
05872       zcur = zcur->next;
05873       free_zone(zl);
05874    }
05875    zones = NULL;
05876    zonesl = NULL;
05877    users = NULL;
05878    usersl = NULL;
05879    memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
05880 
05881    if (cfg) {
05882       /* General settings */
05883 
05884       /* Attach voice message to mail message ? */
05885       if (!(astattach = ast_variable_retrieve(cfg, "general", "attach"))) 
05886          astattach = "yes";
05887       ast_set2_flag((&globalflags), ast_true(astattach), VM_ATTACH); 
05888 
05889       if (!(astsearch = ast_variable_retrieve(cfg, "general", "searchcontexts")))
05890          astsearch = "no";
05891       ast_set2_flag((&globalflags), ast_true(astsearch), VM_SEARCH);
05892 
05893 #ifdef USE_ODBC_STORAGE
05894       strcpy(odbc_database, "asterisk");
05895       if ((thresholdstr = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
05896          ast_copy_string(odbc_database, thresholdstr, sizeof(odbc_database));
05897       }
05898       strcpy(odbc_table, "voicemessages");
05899                 if ((thresholdstr = ast_variable_retrieve(cfg, "general", "odbctable"))) {
05900                         ast_copy_string(odbc_table, thresholdstr, sizeof(odbc_table));
05901                 }
05902 #endif      
05903       /* Mail command */
05904       strcpy(mailcmd, SENDMAIL);
05905       if ((astmailcmd = ast_variable_retrieve(cfg, "general", "mailcmd")))
05906          ast_copy_string(mailcmd, astmailcmd, sizeof(mailcmd)); /* User setting */
05907 
05908       maxsilence = 0;
05909       if ((silencestr = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
05910          maxsilence = atoi(silencestr);
05911          if (maxsilence > 0)
05912             maxsilence *= 1000;
05913       }
05914       
05915       if (!(maxmsgstr = ast_variable_retrieve(cfg, "general", "maxmsg"))) {
05916          maxmsg = MAXMSG;
05917       } else {
05918          maxmsg = atoi(maxmsgstr);
05919          if (maxmsg <= 0) {
05920             ast_log(LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", maxmsgstr, MAXMSG);
05921             maxmsg = MAXMSG;
05922          } else if (maxmsg > MAXMSGLIMIT) {
05923             ast_log(LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, maxmsgstr);
05924             maxmsg = MAXMSGLIMIT;
05925          }
05926       }
05927 
05928       /* Load date format config for voicemail mail */
05929       if ((emaildateformatstr = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
05930          ast_copy_string(emaildateformat, emaildateformatstr, sizeof(emaildateformat));
05931       }
05932 
05933       /* External password changing command */
05934       if ((extpc = ast_variable_retrieve(cfg, "general", "externpass"))) {
05935          ast_copy_string(ext_pass_cmd,extpc,sizeof(ext_pass_cmd));
05936       }
05937 
05938       /* External voicemail notify application */
05939       
05940       if ((notifystr = ast_variable_retrieve(cfg, "general", "externnotify"))) {
05941          ast_copy_string(externnotify, notifystr, sizeof(externnotify));
05942          ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
05943       } else {
05944          externnotify[0] = '\0';
05945       }
05946 
05947       /* Silence treshold */
05948       silencethreshold = 256;
05949       if ((thresholdstr = ast_variable_retrieve(cfg, "general", "silencethreshold")))
05950          silencethreshold = atoi(thresholdstr);
05951       
05952       if (!(astemail = ast_variable_retrieve(cfg, "general", "serveremail"))) 
05953          astemail = ASTERISK_USERNAME;
05954       ast_copy_string(serveremail, astemail, sizeof(serveremail));
05955       
05956       vmmaxmessage = 0;
05957       if ((s = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
05958          if (sscanf(s, "%d", &x) == 1) {
05959             vmmaxmessage = x;
05960          } else {
05961             ast_log(LOG_WARNING, "Invalid max message time length\n");
05962          }
05963       }
05964 
05965       vmminmessage = 0;
05966       if ((s = ast_variable_retrieve(cfg, "general", "minmessage"))) {
05967          if (sscanf(s, "%d", &x) == 1) {
05968             vmminmessage = x;
05969             if (maxsilence <= vmminmessage)
05970                ast_log(LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
05971          } else {
05972             ast_log(LOG_WARNING, "Invalid min message time length\n");
05973          }
05974       }
05975       fmt = ast_variable_retrieve(cfg, "general", "format");
05976       if (!fmt)
05977          fmt = "wav";   
05978       ast_copy_string(vmfmts, fmt, sizeof(vmfmts));
05979 
05980       skipms = 3000;
05981       if ((s = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
05982          if (sscanf(s, "%d", &x) == 1) {
05983             maxgreet = x;
05984          } else {
05985             ast_log(LOG_WARNING, "Invalid max message greeting length\n");
05986          }
05987       }
05988 
05989       if ((s = ast_variable_retrieve(cfg, "general", "skipms"))) {
05990          if (sscanf(s, "%d", &x) == 1) {
05991             skipms = x;
05992          } else {
05993             ast_log(LOG_WARNING, "Invalid skipms value\n");
05994          }
05995       }
05996 
05997       maxlogins = 3;
05998       if ((s = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
05999          if (sscanf(s, "%d", &x) == 1) {
06000             maxlogins = x;
06001          } else {
06002             ast_log(LOG_WARNING, "Invalid max failed login attempts\n");
06003          }
06004       }
06005 
06006       /* Force new user to record name ? */
06007       if (!(astattach = ast_variable_retrieve(cfg, "general", "forcename"))) 
06008          astattach = "no";
06009       ast_set2_flag((&globalflags), ast_true(astattach), VM_FORCENAME);
06010 
06011       /* Force new user to record greetings ? */
06012       if (!(astattach = ast_variable_retrieve(cfg, "general", "forcegreetings"))) 
06013          astattach = "no";
06014       ast_set2_flag((&globalflags), ast_true(astattach), VM_FORCEGREET);
06015 
06016       if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){
06017          ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
06018          stringp = ast_strdupa(s);
06019          for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
06020             if (!ast_strlen_zero(stringp)) {
06021                q = strsep(&stringp,",");
06022                while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
06023                   q++;
06024                ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x]));
06025                ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
06026             } else {
06027                cidinternalcontexts[x][0] = '\0';
06028             }
06029          }
06030       }
06031       if (!(astreview = ast_variable_retrieve(cfg, "general", "review"))){
06032          ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
06033          astreview = "no";
06034       }
06035       ast_set2_flag((&globalflags), ast_true(astreview), VM_REVIEW); 
06036 
06037       if (!(astcallop = ast_variable_retrieve(cfg, "general", "operator"))){
06038          ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
06039          astcallop = "no";
06040       }
06041       ast_set2_flag((&globalflags), ast_true(astcallop), VM_OPERATOR);  
06042 
06043       if (!(astsaycid = ast_variable_retrieve(cfg, "general", "saycid"))) {
06044          ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
06045          astsaycid = "no";
06046       } 
06047       ast_set2_flag((&globalflags), ast_true(astsaycid), VM_SAYCID); 
06048 
06049       if (!(send_voicemail = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){
06050          ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
06051          send_voicemail = "no";
06052       }
06053       ast_set2_flag((&globalflags), ast_true(send_voicemail), VM_SVMAIL);
06054    
06055       if (!(asthearenv = ast_variable_retrieve(cfg, "general", "envelope"))) {
06056          ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
06057          asthearenv = "yes";
06058       }
06059       ast_set2_flag((&globalflags), ast_true(asthearenv), VM_ENVELOPE); 
06060 
06061       if (!(astsaydurationinfo = ast_variable_retrieve(cfg, "general", "sayduration"))) {
06062          ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
06063          astsaydurationinfo = "yes";
06064       }
06065       ast_set2_flag((&globalflags), ast_true(astsaydurationinfo), VM_SAYDURATION);  
06066 
06067       saydurationminfo = 2;
06068       if ((astsaydurationminfo = ast_variable_retrieve(cfg, "general", "saydurationm"))) {
06069          if (sscanf(astsaydurationminfo, "%d", &x) == 1) {
06070             saydurationminfo = x;
06071          } else {
06072             ast_log(LOG_WARNING, "Invalid min duration for say duration\n");
06073          }
06074       }
06075 
06076       if (!(astskipcmd = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
06077          ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
06078          astskipcmd = "no";
06079       }
06080       ast_set2_flag((&globalflags), ast_true(astskipcmd), VM_SKIPAFTERCMD);
06081 
06082       if ((dialoutcxt = ast_variable_retrieve(cfg, "general", "dialout"))) {
06083          ast_copy_string(dialcontext, dialoutcxt, sizeof(dialcontext));
06084          ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
06085       } else {
06086          dialcontext[0] = '\0';  
06087       }
06088       
06089       if ((callbackcxt = ast_variable_retrieve(cfg, "general", "callback"))) {
06090          ast_copy_string(callcontext, callbackcxt, sizeof(callcontext));
06091          ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
06092       } else {
06093          callcontext[0] = '\0';
06094       }
06095 
06096       if ((exitcxt = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
06097          ast_copy_string(exitcontext, exitcxt, sizeof(exitcontext));
06098          ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
06099       } else {
06100          exitcontext[0] = '\0';
06101       }
06102 
06103       if (!(astdirfwd = ast_variable_retrieve(cfg, "general", "usedirectory"))) 
06104          astdirfwd = "no";
06105       ast_set2_flag((&globalflags), ast_true(astdirfwd), VM_DIRECFORWARD); 
06106       cat = ast_category_browse(cfg, NULL);
06107       while (cat) {
06108          if (strcasecmp(cat, "general")) {
06109             var = ast_variable_browse(cfg, cat);
06110             if (strcasecmp(cat, "zonemessages")) {
06111                /* Process mailboxes in this context */
06112                while (var) {
06113                   append_mailbox(cat, var->name, var->value);
06114                   var = var->next;
06115                }
06116             } else {
06117                /* Timezones in this context */
06118                while (var) {
06119                   struct vm_zone *z;
06120                   z = malloc(sizeof(struct vm_zone));
06121                   if (z != NULL) {
06122                      char *msg_format, *timezone;
06123                      msg_format = ast_strdupa(var->value);
06124                      if (msg_format != NULL) {
06125                         timezone = strsep(&msg_format, "|");
06126                         if (msg_format) {
06127                            ast_copy_string(z->name, var->name, sizeof(z->name));
06128                            ast_copy_string(z->timezone, timezone, sizeof(z->timezone));
06129                            ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
06130                            z->next = NULL;
06131                            if (zones) {
06132                               zonesl->next = z;
06133                               zonesl = z;
06134                            } else {
06135                               zones = z;
06136                               zonesl = z;
06137                            }
06138                         } else {
06139                            ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
06140                            free(z);
06141                         }
06142                      } else {
06143                         ast_log(LOG_WARNING, "Out of memory while reading voicemail config\n");
06144                         free(z);
06145                         return -1;
06146                      }
06147                   } else {
06148                      ast_log(LOG_WARNING, "Out of memory while reading voicemail config\n");
06149                      return -1;
06150                   }
06151                   var = var->next;
06152                }
06153             }
06154          }
06155          cat = ast_category_browse(cfg, cat);
06156       }
06157       memset(fromstring,0,sizeof(fromstring));
06158       memset(pagerfromstring,0,sizeof(pagerfromstring));
06159       memset(emailtitle,0,sizeof(emailtitle));
06160       strcpy(charset, "ISO-8859-1");
06161       if (emailbody) {
06162          free(emailbody);
06163          emailbody = NULL;
06164       }
06165       if (emailsubject) {
06166          free(emailsubject);
06167          emailsubject = NULL;
06168       }
06169                if (pagerbody) {
06170                        free(pagerbody);
06171                        pagerbody = NULL;
06172                }
06173                if (pagersubject) {
06174                        free(pagersubject);
06175                        pagersubject = NULL;
06176                }
06177       if ((s=ast_variable_retrieve(cfg, "general", "pbxskip")))
06178          ast_set2_flag((&globalflags), ast_true(s), VM_PBXSKIP);
06179       if ((s=ast_variable_retrieve(cfg, "general", "fromstring")))
06180          ast_copy_string(fromstring,s,sizeof(fromstring));
06181       if ((s=ast_variable_retrieve(cfg, "general", "pagerfromstring")))
06182          ast_copy_string(pagerfromstring,s,sizeof(pagerfromstring));
06183       if ((s=ast_variable_retrieve(cfg, "general", "charset")))
06184          ast_copy_string(charset,s,sizeof(charset));
06185       if ((s=ast_variable_retrieve(cfg, "general", "adsifdn"))) {
06186          sscanf(s, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
06187          for (x=0; x<4; x++) {
06188             memcpy(&adsifdn[x], &tmpadsi[x], 1);
06189          }
06190       }
06191       if ((s=ast_variable_retrieve(cfg, "general", "adsisec"))) {
06192          sscanf(s, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
06193          for (x=0; x<4; x++) {
06194             memcpy(&adsisec[x], &tmpadsi[x], 1);
06195          }
06196       }
06197       if ((s=ast_variable_retrieve(cfg, "general", "adsiver")))
06198          if (atoi(s)) {
06199             adsiver = atoi(s);
06200          }
06201       if ((s=ast_variable_retrieve(cfg, "general", "emailtitle"))) {
06202          ast_log(LOG_NOTICE, "Keyword 'emailtitle' is DEPRECATED, please use 'emailsubject' instead.\n");
06203          ast_copy_string(emailtitle,s,sizeof(emailtitle));
06204       }
06205       if ((s=ast_variable_retrieve(cfg, "general", "emailsubject")))
06206          emailsubject = strdup(s);
06207       if ((s=ast_variable_retrieve(cfg, "general", "emailbody"))) {
06208          char *tmpread, *tmpwrite;
06209          emailbody = strdup(s);
06210 
06211          /* substitute strings \t and \n into the apropriate characters */
06212          tmpread = tmpwrite = emailbody;
06213                        while ((tmpwrite = strchr(tmpread,'\\'))) {
06214                                int len = strlen("\n");
06215                                switch (tmpwrite[1]) {
06216                                        case 'n':
06217                                                strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
06218                                                strncpy(tmpwrite,"\n",len);
06219                                                break;
06220                                        case 't':
06221                                                strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
06222                                                strncpy(tmpwrite,"\t",len);
06223                                                break;
06224                                        default:
06225                                                ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n",tmpwrite[1]);
06226                                }
06227                                tmpread = tmpwrite+len;
06228                        }
06229                }
06230                if ((s=ast_variable_retrieve(cfg, "general", "pagersubject")))
06231                        pagersubject = strdup(s);
06232                if ((s=ast_variable_retrieve(cfg, "general", "pagerbody"))) {
06233                        char *tmpread, *tmpwrite;
06234                        pagerbody = strdup(s);
06235 
06236                        /* substitute strings \t and \n into the apropriate characters */
06237                        tmpread = tmpwrite = pagerbody;
06238          while ((tmpwrite = strchr(tmpread,'\\'))) {
06239             int len = strlen("\n");
06240             switch (tmpwrite[1]) {
06241                case 'n':
06242                   strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
06243                   strncpy(tmpwrite,"\n",len);
06244                   break;
06245                case 't':
06246                   strncpy(tmpwrite+len,tmpwrite+2,strlen(tmpwrite+2)+1);
06247                   strncpy(tmpwrite,"\t",len);
06248                   break;
06249                default:
06250                   ast_log(LOG_NOTICE, "Substitution routine does not support this character: %c\n",tmpwrite[1]);
06251             }
06252             tmpread = tmpwrite+len;
06253          }
06254       }
06255       ast_mutex_unlock(&vmlock);
06256       ast_config_destroy(cfg);
06257       return 0;
06258    } else {
06259       ast_mutex_unlock(&vmlock);
06260       ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
06261       return 0;
06262    }
06263 }

int load_module void   ) 
 

Initialize the module.

Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.

Returns:
int Always 0.

Definition at line 6287 of file app_voicemail.c.

References app, app2, app3, app4, ast_cli_register(), ast_config_AST_SPOOL_DIR, ast_install_vm_functions(), ast_log(), ast_register_application(), descrip_vm, descrip_vm_box_exists, descrip_vmain, descrip_vmauthenticate, has_voicemail(), load_config(), LOG_WARNING, messagecount(), show_voicemail_users_cli, show_voicemail_zones_cli, synopsis_vm, synopsis_vm_box_exists, synopsis_vmain, synopsis_vmauthenticate, vm_box_exists(), vm_exec(), vm_execmain(), VM_SPOOL_DIR, and vmauthenticate().

06288 {
06289    int res;
06290    res = ast_register_application(app, vm_exec, synopsis_vm, descrip_vm);
06291    res |= ast_register_application(app2, vm_execmain, synopsis_vmain, descrip_vmain);
06292    res |= ast_register_application(app3, vm_box_exists, synopsis_vm_box_exists, descrip_vm_box_exists);
06293    res |= ast_register_application(app4, vmauthenticate, synopsis_vmauthenticate, descrip_vmauthenticate);
06294    if (res)
06295       return(res);
06296 
06297    if ((res=load_config())) {
06298       return(res);
06299    }
06300 
06301    ast_cli_register(&show_voicemail_users_cli);
06302    ast_cli_register(&show_voicemail_zones_cli);
06303 
06304    /* compute the location of the voicemail spool directory */
06305    snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);
06306 
06307    ast_install_vm_functions(has_voicemail, messagecount);
06308 
06309 #if defined(USE_ODBC_STORAGE) && !defined(EXTENDED_ODBC_STORAGE)
06310    ast_log(LOG_WARNING, "The current ODBC storage table format will be changed soon."
06311             "Please update your tables as per the README and edit the apps/Makefile "
06312             "and uncomment the line containing EXTENDED_ODBC_STORAGE to enable the "
06313             "new table format.\n");
06314 #endif
06315 
06316    return res;
06317 }

int make_dir char *  dest,
int  len,
char *  context,
char *  ext,
char *  mailbox
[static]
 

Definition at line 773 of file app_voicemail.c.

References VM_SPOOL_DIR.

Referenced by copy_message(), create_dirpath(), handle_show_voicemail_users(), notify_new_message(), and open_mailbox().

00774 {
00775    return snprintf(dest, len, "%s%s/%s/%s", VM_SPOOL_DIR, context, ext, mailbox);
00776 }

int make_file char *  dest,
int  len,
char *  dir,
int  num
[static]
 

Definition at line 778 of file app_voicemail.c.

Referenced by advanced_options(), close_mailbox(), copy_message(), last_message_index(), leave_voicemail(), notify_new_message(), play_message(), resequence_mailbox(), save_to_folder(), and vm_execmain().

00779 {
00780    return snprintf(dest, len, "%s/msg%04d", dir, num);
00781 }

char* mbox int  id  )  [static]
 

Definition at line 1981 of file app_voicemail.c.

Referenced by adsi_load_vmail(), append_mailbox(), copy_message(), get_folder(), open_mailbox(), save_to_folder(), vm_box_exists(), vm_execmain(), vm_play_folder_name(), and vm_play_folder_name_gr().

01982 {
01983    switch(id) {
01984    case 0:
01985       return "INBOX";
01986    case 1:
01987       return "Old";
01988    case 2:
01989       return "Work";
01990    case 3:
01991       return "Family";
01992    case 4:
01993       return "Friends";
01994    case 5:
01995       return "Cust1";
01996    case 6:
01997       return "Cust2";
01998    case 7:
01999       return "Cust3";
02000    case 8:
02001       return "Cust4";
02002    case 9:
02003       return "Cust5";
02004    default:
02005       return "Unknown";
02006    }
02007 }

int messagecount const char *  mailbox,
int *  newmsgs,
int *  oldmsgs
[static]
 

Definition at line 2232 of file app_voicemail.c.

References ast_strlen_zero(), strsep(), and VM_SPOOL_DIR.

Referenced by load_module(), and run_externnotify().

02233 {
02234    DIR *dir;
02235    struct dirent *de;
02236    char fn[256];
02237    char tmp[256]="";
02238    char *mb, *cur;
02239    char *context;
02240    int ret;
02241    if (newmsgs)
02242       *newmsgs = 0;
02243    if (oldmsgs)
02244       *oldmsgs = 0;
02245    /* If no mailbox, return immediately */
02246    if (ast_strlen_zero(mailbox))
02247       return 0;
02248    if (strchr(mailbox, ',')) {
02249       int tmpnew, tmpold;
02250       ast_copy_string(tmp, mailbox, sizeof(tmp));
02251       mb = tmp;
02252       ret = 0;
02253       while((cur = strsep(&mb, ", "))) {
02254          if (!ast_strlen_zero(cur)) {
02255             if (messagecount(cur, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL))
02256                return -1;
02257             else {
02258                if (newmsgs)
02259                   *newmsgs += tmpnew; 
02260                if (oldmsgs)
02261                   *oldmsgs += tmpold;
02262             }
02263          }
02264       }
02265       return 0;
02266    }
02267    ast_copy_string(tmp, mailbox, sizeof(tmp));
02268    context = strchr(tmp, '@');
02269    if (context) {
02270       *context = '\0';
02271       context++;
02272    } else
02273       context = "default";
02274    if (newmsgs) {
02275       snprintf(fn, sizeof(fn), "%s/%s/%s/INBOX", VM_SPOOL_DIR, context, tmp);
02276       dir = opendir(fn);
02277       if (dir) {
02278          while ((de = readdir(dir))) {
02279             if ((strlen(de->d_name) > 3) && !strncasecmp(de->d_name, "msg", 3) &&
02280                !strcasecmp(de->d_name + strlen(de->d_name) - 3, "txt"))
02281                   (*newmsgs)++;
02282                
02283          }
02284          closedir(dir);
02285       }
02286    }
02287    if (oldmsgs) {
02288       snprintf(fn, sizeof(fn), "%s/%s/%s/Old", VM_SPOOL_DIR, context, tmp);
02289       dir = opendir(fn);
02290       if (dir) {
02291          while ((de = readdir(dir))) {
02292             if ((strlen(de->d_name) > 3) && !strncasecmp(de->d_name, "msg", 3) &&
02293                !strcasecmp(de->d_name + strlen(de->d_name) - 3, "txt"))
02294                   (*oldmsgs)++;
02295                
02296          }
02297          closedir(dir);
02298       }
02299    }
02300    return 0;
02301 }

int notify_new_message struct ast_channel chan,
struct ast_vm_user vmu,
int  msgnum,
long  duration,
char *  fmt,
char *  cidnum,
char *  cidname
[static]
 

Definition at line 3302 of file app_voicemail.c.

References ast_app_has_voicemail(), ast_app_messagecount(), ast_log(), ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_vm_user::context, DELETE, ast_vm_user::email, EVENT_FLAG_CALL, fmt, globalflags, LOG_ERROR, ast_vm_user::mailbox, make_dir(), make_file(), manager_event(), ast_vm_user::pager, run_externnotify(), sendmail(), sendpage(), ast_vm_user::serveremail, strsep(), VM_ATTACH, and VM_DELETE.

Referenced by copy_message(), and leave_voicemail().

03303 {
03304    char todir[256], fn[256], ext_context[256], *stringp;
03305    int newmsgs = 0, oldmsgs = 0;
03306 
03307    make_dir(todir, sizeof(todir), vmu->context, vmu->mailbox, "INBOX");
03308    make_file(fn, sizeof(fn), todir, msgnum);
03309    snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context);
03310 
03311    /* Attach only the first format */
03312    fmt = ast_strdupa(fmt);
03313    if (fmt) {
03314       stringp = fmt;
03315       strsep(&stringp, "|");
03316 
03317       if (!ast_strlen_zero(vmu->email)) {
03318          int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
03319          char *myserveremail = serveremail;
03320          attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
03321          if (!ast_strlen_zero(vmu->serveremail))
03322             myserveremail = vmu->serveremail;
03323          sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail);
03324       }
03325 
03326       if (!ast_strlen_zero(vmu->pager)) {
03327          char *myserveremail = serveremail;
03328          if (!ast_strlen_zero(vmu->serveremail))
03329             myserveremail = vmu->serveremail;
03330          sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu);
03331       }
03332    } else {
03333       ast_log(LOG_ERROR, "Out of memory\n");
03334    }
03335 
03336    if (ast_test_flag(vmu, VM_DELETE)) {
03337       DELETE(todir, msgnum, fn);
03338    }
03339 
03340    /* Leave voicemail for someone */
03341    if (ast_app_has_voicemail(ext_context, NULL)) {
03342       ast_app_messagecount(ext_context, &newmsgs, &oldmsgs);
03343    }
03344    manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\nNew: %d\r\nOld: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs);
03345    run_externnotify(vmu->context, vmu->mailbox);
03346    return 0;
03347 }

int ochar struct baseio bio,
int  c,
FILE *  so
[static]
 

Definition at line 1538 of file app_voicemail.c.

References eol, baseio::linelength, and so.

Referenced by base_encode().

01539 {
01540    if (bio->linelength>=BASELINELEN) {
01541       if (fputs(eol,so)==EOF)
01542          return -1;
01543 
01544       bio->linelength= 0;
01545    }
01546 
01547    if (putc(((unsigned char)c),so)==EOF)
01548       return -1;
01549 
01550    bio->linelength++;
01551 
01552    return 1;
01553 }

int open_mailbox struct vm_state vms,
struct ast_vm_user vmu,
int  box
[static]
 

Definition at line 3836 of file app_voicemail.c.

References ast_log(), ast_vm_user::context, count_messages(), vm_state::curbox, vm_state::curdir, last_message_index(), vm_state::lastmsg, LOG_NOTICE, make_dir(), mbox(), resequence_mailbox(), vm_state::username, and vm_state::vmbox.

Referenced by vm_execmain().

03837 {
03838    int res = 0;
03839    int count_msg, last_msg;
03840 
03841    ast_copy_string(vms->curbox, mbox(box), sizeof(vms->curbox));
03842    
03843    /* Rename the member vmbox HERE so that we don't try to return before
03844     * we know what's going on.
03845     */
03846    snprintf(vms->vmbox, sizeof(vms->vmbox), "vm-%s", vms->curbox);
03847    
03848    make_dir(vms->curdir, sizeof(vms->curdir), vmu->context, vms->username, vms->curbox);
03849    count_msg = count_messages(vmu, vms->curdir);
03850    if (count_msg < 0)
03851       return count_msg;
03852    else
03853       vms->lastmsg = count_msg - 1;
03854 
03855    /*
03856    The following test is needed in case sequencing gets messed up.
03857    There appears to be more than one way to mess up sequence, so
03858    we will not try to find all of the root causes--just fix it when
03859    detected.
03860    */
03861 
03862    last_msg = last_message_index(vmu, vms->curdir);
03863    if (last_msg < 0)
03864       return last_msg;
03865    else if(vms->lastmsg != last_msg)
03866    {
03867       ast_log(LOG_NOTICE, "Resequencing Mailbox: %s\n", vms->curdir);
03868       res = resequence_mailbox(vmu, vms->curdir);
03869       if (res)
03870          return res;
03871    }
03872 
03873    return 0;
03874 }

int play_message struct ast_channel chan,
struct ast_vm_user vmu,
struct vm_state vms
[static]
 

Definition at line 3762 of file app_voicemail.c.

References adsi_message(), ast_config_destroy(), ast_config_load(), AST_DIGIT_ANY, ast_log(), ast_say_number(), ast_test_flag, ast_variable_retrieve(), vm_state::curdir, vm_state::curmsg, DISPOSE, vm_state::fn, vm_state::fn2, vm_state::heard, ast_channel::language, vm_state::lastmsg, LOG_WARNING, make_file(), play_message_callerid(), play_message_category(), play_message_datetime(), play_message_duration(), RETRIEVE, ast_vm_user::saydurationm, vm_state::starting, VM_ENVELOPE, VM_SAYCID, VM_SAYDURATION, wait_file(), and wait_file2().

Referenced by vm_browse_messages_en(), vm_browse_messages_es(), vm_browse_messages_gr(), vm_browse_messages_it(), vm_browse_messages_pt(), and vm_execmain().

03763 {
03764    int res = 0;
03765    char filename[256],*origtime, *cid, *context, *duration;
03766    char *category;
03767    struct ast_config *msg_cfg;
03768 
03769    vms->starting = 0; 
03770    make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
03771    adsi_message(chan, vms);
03772    if (!vms->curmsg)
03773       res = wait_file2(chan, vms, "vm-first");  /* "First" */
03774    else if (vms->curmsg == vms->lastmsg)
03775       res = wait_file2(chan, vms, "vm-last");      /* "last" */
03776    if (!res) {
03777                if (!strcasecmp(chan->language, "se")) {             /* SWEDISH syntax */
03778                        res = wait_file2(chan, vms, "vm-meddelandet");  /* "message" */
03779                }
03780                else {
03781                        res = wait_file2(chan, vms, "vm-message");      /* "message" */
03782                }
03783       if (vms->curmsg && (vms->curmsg != vms->lastmsg)) {
03784          if (!res)
03785             res = ast_say_number(chan, vms->curmsg + 1, AST_DIGIT_ANY, chan->language, (char *) NULL);
03786       }
03787    }
03788 
03789    /* Retrieve info from VM attribute file */
03790    make_file(vms->fn2, sizeof(vms->fn2), vms->curdir, vms->curmsg);
03791    snprintf(filename,sizeof(filename), "%s.txt", vms->fn2);
03792    RETRIEVE(vms->curdir, vms->curmsg);
03793    msg_cfg = ast_config_load(filename);
03794    if (!msg_cfg) {
03795       ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
03796       return 0;
03797    }
03798                                                                            
03799    if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) {
03800       ast_log(LOG_WARNING, "No origtime?!\n");
03801       DISPOSE(vms->curdir, vms->curmsg);
03802       ast_config_destroy(msg_cfg);
03803       return 0;
03804    }
03805 
03806    cid = ast_variable_retrieve(msg_cfg, "message", "callerid");
03807    duration = ast_variable_retrieve(msg_cfg, "message", "duration");
03808    category = ast_variable_retrieve(msg_cfg, "message", "category");
03809 
03810    context = ast_variable_retrieve(msg_cfg, "message", "context");
03811    if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */
03812       context = ast_variable_retrieve(msg_cfg, "message","macrocontext");
03813 
03814    if (!res)
03815       res = play_message_category(chan, category);
03816    if ((!res) && (ast_test_flag(vmu, VM_ENVELOPE)))
03817       res = play_message_datetime(chan, vmu, origtime, filename);
03818    if ((!res) && (ast_test_flag(vmu, VM_SAYCID)))
03819       res = play_message_callerid(chan, vms, cid, context, 0);
03820         if ((!res) && (ast_test_flag(vmu, VM_SAYDURATION)))
03821                 res = play_message_duration(chan, vms, duration, vmu->saydurationm);
03822    /* Allow pressing '1' to skip envelope / callerid */
03823    if (res == '1')
03824       res = 0;
03825    ast_config_destroy(msg_cfg);
03826 
03827    if (!res) {
03828       make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg);
03829       vms->heard[vms->curmsg] = 1;
03830       res = wait_file(chan, vms, vms->fn);
03831    }
03832    DISPOSE(vms->curdir, vms->curmsg);
03833    return res;
03834 }

int play_message_callerid struct ast_channel chan,
struct vm_state vms,
char *  cid,
char *  context,
int  callback
[static]
 

Definition at line 3678 of file app_voicemail.c.

References ast_callerid_parse(), AST_DIGIT_ANY, ast_fileexists(), ast_log(), ast_say_digit_str(), ast_streamfile(), ast_strlen_zero(), ast_verbose(), ast_waitstream(), cidinternalcontexts, ast_channel::language, LOG_DEBUG, name, VERBOSE_PREFIX_3, VM_SPOOL_DIR, and wait_file2().

Referenced by advanced_options(), and play_message().

03679 {
03680    int res = 0;
03681    int i;
03682    char *callerid, *name;
03683    char prefile[256]="";
03684    
03685 
03686    /* If voicemail cid is not enabled, or we didn't get cid or context from the attribute file, leave now. */
03687    /* BB: Still need to change this so that if this function is called by the message envelope (and someone is explicitly requesting to hear the CID), it does not check to see if CID is enabled in the config file */
03688    if ((cid == NULL)||(context == NULL))
03689       return res;
03690 
03691    /* Strip off caller ID number from name */
03692    ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
03693    ast_callerid_parse(cid, &name, &callerid);
03694    if ((!ast_strlen_zero(callerid)) && strcmp(callerid, "Unknown")) {
03695       /* Check for internal contexts and only */
03696       /* say extension when the call didn't come from an internal context in the list */
03697       for (i = 0 ; i < MAX_NUM_CID_CONTEXTS ; i++){
03698          ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
03699          if ((strcmp(cidinternalcontexts[i], context) == 0))
03700             break;
03701       }
03702       if (i != MAX_NUM_CID_CONTEXTS){ /* internal context? */
03703          if (!res) {
03704             snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, context, callerid);
03705             if (!ast_strlen_zero(prefile)) {
03706             /* See if we can find a recorded name for this person instead of their extension number */
03707                if (ast_fileexists(prefile, NULL, NULL) > 0) {
03708                   ast_verbose(VERBOSE_PREFIX_3 "Playing envelope info: CID number '%s' matches mailbox number, playing recorded name\n", callerid);
03709                   if (!callback)
03710                      res = wait_file2(chan, vms, "vm-from");
03711                   res = ast_streamfile(chan, prefile, chan->language) > -1;
03712                   res = ast_waitstream(chan, "");
03713                } else {
03714                   ast_verbose(VERBOSE_PREFIX_3 "Playing envelope info: message from '%s'\n", callerid);
03715                   /* BB: Say "from extension" as one saying to sound smoother */
03716                   if (!callback)
03717                      res = wait_file2(chan, vms, "vm-from-extension");
03718                   res = ast_say_digit_str(chan, callerid, "", chan->language);
03719                }
03720             }
03721          }
03722       }
03723 
03724       else if (!res){
03725          ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid);
03726          /* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */
03727          if (!callback)
03728             res = wait_file2(chan, vms, "vm-from-phonenumber");
03729          res = ast_say_digit_str(chan, callerid, AST_DIGIT_ANY, chan->language);
03730       }
03731    } else {
03732       /* Number unknown */
03733       ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
03734       /* Say "from an unknown caller" as one phrase - it is already recorded by "the voice" anyhow */
03735       res = wait_file2(chan, vms, "vm-unknown-caller");
03736    }
03737    return res;
03738 }

int play_message_category struct ast_channel chan,
char *  category
[static]
 

Definition at line 3600 of file app_voicemail.c.

References ast_play_and_wait(), and ast_strlen_zero().

Referenced by play_message().

03601 {
03602    int res = 0;
03603 
03604    if (!ast_strlen_zero(category))
03605       res = ast_play_and_wait(chan, category);
03606 
03607    return res;
03608 }

int play_message_datetime struct ast_channel chan,
struct ast_vm_user vmu,
char *  origtime,
char *  filename
[static]
 

Definition at line 3610 of file app_voicemail.c.

References AST_DIGIT_ANY, ast_log(), ast_say_date_with_format(), ast_strlen_zero(), ast_channel::language, LOG_WARNING, vm_zone::msg_format, vm_zone::name, vm_zone::next, pbx_builtin_setvar_helper(), vm_zone::timezone, and ast_vm_user::zonetag.

Referenced by advanced_options(), and play_message().

03611 {
03612    int res = 0;
03613    struct vm_zone *the_zone = NULL;
03614    time_t t;
03615    long tin;
03616 
03617    if (sscanf(origtime,"%ld",&tin) < 1) {
03618       ast_log(LOG_WARNING, "Couldn't find origtime in %s\n", filename);
03619       return 0;
03620    }
03621    t = tin;
03622 
03623    /* Does this user have a timezone specified? */
03624    if (!ast_strlen_zero(vmu->zonetag)) {
03625       /* Find the zone in the list */
03626       struct vm_zone *z;
03627       z = zones;
03628       while (z) {
03629          if (!strcmp(z->name, vmu->zonetag)) {
03630             the_zone = z;
03631             break;
03632          }
03633          z = z->next;
03634       }
03635    }
03636 
03637 /* No internal variable parsing for now, so we'll comment it out for the time being */
03638 #if 0
03639    /* Set the DIFF_* variables */
03640    localtime_r(&t, &time_now);
03641    tv_now = ast_tvnow();
03642    tnow = tv_now.tv_sec;
03643    localtime_r(&tnow,&time_then);
03644 
03645    /* Day difference */
03646    if (time_now.tm_year == time_then.tm_year)
03647       snprintf(temp,sizeof(temp),"%d",time_now.tm_yday);
03648    else
03649       snprintf(temp,sizeof(temp),"%d",(time_now.tm_year - time_then.tm_year) * 365 + (time_now.tm_yday - time_then.tm_yday));
03650    pbx_builtin_setvar_helper(chan, "DIFF_DAY", temp);
03651 
03652    /* Can't think of how other diffs might be helpful, but I'm sure somebody will think of something. */
03653 #endif
03654    if (the_zone)
03655       res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, the_zone->msg_format, the_zone->timezone);
03656        else if(!strcasecmp(chan->language,"se"))       /* SWEDISH syntax */
03657                res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' dB 'digits/at' k 'and' M", NULL);
03658        else if(!strcasecmp(chan->language,"no"))       /* NORWEGIAN syntax */
03659                res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q 'digits/at' HM", NULL);
03660    else if(!strcasecmp(chan->language,"de")) /* GERMAN syntax */
03661       res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q 'digits/at' HM", NULL);
03662    else if (!strcasecmp(chan->language,"nl"))   /* DUTCH syntax */
03663       res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/nl-om' HM", NULL);
03664    else if (!strcasecmp(chan->language,"it"))      /* ITALIAN syntax */
03665       res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' 'digits/hours' k 'digits/e' M 'digits/minutes'", NULL);
03666    else if (!strcasecmp(chan->language,"gr"))
03667       res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q  H 'digits/kai' M ", NULL);
03668    else
03669       res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL);
03670 #if 0
03671    pbx_builtin_setvar_helper(chan, "DIFF_DAY", NULL);
03672 #endif
03673    return res;
03674 }

int play_message_duration struct ast_channel chan,
struct vm_state vms,
char *  duration,
int  minduration
[static]
 

Definition at line 3740 of file app_voicemail.c.

References AST_DIGIT_ANY, ast_log(), ast_say_number(), ast_channel::language, LOG_DEBUG, and wait_file2().

Referenced by play_message().

03741 {
03742    int res = 0;
03743    int durationm;
03744    int durations;
03745    /* Verify that we have a duration for the message */
03746    if((duration == NULL))
03747       return res;
03748 
03749    /* Convert from seconds to minutes */
03750    durations=atoi(duration);
03751    durationm=(durations / 60);
03752 
03753    ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
03754 
03755    if((!res)&&(durationm>=minduration)) {
03756       res = ast_say_number(chan, durationm, AST_DIGIT_ANY, chan->language, (char *) NULL);
03757       res = wait_file2(chan, vms, "vm-minutes");
03758    }
03759    return res;
03760 }

int play_record_review struct ast_channel chan,
char *  playfile,
char *  recordfile,
int  maxtime,
char *  fmt,
int  outsidecaller,
struct ast_vm_user vmu,
int *  duration,
const char *  unlockdir,
signed char  record_gain
[static]
 

Definition at line 6544 of file app_voicemail.c.

References ast_channel_setoption(), AST_DIGIT_ANY, ast_log(), AST_OPTION_RXGAIN, ast_play_and_record(), ast_play_and_wait(), ast_streamfile(), ast_test_flag, ast_verbose(), ast_waitfordigit(), ast_waitstream(), ast_vm_user::context, DELETE, DISPOSE, fmt, INTRO, ast_channel::language, LOG_WARNING, ast_vm_user::mailbox, maxsilence, silencethreshold, STORE, VERBOSE_PREFIX_3, vm_delete(), vm_exec(), VM_OPERATOR, and VM_REVIEW.

Referenced by leave_voicemail(), vm_newuser(), vm_options(), and vm_tempgreeting().

06547 {
06548    /* Record message & let caller review or re-record it, or set options if applicable */
06549    int res = 0;
06550    int cmd = 0;
06551    int max_attempts = 3;
06552    int attempts = 0;
06553    int recorded = 0;
06554    int message_exists = 0;
06555    signed char zero_gain = 0;
06556    /* Note that urgent and private are for flagging messages as such in the future */
06557  
06558    /* barf if no pointer passed to store duration in */
06559    if (duration == NULL) {
06560       ast_log(LOG_WARNING, "Error play_record_review called without duration pointer\n");
06561       return -1;
06562    }
06563 
06564    cmd = '3';   /* Want to start by recording */
06565  
06566    while ((cmd >= 0) && (cmd != 't')) {
06567       switch (cmd) {
06568       case '1':
06569          if (!message_exists) {
06570             /* In this case, 1 is to record a message */
06571             cmd = '3';
06572             break;
06573          } else {
06574             /* Otherwise 1 is to save the existing message */
06575             ast_verbose(VERBOSE_PREFIX_3 "Saving message as is\n");
06576             ast_streamfile(chan, "vm-msgsaved", chan->language);
06577             ast_waitstream(chan, "");
06578             STORE(recordfile, vmu->mailbox, vmu->context, -1);
06579             DISPOSE(recordfile, -1);
06580             cmd = 't';
06581             return res;
06582          }
06583       case '2':
06584          /* Review */
06585          ast_verbose(VERBOSE_PREFIX_3 "Reviewing the message\n");
06586          ast_streamfile(chan, recordfile, chan->language);
06587          cmd = ast_waitstream(chan, AST_DIGIT_ANY);
06588          break;
06589       case '3':
06590          message_exists = 0;
06591          /* Record */
06592          if (recorded == 1)
06593             ast_verbose(VERBOSE_PREFIX_3 "Re-recording the message\n");
06594          else  
06595             ast_verbose(VERBOSE_PREFIX_3 "Recording the message\n");
06596          if (recorded && outsidecaller) {
06597             cmd = ast_play_and_wait(chan, INTRO);
06598             cmd = ast_play_and_wait(chan, "beep");
06599          }
06600          recorded = 1;
06601          /* After an attempt has been made to record message, we have to take care of INTRO and beep for incoming messages, but not for greetings */
06602          if (record_gain)
06603             ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
06604          cmd = ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir);
06605          if (record_gain)
06606             ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
06607          if (cmd == -1) {
06608          /* User has hung up, no options to give */
06609             return cmd;
06610          }
06611          if (cmd == '0') {
06612             break;
06613          } else if (cmd == '*') {
06614             break;
06615          } 
06616 #if 0       
06617          else if (vmu->review && (*duration < 5)) {
06618             /* Message is too short */
06619             ast_verbose(VERBOSE_PREFIX_3 "Message too short\n");
06620             cmd = ast_play_and_wait(chan, "vm-tooshort");
06621             cmd = vm_delete(recordfile);
06622             break;
06623          }
06624          else if (vmu->review && (cmd == 2 && *duration < (maxsilence + 3))) {
06625             /* Message is all silence */
06626             ast_verbose(VERBOSE_PREFIX_3 "Nothing recorded\n");
06627             cmd = vm_delete(recordfile);
06628             cmd = ast_play_and_wait(chan, "vm-nothingrecorded");
06629             if (!cmd)
06630                cmd = ast_play_and_wait(chan, "vm-speakup");
06631             break;
06632          }
06633 #endif
06634          else {
06635             /* If all is well, a message exists */
06636             message_exists = 1;
06637             cmd = 0;
06638          }
06639          break;
06640       case '4':
06641       case '5':
06642       case '6':
06643       case '7':
06644       case '8':
06645       case '9':
06646       case '*':
06647       case '#':
06648          cmd = ast_play_and_wait(chan, "vm-sorry");
06649          break;
06650 #if 0 
06651 /*  XXX Commented out for the moment because of the dangers of deleting
06652     a message while recording (can put the message numbers out of sync) */
06653       case '*':
06654          /* Cancel recording, delete message, offer to take another message*/
06655          cmd = ast_play_and_wait(chan, "vm-deleted");
06656          cmd = vm_delete(recordfile);
06657          if (outsidecaller) {
06658             res = vm_exec(chan, NULL);
06659             return res;
06660          }
06661          else
06662             return 1;
06663 #endif
06664       case '0':
06665          if (message_exists || recorded) {
06666             cmd = ast_play_and_wait(chan, "vm-saveoper");
06667             if (!cmd)
06668                cmd = ast_waitfordigit(chan, 3000);
06669             if (cmd == '1') {
06670                ast_play_and_wait(chan, "vm-msgsaved");
06671                cmd = '0';
06672             } else {
06673                ast_play_and_wait(chan, "vm-deleted");
06674                DELETE(recordfile, -1, recordfile);
06675                cmd = '0';
06676             }
06677          }
06678          return cmd;
06679       default:
06680          /* If the caller is an ouside caller, and the review option is enabled,
06681             allow them to review the message, but let the owner of the box review
06682             their OGM's */
06683          if (outsidecaller && !ast_test_flag(vmu, VM_REVIEW))
06684             return cmd;
06685          if (message_exists) {
06686             cmd = ast_play_and_wait(chan, "vm-review");
06687          }
06688          else {
06689             cmd = ast_play_and_wait(chan, "vm-torerecord");
06690             if (!cmd)
06691                cmd = ast_waitfordigit(chan, 600);
06692          }
06693          
06694          if (!cmd && outsidecaller && ast_test_flag(vmu, VM_OPERATOR)) {
06695             cmd = ast_play_and_wait(chan, "vm-reachoper");
06696             if (!cmd)
06697                cmd = ast_waitfordigit(chan, 600);
06698          }
06699 #if 0
06700          if (!cmd)
06701             cmd = ast_play_and_wait(chan, "vm-tocancelmsg");
06702 #endif
06703          if (!cmd)
06704             cmd = ast_waitfordigit(chan, 6000);
06705          if (!cmd) {
06706             attempts++;
06707          }
06708          if (attempts > max_attempts) {
06709             cmd = 't';
06710          }
06711       }
06712    }
06713    if (outsidecaller)  
06714       ast_play_and_wait(chan, "vm-goodbye");
06715    if (cmd == 't')
06716       cmd = 0;
06717    return cmd;
06718  }

void populate_defaults struct ast_vm_user vmu  )  [static]
 

Definition at line 424 of file app_voicemail.c.

References ast_copy_flags, AST_FLAGS_ALL, ast_vm_user::callback, callcontext, dialcontext, ast_vm_user::dialout, ast_vm_user::exit, exitcontext, globalflags, ast_vm_user::maxmsg, and ast_vm_user::saydurationm.

Referenced by append_mailbox(), and find_user_realtime().

00425 {
00426    ast_copy_flags(vmu, (&globalflags), AST_FLAGS_ALL);   
00427    if (saydurationminfo)
00428       vmu->saydurationm = saydurationminfo;
00429    if (callcontext)
00430       ast_copy_string(vmu->callback, callcontext, sizeof(vmu->callback));
00431    if (dialcontext)
00432       ast_copy_string(vmu->dialout, dialcontext, sizeof(vmu->dialout));
00433    if (exitcontext)
00434       ast_copy_string(vmu->exit, exitcontext, sizeof(vmu->exit));
00435    if (maxmsg)
00436       vmu->maxmsg = maxmsg;
00437 }

void prep_email_sub_vars struct ast_channel ast,
struct ast_vm_user vmu,
int  msgnum,
char *  context,
char *  mailbox,
char *  cidnum,
char *  cidname,
char *  dur,
char *  date,
char *  passdata,
size_t  passdatasize
[static]
 

Definition at line 1627 of file app_voicemail.c.

References ast_callerid_merge(), ast_vm_user::fullname, and pbx_builtin_setvar_helper().

Referenced by sendmail(), and sendpage().

01628 {
01629    char callerid[256];
01630    /* Prepare variables for substition in email body and subject */
01631    pbx_builtin_setvar_helper(ast, "VM_NAME", vmu->fullname);
01632    pbx_builtin_setvar_helper(ast, "VM_DUR", dur);
01633    snprintf(passdata, passdatasize, "%d", msgnum);
01634    pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata);
01635    pbx_builtin_setvar_helper(ast, "VM_CONTEXT", context);
01636    pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox);
01637    pbx_builtin_setvar_helper(ast, "VM_CALLERID", ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, "Unknown Caller"));
01638    pbx_builtin_setvar_helper(ast, "VM_CIDNAME", (cidname ? cidname : "an unknown caller"));
01639    pbx_builtin_setvar_helper(ast, "VM_CIDNUM", (cidnum ? cidnum : "an unknown caller"));
01640    pbx_builtin_setvar_helper(ast, "VM_DATE", date);
01641 }

int reload void   ) 
 

Reload stuff.

This function is where any reload routines take place. Re-read config files, change signalling, whatever is appropriate on a reload.

Returns:
The return value is not used.

Definition at line 6265 of file app_voicemail.c.

References load_config().

06266 {
06267    return(load_config());
06268 }

void rename_file char *  sfn,
char *  dfn
[static]
 

Definition at line 1397 of file app_voicemail.c.

References ast_filerename().

01398 {
01399    char stxt[256];
01400    char dtxt[256];
01401    ast_filerename(sfn,dfn,NULL);
01402    snprintf(stxt, sizeof(stxt), "%s.txt", sfn);
01403    snprintf(dtxt, sizeof(dtxt), "%s.txt", dfn);
01404    rename(stxt, dtxt);
01405 }

int resequence_mailbox struct ast_vm_user vmu,
char *  dir
[static]
 

Definition at line 2655 of file app_voicemail.c.

References ast_unlock_path(), ast_vm_user::context, EXISTS, ast_vm_user::mailbox, make_file(), ast_vm_user::maxmsg, RENAME, and vm_lock_path().

Referenced by open_mailbox().

02656 {
02657    /* we know max messages, so stop process when number is hit */
02658 
02659    int x,dest;
02660    char sfn[256];
02661    char dfn[256];
02662 
02663    if (vm_lock_path(dir))
02664       return ERROR_LOCK_PATH;
02665 
02666    for (x = 0, dest = 0; x < vmu->maxmsg; x++) {
02667       make_file(sfn, sizeof(sfn), dir, x);
02668       if (EXISTS(dir, x, sfn, NULL)) {
02669          
02670          if(x != dest) {
02671             make_file(dfn, sizeof(dfn), dir, dest);
02672             RENAME(dir, x, vmu->mailbox, vmu->context, dir, dest, sfn, dfn);
02673          }
02674          
02675          dest++;
02676       }
02677    }
02678    ast_unlock_path(dir);
02679 
02680    return 0;
02681 }

int reset_user_pw const char *  context,
const char *  mailbox,
const char *  newpass
[static]
 

Definition at line 608 of file app_voicemail.c.

References ast_mutex_lock(), ast_mutex_unlock(), ast_vm_user::context, ast_vm_user::mailbox, ast_vm_user::next, and ast_vm_user::password.

Referenced by vm_change_password().

00609 {
00610    /* This function could be made to generate one from a database, too */
00611    struct ast_vm_user *cur;
00612    int res = -1;
00613    ast_mutex_lock(&vmlock);
00614    cur = users;
00615    while (cur) {
00616       if ((!context || !strcasecmp(context, cur->context)) &&
00617          (!strcasecmp(mailbox, cur->mailbox)))
00618             break;
00619       cur=cur->next;
00620    }
00621    if (cur) {
00622       ast_copy_string(cur->password, newpass, sizeof(cur->password));
00623       res = 0;
00624    }
00625    ast_mutex_unlock(&vmlock);
00626    return res;
00627 }

void run_externnotify char *  context,
char *  extension
[static]
 

Definition at line 2341 of file app_voicemail.c.

References ast_log(), ast_safe_system(), ast_strlen_zero(), externnotify, LOG_DEBUG, LOG_ERROR, and messagecount().

Referenced by forward_message(), notify_new_message(), and vm_execmain().

02342 {
02343    char arguments[255];
02344    char ext_context[256] = "";
02345    int newvoicemails = 0, oldvoicemails = 0;
02346 
02347    if (!ast_strlen_zero(context))
02348       snprintf(ext_context, sizeof(ext_context), "%s@%s", extension, context);
02349    else
02350       ast_copy_string(ext_context, extension, sizeof(ext_context));
02351 
02352    if (!ast_strlen_zero(externnotify)) {
02353       if (messagecount(ext_context, &newvoicemails, &oldvoicemails)) {
02354          ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension);
02355       } else {
02356          snprintf(arguments, sizeof(arguments), "%s %s %s %d&", externnotify, context, extension, newvoicemails);
02357          ast_log(LOG_DEBUG, "Executing %s\n", arguments);
02358          ast_safe_system(arguments);
02359       }
02360    }
02361 }

int save_to_folder struct ast_vm_user vmu,
char *  dir,
int  msg,
char *  context,
char *  username,
int  box
[static]
 

Definition at line 2691 of file app_voicemail.c.

References ast_unlock_path(), COPY, create_dirpath(), EXISTS, make_file(), ast_vm_user::maxmsg, mbox(), and vm_lock_path().

Referenced by close_mailbox(), and vm_execmain().

02692 {
02693    char sfn[256];
02694    char dfn[256];
02695    char ddir[256];
02696    char *dbox = mbox(box);
02697    int x;
02698    make_file(sfn, sizeof(sfn), dir, msg);
02699    create_dirpath(ddir, sizeof(ddir), context, username, dbox);
02700 
02701    if (vm_lock_path(ddir))
02702       return ERROR_LOCK_PATH;
02703 
02704    for (x = 0; x < vmu->maxmsg; x++) {
02705       make_file(dfn, sizeof(dfn), ddir, x);
02706       if (!EXISTS(ddir, x, dfn, NULL))
02707          break;
02708    }
02709    if (x >= vmu->maxmsg) {
02710       ast_unlock_path(ddir);
02711       return -1;
02712    }
02713    if (strcmp(sfn, dfn)) {
02714       COPY(dir, msg, ddir, x, username, context, sfn, dfn);
02715    }
02716    ast_unlock_path(ddir);
02717    
02718    return 0;
02719 }

int say_and_wait struct ast_channel chan,
int  num,
char *  language
[static]
 

Definition at line 2684 of file app_voicemail.c.

References AST_DIGIT_ANY, and ast_say_number().

Referenced by vm_execmain(), vm_intro_cz(), vm_intro_de(), vm_intro_en(), vm_intro_es(), vm_intro_fr(), vm_intro_it(), vm_intro_nl(), vm_intro_no(), and vm_intro_se().

02685 {
02686    int d;
02687    d = ast_say_number(chan, num, AST_DIGIT_ANY, language, (char *) NULL);
02688    return d;
02689 }

int sendmail char *  srcemail,
struct ast_vm_user vmu,
int  msgnum,
char *  context,
char *  mailbox,
char *  cidnum,
char *  cidname,
char *  attach,
char *  format,
int  duration,
int  attach_user_voicemail
[static]
 

Definition at line 1643 of file app_voicemail.c.

References ast_channel_alloc(), ast_channel_free(), ast_localtime(), ast_log(), ast_safe_system(), ast_strlen_zero(), ast_test_flag, base_encode(), charset, ast_vm_user::email, emailbody, emaildateformat, emailsubject, emailtitle, fromstring, ast_vm_user::fullname, globalflags, LOG_DEBUG, LOG_WARNING, ast_vm_user::mailbox, mailcmd, vm_zone::name, vm_zone::next, pbx_substitute_variables_helper(), prep_email_sub_vars(), vm_zone::timezone, VM_ATTACH, VM_PBXSKIP, and ast_vm_user::zonetag.

Referenced by forward_message(), and notify_new_message().

01644 {
01645    FILE *p=NULL;
01646    int pfd;
01647    char date[256];
01648    char host[MAXHOSTNAMELEN] = "";
01649    char who[256];
01650    char bound[256];
01651    char fname[256];
01652    char dur[256];
01653    char tmp[80] = "/tmp/astmail-XXXXXX";
01654    char tmp2[256];
01655    time_t t;
01656    struct tm tm;
01657    struct vm_zone *the_zone = NULL;
01658    if (vmu && ast_strlen_zero(vmu->email)) {
01659       ast_log(LOG_WARNING, "E-mail address missing for mailbox [%s].  E-mail will not be sent.\n", vmu->mailbox);
01660       return(0);
01661    }
01662    if (!strcmp(format, "wav49"))
01663       format = "WAV";
01664    ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
01665    /* Make a temporary file instead of piping directly to sendmail, in case the mail
01666       command hangs */
01667    pfd = mkstemp(tmp);
01668    if (pfd > -1) {
01669       p = fdopen(pfd, "w");
01670       if (!p) {
01671          close(pfd);
01672          pfd = -1;
01673       }
01674    }
01675    if (p) {
01676       gethostname(host, sizeof(host)-1);
01677       if (strchr(srcemail, '@'))
01678          ast_copy_string(who, srcemail, sizeof(who));
01679       else {
01680          snprintf(who, sizeof(who), "%s@%s", srcemail, host);
01681       }
01682       snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
01683       time(&t);
01684 
01685       /* Does this user have a timezone specified? */
01686       if (!ast_strlen_zero(vmu->zonetag)) {
01687          /* Find the zone in the list */
01688          struct vm_zone *z;
01689          z = zones;
01690          while (z) {
01691             if (!strcmp(z->name, vmu->zonetag)) {
01692                the_zone = z;
01693                break;
01694             }
01695             z = z->next;
01696          }
01697       }
01698 
01699       if (the_zone)
01700          ast_localtime(&t,&tm,the_zone->timezone);
01701       else
01702          ast_localtime(&t,&tm,NULL);
01703       strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm);
01704       fprintf(p, "Date: %s\n", date);
01705 
01706       /* Set date format for voicemail mail */
01707       strftime(date, sizeof(date), emaildateformat, &tm);
01708 
01709       if (*fromstring) {
01710          struct ast_channel *ast = ast_channel_alloc(0);
01711          if (ast) {
01712             char *passdata;
01713             int vmlen = strlen(fromstring)*3 + 200;
01714             if ((passdata = alloca(vmlen))) {
01715                memset(passdata, 0, vmlen);
01716                prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
01717                pbx_substitute_variables_helper(ast,fromstring,passdata,vmlen);
01718                fprintf(p, "From: %s <%s>\n",passdata,who);
01719             } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
01720             ast_channel_free(ast);
01721          } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
01722       } else
01723          fprintf(p, "From: Asterisk PBX <%s>\n", who);
01724       fprintf(p, "To: %s <%s>\n", vmu->fullname, vmu->email);
01725 
01726       if (emailsubject) {
01727          struct ast_channel *ast = ast_channel_alloc(0);
01728          if (ast) {
01729             char *passdata;
01730             int vmlen = strlen(emailsubject)*3 + 200;
01731             if ((passdata = alloca(vmlen))) {
01732                memset(passdata, 0, vmlen);
01733                prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
01734                pbx_substitute_variables_helper(ast,emailsubject,passdata,vmlen);
01735                fprintf(p, "Subject: %s\n",passdata);
01736             } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
01737             ast_channel_free(ast);
01738          } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
01739       } else
01740       if (*emailtitle) {
01741          fprintf(p, emailtitle, msgnum + 1, mailbox) ;
01742          fprintf(p,"\n") ;
01743       } else if (ast_test_flag((&globalflags), VM_PBXSKIP))
01744          fprintf(p, "Subject: New message %d in mailbox %s\n", msgnum + 1, mailbox);
01745       else
01746          fprintf(p, "Subject: [PBX]: New message %d in mailbox %s\n", msgnum + 1, mailbox);
01747       fprintf(p, "Message-ID: <Asterisk-%d-%d-%s-%d@%s>\n", msgnum, (unsigned int)rand(), mailbox, getpid(), host);
01748       fprintf(p, "MIME-Version: 1.0\n");
01749       if (attach_user_voicemail) {
01750          /* Something unique. */
01751          snprintf(bound, sizeof(bound), "voicemail_%d%s%d%d", msgnum, mailbox, getpid(), (unsigned int)rand());
01752 
01753          fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"\n\n\n", bound);
01754 
01755          fprintf(p, "--%s\n", bound);
01756       }
01757       fprintf(p, "Content-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n\n", charset);
01758       if (emailbody) {
01759          struct ast_channel *ast = ast_channel_alloc(0);
01760          if (ast) {
01761             char *passdata;
01762             int vmlen = strlen(emailbody)*3 + 200;
01763             if ((passdata = alloca(vmlen))) {
01764                memset(passdata, 0, vmlen);
01765                prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
01766                pbx_substitute_variables_helper(ast,emailbody,passdata,vmlen);
01767                fprintf(p, "%s\n",passdata);
01768             } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
01769             ast_channel_free(ast);
01770          } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
01771       } else {
01772          fprintf(p, "Dear %s:\n\n\tJust wanted to let you know you were just left a %s long message (number %d)\n"
01773 
01774          "in mailbox %s from %s, on %s so you might\n"
01775          "want to check it when you get a chance.  Thanks!\n\n\t\t\t\t--Asterisk\n\n", vmu->fullname, 
01776          dur, msgnum + 1, mailbox, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
01777       }
01778       if (attach_user_voicemail) {
01779          /* Eww. We want formats to tell us their own MIME type */
01780          char *ctype = "audio/x-";
01781          if (!strcasecmp(format, "ogg"))
01782             ctype = "application/";
01783       
01784          fprintf(p, "--%s\n", bound);
01785          fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", ctype, format, msgnum, format);
01786          fprintf(p, "Content-Transfer-Encoding: base64\n");
01787          fprintf(p, "Content-Description: Voicemail sound attachment.\n");
01788          fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"\n\n", msgnum, format);
01789 
01790          snprintf(fname, sizeof(fname), "%s.%s", attach, format);
01791          base_encode(fname, p);
01792          fprintf(p, "\n\n--%s--\n.\n", bound);
01793       }
01794       fclose(p);
01795       snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
01796       ast_safe_system(tmp2);
01797       ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
01798    } else {
01799       ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd);
01800       return -1;
01801    }
01802    return 0;
01803 }

int sendpage char *  srcemail,
char *  pager,
int  msgnum,
char *  context,
char *  mailbox,
char *  cidnum,
char *  cidname,
int  duration,
struct ast_vm_user vmu
[static]
 

Definition at line 1805 of file app_voicemail.c.

References ast_channel_alloc(), ast_channel_free(), ast_localtime(), ast_log(), ast_safe_system(), ast_strlen_zero(), fromstring, LOG_DEBUG, LOG_WARNING, mailcmd, vm_zone::name, vm_zone::next, pagerbody, pagerfromstring, pagersubject, pbx_substitute_variables_helper(), prep_email_sub_vars(), vm_zone::timezone, and ast_vm_user::zonetag.

Referenced by forward_message(), and notify_new_message().

01806 {
01807    FILE *p=NULL;
01808    int pfd;
01809    char date[256];
01810    char host[MAXHOSTNAMELEN]="";
01811    char who[256];
01812    char dur[256];
01813    char tmp[80] = "/tmp/astmail-XXXXXX";
01814    char tmp2[256];
01815    time_t t;
01816    struct tm tm;
01817    struct vm_zone *the_zone = NULL;
01818    pfd = mkstemp(tmp);
01819 
01820    if (pfd > -1) {
01821       p = fdopen(pfd, "w");
01822       if (!p) {
01823          close(pfd);
01824          pfd = -1;
01825       }
01826    }
01827 
01828    if (p) {
01829       gethostname(host, sizeof(host)-1);
01830       if (strchr(srcemail, '@'))
01831          ast_copy_string(who, srcemail, sizeof(who));
01832       else {
01833          snprintf(who, sizeof(who), "%s@%s", srcemail, host);
01834       }
01835       snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60);
01836       time(&t);
01837 
01838       /* Does this user have a timezone specified? */
01839       if (!ast_strlen_zero(vmu->zonetag)) {
01840          /* Find the zone in the list */
01841          struct vm_zone *z;
01842          z = zones;
01843          while (z) {
01844             if (!strcmp(z->name, vmu->zonetag)) {
01845                the_zone = z;
01846                break;
01847             }
01848             z = z->next;
01849          }
01850       }
01851 
01852       if (the_zone)
01853          ast_localtime(&t,&tm,the_zone->timezone);
01854       else
01855          ast_localtime(&t,&tm,NULL);
01856 
01857       strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm);
01858       fprintf(p, "Date: %s\n", date);
01859 
01860       if (*pagerfromstring) {
01861          struct ast_channel *ast = ast_channel_alloc(0);
01862          if (ast) {
01863             char *passdata;
01864             int vmlen = strlen(fromstring)*3 + 200;
01865             if ((passdata = alloca(vmlen))) {
01866                memset(passdata, 0, vmlen);
01867                prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
01868                pbx_substitute_variables_helper(ast,pagerfromstring,passdata,vmlen);
01869                fprintf(p, "From: %s <%s>\n",passdata,who);
01870             } else 
01871                ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
01872             ast_channel_free(ast);
01873          } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
01874       } else
01875          fprintf(p, "From: Asterisk PBX <%s>\n", who);
01876       fprintf(p, "To: %s\n", pager);
01877                if (pagersubject) {
01878                        struct ast_channel *ast = ast_channel_alloc(0);
01879                        if (ast) {
01880                                char *passdata;
01881                                int vmlen = strlen(pagersubject)*3 + 200;
01882                                if ((passdata = alloca(vmlen))) {
01883                                        memset(passdata, 0, vmlen);
01884                                        prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
01885                                        pbx_substitute_variables_helper(ast,pagersubject,passdata,vmlen);
01886                                        fprintf(p, "Subject: %s\n\n",passdata);
01887                                } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
01888                                ast_channel_free(ast);
01889                        } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
01890                } else
01891                        fprintf(p, "Subject: New VM\n\n");
01892       strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
01893                if (pagerbody) {
01894                        struct ast_channel *ast = ast_channel_alloc(0);
01895                        if (ast) {
01896                                char *passdata;
01897                                int vmlen = strlen(pagerbody)*3 + 200;
01898                                if ((passdata = alloca(vmlen))) {
01899                                        memset(passdata, 0, vmlen);
01900                                        prep_email_sub_vars(ast,vmu,msgnum + 1,context,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
01901                                        pbx_substitute_variables_helper(ast,pagerbody,passdata,vmlen);
01902                                        fprintf(p, "%s\n",passdata);
01903                                } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
01904                                ast_channel_free(ast);
01905                        } else ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
01906                } else {
01907                        fprintf(p, "New %s long msg in box %s\n"
01908                                        "from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date);
01909                }
01910       fclose(p);
01911       snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
01912       ast_safe_system(tmp2);
01913       ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
01914    } else {
01915       ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd);
01916       return -1;
01917    }
01918    return 0;
01919 }

int unload_module void   ) 
 

Cleanup all module structures, sockets, etc.

This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).

Returns:
Zero on success, or non-zero on error.

Definition at line 6270 of file app_voicemail.c.

References app, app2, app3, app4, ast_cli_unregister(), ast_uninstall_vm_functions(), ast_unregister_application(), show_voicemail_users_cli, and show_voicemail_zones_cli.

06271 {
06272    int res;
06273    
06274    res = ast_unregister_application(app);
06275    res |= ast_unregister_application(app2);
06276    res |= ast_unregister_application(app3);
06277    res |= ast_unregister_application(app4);
06278    res |= ast_cli_unregister(&show_voicemail_users_cli);
06279    res |= ast_cli_unregister(&show_voicemail_zones_cli);
06280    ast_uninstall_vm_functions();
06281    
06282    STANDARD_HANGUP_LOCALUSERS;
06283 
06284    return res;
06285 }

int usecount void   ) 
 

Provides a usecount.

This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.

Returns:
The module's usecount.

Definition at line 6721 of file app_voicemail.c.

References STANDARD_USECOUNT.

06722 {
06723    int res;
06724    STANDARD_USECOUNT(res);
06725    return res;
06726 }

int vm_authenticate struct ast_channel chan,
char *  mailbox,
int  mailbox_size,
struct ast_vm_user res_vmu,
const char *  context,
const char *  prefix,
int  skipuser,
int  maxlogins,
int  silent
[static]
 

Definition at line 4944 of file app_voicemail.c.

References adsi_begin(), adsi_login(), adsi_password(), ast_log(), ast_play_and_wait(), ast_readstring(), ast_stopstream(), ast_streamfile(), ast_strlen_zero(), ast_verbose(), ast_waitstream(), ast_channel::cid, ast_callerid::cid_num, find_user(), ast_channel::language, LOG_WARNING, option_verbose, ast_vm_user::password, and VERBOSE_PREFIX_3.

Referenced by vm_execmain(), and vmauthenticate().

04947 {
04948    int useadsi=0, valid=0, logretries=0;
04949    char password[AST_MAX_EXTENSION]="", *passptr;
04950    struct ast_vm_user vmus, *vmu = NULL;
04951 
04952    /* If ADSI is supported, setup login screen */
04953    adsi_begin(chan, &useadsi);
04954    if (!skipuser && useadsi)
04955       adsi_login(chan);
04956    if (!silent && !skipuser && ast_streamfile(chan, "vm-login", chan->language)) {
04957       ast_log(LOG_WARNING, "Couldn't stream login file\n");
04958       return -1;
04959    }
04960    
04961    /* Authenticate them and get their mailbox/password */
04962    
04963    while (!valid && (logretries < maxlogins)) {
04964       /* Prompt for, and read in the username */
04965       if (!skipuser && ast_readstring(chan, mailbox, mailbox_size - 1, 2000, 10000, "#") < 0) {
04966          ast_log(LOG_WARNING, "Couldn't read username\n");
04967          return -1;
04968       }
04969       if (ast_strlen_zero(mailbox)) {
04970          if (chan->cid.cid_num) {
04971             ast_copy_string(mailbox, chan->cid.cid_num, mailbox_size);
04972          } else {
04973             if (option_verbose > 2)
04974                ast_verbose(VERBOSE_PREFIX_3 "Username not entered\n");  
04975             return -1;
04976          }
04977       }
04978       if (useadsi)
04979          adsi_password(chan);
04980 
04981       if (!ast_strlen_zero(prefix)) {
04982          char fullusername[80] = "";
04983          ast_copy_string(fullusername, prefix, sizeof(fullusername));
04984          strncat(fullusername, mailbox, sizeof(fullusername) - 1 - strlen(fullusername));
04985          ast_copy_string(mailbox, fullusername, mailbox_size);
04986       }
04987 
04988       vmu = find_user(&vmus, context, mailbox);
04989       if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) {
04990          /* saved password is blank, so don't bother asking */
04991          password[0] = '\0';
04992       } else {
04993          if (ast_streamfile(chan, "vm-password", chan->language)) {
04994             ast_log(LOG_WARNING, "Unable to stream password file\n");
04995             return -1;
04996          }
04997          if (ast_readstring(chan, password, sizeof(password) - 1, 2000, 10000, "#") < 0) {
04998             ast_log(LOG_WARNING, "Unable to read password\n");
04999             return -1;
05000          }
05001       }
05002 
05003       if (vmu) {
05004          passptr = vmu->password;
05005          if (passptr[0] == '-') passptr++;
05006       }
05007       if (vmu && !strcmp(passptr, password))
05008          valid++;
05009       else {
05010          if (option_verbose > 2)
05011             ast_verbose( VERBOSE_PREFIX_3 "Incorrect password '%s' for user '%s' (context = %s)\n", password, mailbox, context ? context : "default");
05012          if (!ast_strlen_zero(prefix))
05013             mailbox[0] = '\0';
05014       }
05015       logretries++;
05016       if (!valid) {
05017          if (skipuser || logretries >= maxlogins) {
05018             if (ast_streamfile(chan, "vm-incorrect", chan->language)) {
05019                ast_log(LOG_WARNING, "Unable to stream incorrect message\n");
05020                return -1;
05021             }
05022          } else {
05023             if (useadsi)
05024                adsi_login(chan);
05025             if (ast_streamfile(chan, "vm-incorrect-mailbox", chan->language)) {
05026                ast_log(LOG_WARNING, "Unable to stream incorrect mailbox message\n");
05027                return -1;
05028             }
05029          }
05030          if (ast_waitstream(chan, "")) /* Channel is hung up */
05031             return -1;
05032       }
05033    }
05034    if (!valid && (logretries >= maxlogins)) {
05035       ast_stopstream(chan);
05036       ast_play_and_wait(chan, "vm-goodbye");
05037       return -1;
05038    }
05039    if (vmu && !skipuser) {
05040       memcpy(res_vmu, vmu, sizeof(struct ast_vm_user));
05041    }
05042    return 0;
05043 }

int vm_box_exists struct ast_channel chan,
void *  data
[static]
 

Definition at line 5613 of file app_voicemail.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_goto_if_exists(), ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_channel::context, ast_channel::exten, find_user(), LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, LOG_WARNING, mbox(), pbx_builtin_setvar_helper(), and ast_channel::priority.

Referenced by load_module().

05614 {
05615    struct localuser *u;
05616    struct ast_vm_user svm;
05617    char *context, *box;
05618    int priority_jump = 0;
05619    AST_DECLARE_APP_ARGS(args,
05620       AST_APP_ARG(mbox);
05621       AST_APP_ARG(options);
05622    );
05623 
05624    if (ast_strlen_zero(data)) {
05625       ast_log(LOG_ERROR, "MailboxExists requires an argument: (vmbox[@context][|options])\n");
05626       return -1;
05627    }
05628 
05629    LOCAL_USER_ADD(u);
05630 
05631    box = ast_strdupa(data);
05632    if (!box) {
05633       ast_log(LOG_ERROR, "Out of memory\n");
05634       LOCAL_USER_REMOVE(u);
05635       return -1;
05636    }
05637 
05638    AST_STANDARD_APP_ARGS(args, box);
05639 
05640    if (args.options) {
05641       if (strchr(args.options, 'j'))
05642          priority_jump = 1;
05643    }
05644 
05645    if ((context = strchr(args.mbox, '@'))) {
05646       *context = '\0';
05647       context++;
05648    }
05649 
05650    if (find_user(&svm, context, args.mbox)) {
05651       pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "SUCCESS");
05652       if (priority_jump || option_priority_jumping)
05653          if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) 
05654             ast_log(LOG_WARNING, "VM box %s@%s exists, but extension %s, priority %d doesn't exist\n", box, context, chan->exten, chan->priority + 101);
05655    } else
05656       pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "FAILED");
05657    LOCAL_USER_REMOVE(u);
05658    return 0;
05659 }

int vm_browse_messages struct ast_channel chan,
struct vm_state vms,
struct ast_vm_user vmu
[static]
 

Definition at line 4929 of file app_voicemail.c.

References ast_channel::language, vm_browse_messages_en(), vm_browse_messages_es(), vm_browse_messages_gr(), vm_browse_messages_it(), and vm_browse_messages_pt().

Referenced by vm_execmain().

04930 {
04931    if (!strcasecmp(chan->language, "es")) {  /* SPANISH */
04932       return vm_browse_messages_es(chan, vms, vmu);
04933    } else if (!strcasecmp(chan->language, "it")) { /* ITALIAN */
04934       return vm_browse_messages_it(chan, vms, vmu);
04935    } else if (!strcasecmp(chan->language, "pt")) { /* PORTUGUESE */
04936       return vm_browse_messages_pt(chan, vms, vmu);
04937    } else if (!strcasecmp(chan->language, "gr")){
04938       return vm_browse_messages_gr(chan, vms, vmu);   /* GREEK */
04939    } else { /* Default to English syntax */
04940       return vm_browse_messages_en(chan, vms, vmu);
04941    }
04942 }

int vm_browse_messages_en struct ast_channel chan,
struct vm_state vms,
struct ast_vm_user vmu
[static]
 

Definition at line 4852 of file app_voicemail.c.

References ast_play_and_wait(), vm_state::curbox, vm_state::fn, vm_state::lastmsg, and play_message().

Referenced by vm_browse_messages().

04853 {
04854    int cmd=0;
04855 
04856    if (vms->lastmsg > -1) {
04857       cmd = play_message(chan, vmu, vms);
04858    } else {
04859       cmd = ast_play_and_wait(chan, "vm-youhave");
04860       if (!cmd) 
04861          cmd = ast_play_and_wait(chan, "vm-no");
04862       if (!cmd) {
04863          snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox);
04864          cmd = ast_play_and_wait(chan, vms->fn);
04865       }
04866       if (!cmd)
04867          cmd = ast_play_and_wait(chan, "vm-messages");
04868    }
04869    return cmd;
04870 }

int vm_browse_messages_es struct ast_channel chan,
struct vm_state vms,
struct ast_vm_user vmu
[static]
 

Definition at line 4892 of file app_voicemail.c.

References ast_play_and_wait(), vm_state::curbox, vm_state::fn, vm_state::lastmsg, and play_message().

Referenced by vm_browse_messages().

04893 {
04894    int cmd=0;
04895 
04896    if (vms->lastmsg > -1) {
04897       cmd = play_message(chan, vmu, vms);
04898    } else {
04899       cmd = ast_play_and_wait(chan, "vm-youhaveno");
04900       if (!cmd)
04901          cmd = ast_play_and_wait(chan, "vm-messages");
04902       if (!cmd) {
04903          snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox);
04904          cmd = ast_play_and_wait(chan, vms->fn);
04905       }
04906    }
04907    return cmd;
04908 }

int vm_browse_messages_gr struct ast_channel chan,
struct vm_state vms,
struct ast_vm_user vmu
[static]
 

Definition at line 4824 of file app_voicemail.c.

References ast_play_and_wait(), vm_state::curbox, vm_state::fn, vm_state::lastmsg, play_message(), and vm_state::vmbox.

Referenced by vm_browse_messages().

04825 {
04826    int cmd=0;
04827 
04828    if (vms->lastmsg > -1) {
04829       cmd = play_message(chan, vmu, vms);
04830    } else {
04831       cmd = ast_play_and_wait(chan, "vm-youhaveno");
04832       if (!strcasecmp(vms->vmbox, "vm-INBOX") ||!strcasecmp(vms->vmbox, "vm-Old")){
04833          if (!cmd) {
04834             snprintf(vms->fn, sizeof(vms->fn), "vm-%ss", vms->curbox);
04835             cmd = ast_play_and_wait(chan, vms->fn);
04836          }
04837          if (!cmd)
04838             cmd = ast_play_and_wait(chan, "vm-messages");
04839       } else {
04840          if (!cmd)
04841             cmd = ast_play_and_wait(chan, "vm-messages");
04842          if (!cmd) {
04843             snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox);
04844             cmd = ast_play_and_wait(chan, vms->fn);
04845          }
04846       }
04847    } 
04848    return cmd;
04849 }

int vm_browse_messages_it struct ast_channel chan,
struct vm_state vms,
struct ast_vm_user vmu
[static]
 

Definition at line 4873 of file app_voicemail.c.

References ast_play_and_wait(), vm_state::curbox, vm_state::fn, vm_state::lastmsg, and play_message().

Referenced by vm_browse_messages().

04874 {
04875         int cmd=0;
04876 
04877         if (vms->lastmsg > -1) {
04878                 cmd = play_message(chan, vmu, vms);
04879         } else {
04880                 cmd = ast_play_and_wait(chan, "vm-no");
04881                 if (!cmd)
04882                         cmd = ast_play_and_wait(chan, "vm-message");
04883                 if (!cmd) {
04884                         snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox);
04885                         cmd = ast_play_and_wait(chan, vms->fn);
04886                 }
04887         }
04888         return cmd;
04889 }

int vm_browse_messages_pt struct ast_channel chan,
struct vm_state vms,
struct ast_vm_user vmu
[static]
 

Definition at line 4911 of file app_voicemail.c.

References ast_play_and_wait(), vm_state::curbox, vm_state::fn, vm_state::lastmsg, and play_message().

Referenced by vm_browse_messages().

04912 {
04913    int cmd=0;
04914 
04915    if (vms->lastmsg > -1) {
04916       cmd = play_message(chan, vmu, vms);
04917    } else {
04918       cmd = ast_play_and_wait(chan, "vm-no");
04919       if (!cmd) {
04920          snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox);
04921          cmd = ast_play_and_wait(chan, vms->fn);
04922       }
04923       if (!cmd)
04924          cmd = ast_play_and_wait(chan, "vm-messages");
04925    }
04926    return cmd;
04927 }

void vm_change_password struct ast_vm_user vmu,
const char *  newpassword
[static]
 

Definition at line 629 of file app_voicemail.c.

References ast_config_AST_CONFIG_DIR, ast_log(), ast_strlen_zero(), change_password_realtime(), ast_vm_user::context, inbuf(), LOG_WARNING, ast_vm_user::mailbox, ast_vm_user::password, and reset_user_pw().

Referenced by vm_newuser(), and vm_options().

00630 {
00631    /*  There's probably a better way of doing this. */
00632    /*  That's why I've put the password change in a separate function. */
00633    /*  This could also be done with a database function */
00634    
00635    FILE *configin;
00636    FILE *configout;
00637    int linenum=0;
00638    char inbuf[256];
00639    char orig[256];
00640    char currcontext[256] ="";
00641    char tmpin[AST_CONFIG_MAX_PATH];
00642    char tmpout[AST_CONFIG_MAX_PATH];
00643    struct stat statbuf;
00644 
00645    if (!change_password_realtime(vmu, newpassword))
00646       return;
00647 
00648    snprintf(tmpin, sizeof(tmpin), "%s/voicemail.conf", ast_config_AST_CONFIG_DIR);
00649    snprintf(tmpout, sizeof(tmpout), "%s/voicemail.conf.new", ast_config_AST_CONFIG_DIR);
00650    configin = fopen(tmpin,"r");
00651    if (configin)
00652       configout = fopen(tmpout,"w+");
00653    else
00654       configout = NULL;
00655    if (!configin || !configout) {
00656       if (configin)
00657          fclose(configin);
00658       else
00659          ast_log(LOG_WARNING, "Warning: Unable to open '%s' for reading: %s\n", tmpin, strerror(errno));
00660       if (configout)
00661          fclose(configout);
00662       else
00663          ast_log(LOG_WARNING, "Warning: Unable to open '%s' for writing: %s\n", tmpout, strerror(errno));
00664          return;
00665    }
00666 
00667    while (!feof(configin)) {
00668       char *user = NULL, *pass = NULL, *rest = NULL, *comment = NULL, *tmpctx = NULL, *tmpctxend = NULL;
00669 
00670       /* Read in the line */
00671       fgets(inbuf, sizeof(inbuf), configin);
00672       linenum++;
00673 
00674       if (ast_strlen_zero(inbuf)) {
00675          fprintf(configout, "\n");
00676          continue;
00677       }
00678 
00679       /* Make a backup of it */
00680       ast_copy_string(orig, inbuf, sizeof(orig));
00681 
00682       /*
00683         Read the file line by line, split each line into a comment and command section
00684         only parse the command portion of the line
00685       */
00686       if (inbuf[strlen(inbuf) - 1] == '\n')
00687          inbuf[strlen(inbuf) - 1] = '\0';
00688 
00689       if ((comment = strchr(inbuf, ';')))
00690          *comment++ = '\0'; /* Now inbuf is terminated just before the comment */
00691 
00692       if (ast_strlen_zero(inbuf)) {
00693          fprintf(configout, "%s", orig);
00694          continue;
00695       }
00696 
00697       /* Check for a context, first '[' to first ']' */
00698       if ((tmpctx = strchr(inbuf, '['))) {
00699          tmpctxend = strchr(tmpctx, ']');
00700          if (tmpctxend) {
00701             /* Valid context */
00702             ast_copy_string(currcontext, tmpctx + 1, tmpctxend - tmpctx);
00703             fprintf(configout, "%s", orig);
00704             continue;
00705          }
00706       }
00707 
00708       /* This isn't a context line, check for MBX => PSWD... */
00709       user = inbuf;
00710       if ((pass = strchr(user, '='))) {
00711          /* We have a line in the form of aaaaa=aaaaaa */
00712          *pass++ = '\0';
00713 
00714          user = ast_strip(user);
00715 
00716          if (*pass == '>')
00717             *pass++ = '\0';
00718 
00719          pass = ast_skip_blanks(pass);
00720 
00721          /* 
00722             Since no whitespace allowed in fields, or more correctly white space
00723             inside the fields is there for a purpose, we can just terminate pass
00724             at the comma or EOL whichever comes first.
00725          */
00726          if ((rest = strchr(pass, ',')))
00727             *rest++ = '\0';
00728       } else {
00729          user = NULL;
00730       }        
00731 
00732       /* Compare user, pass AND context */
00733       if (!ast_strlen_zero(user) && !strcmp(user, vmu->mailbox) &&
00734           !ast_strlen_zero(pass) && !strcmp(pass, vmu->password) &&
00735           !strcasecmp(currcontext, vmu->context)) {
00736          /* This is the line */
00737          if (rest) {
00738             fprintf(configout, "%s => %s,%s", user, newpassword, rest);
00739          } else {
00740             fprintf(configout, "%s => %s", user, newpassword);
00741          }
00742          /* If there was a comment on the line print it out */
00743          if (comment) {
00744             fprintf(configout, ";%s\n", comment);
00745          } else {
00746             fprintf(configout, "\n");
00747          }
00748       } else {
00749          /* Put it back like it was */
00750          fprintf(configout, "%s", orig);
00751       }
00752    }
00753    fclose(configin);
00754    fclose(configout);
00755 
00756    stat(tmpin, &statbuf);
00757    chmod(tmpout, statbuf.st_mode);
00758    chown(tmpout, statbuf.st_uid, statbuf.st_gid);
00759    unlink(tmpin);
00760    rename(tmpout, tmpin);
00761    reset_user_pw(vmu->context, vmu->mailbox, newpassword);
00762    ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
00763 }

void vm_change_password_shell struct ast_vm_user vmu,
char *  newpassword
[static]
 

Definition at line 765 of file app_voicemail.c.

References ast_safe_system(), ast_vm_user::context, ext_pass_cmd, ast_vm_user::mailbox, and ast_vm_user::password.

Referenced by vm_newuser(), and vm_options().

00766 {
00767    char buf[255];
00768    snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->mailbox,newpassword);
00769    if (!ast_safe_system(buf))
00770       ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
00771 }

int vm_delete char *  file  )  [static]
 

Definition at line 1487 of file app_voicemail.c.

References ast_filedelete().

Referenced by play_record_review().

01488 {
01489    char *txt;
01490    int txtsize = 0;
01491 
01492    txtsize = (strlen(file) + 5)*sizeof(char);
01493    txt = (char *)alloca(txtsize);
01494    /* Sprintf here would safe because we alloca'd exactly the right length,
01495     * but trying to eliminate all sprintf's anyhow
01496     */
01497    snprintf(txt, txtsize, "%s.txt", file);
01498    unlink(txt);
01499    return ast_filedelete(file, NULL);
01500 }

int vm_exec struct ast_channel chan,
void *  data
[static]
 

Definition at line 5487 of file app_voicemail.c.

References ast_channel::_state, ast_answer(), ast_app_getdata(), ast_app_parse_options(), ast_app_separate_args(), ast_copy_flags, ast_goto_if_exists(), ast_log(), ast_set_flag, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_channel::context, ast_channel::exten, leave_voicemail(), LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, LOG_WARNING, OPT_ARG_RECORDGAIN, OPT_BUSY_GREETING, OPT_PRIORITY_JUMP, OPT_RECORDGAIN, OPT_SILENT, OPT_UNAVAIL_GREETING, pbx_builtin_setvar_helper(), and ast_channel::priority.

Referenced by load_module(), and play_record_review().

05488 {
05489    int res = 0;
05490    struct localuser *u;
05491    char tmp[256];
05492    struct leave_vm_options leave_options;
05493    int argc;
05494    char *argv[2];
05495    struct ast_flags flags = { 0 };
05496    char *opts[OPT_ARG_ARRAY_SIZE];
05497    
05498    LOCAL_USER_ADD(u);
05499    
05500    memset(&leave_options, 0, sizeof(leave_options));
05501 
05502    if (chan->_state != AST_STATE_UP)
05503       ast_answer(chan);
05504 
05505    if (!ast_strlen_zero(data)) {
05506       ast_copy_string(tmp, data, sizeof(tmp));
05507       argc = ast_app_separate_args(tmp, '|', argv, sizeof(argv) / sizeof(argv[0]));
05508       if (argc == 2) {
05509          if (ast_app_parse_options(vm_app_options, &flags, opts, argv[1])) {
05510             LOCAL_USER_REMOVE(u);
05511             return -1;
05512          }
05513          ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING);
05514          if (ast_test_flag(&flags, OPT_RECORDGAIN)) {
05515             int gain;
05516 
05517             if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
05518                ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
05519                LOCAL_USER_REMOVE(u);
05520                return -1;
05521             } else {
05522                leave_options.record_gain = (signed char) gain;
05523             }
05524          }
05525       } else {
05526          /* old style options parsing */
05527          while (*argv[0]) {
05528             if (*argv[0] == 's') {
05529                ast_set_flag(&leave_options, OPT_SILENT);
05530                argv[0]++;
05531             } else if (*argv[0] == 'b') {
05532                ast_set_flag(&leave_options, OPT_BUSY_GREETING);
05533                argv[0]++;
05534             } else if (*argv[0] == 'u') {
05535                ast_set_flag(&leave_options, OPT_UNAVAIL_GREETING);
05536                argv[0]++;
05537             } else if (*argv[0] == 'j') {
05538                ast_set_flag(&leave_options, OPT_PRIORITY_JUMP);
05539                argv[0]++;
05540             } else 
05541                break;
05542          }
05543       }
05544    } else {
05545       res = ast_app_getdata(chan, "vm-whichbox", tmp, sizeof(tmp) - 1, 0);
05546       if (res < 0) {
05547          LOCAL_USER_REMOVE(u);
05548          return res;
05549       }
05550       if (ast_strlen_zero(tmp)) {
05551          LOCAL_USER_REMOVE(u);
05552          return 0;
05553       }
05554       argv[0] = ast_strdupa(tmp);
05555    }
05556 
05557    res = leave_voicemail(chan, argv[0], &leave_options);
05558 
05559    if (res == ERROR_LOCK_PATH) {
05560       ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n");
05561       /*Send the call to n+101 priority, where n is the current priority*/
05562       if (ast_test_flag(&leave_options, OPT_PRIORITY_JUMP) || option_priority_jumping)
05563          if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
05564             ast_log(LOG_WARNING, "Extension %s, priority %d doesn't exist.\n", chan->exten, chan->priority + 101);
05565       pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
05566       res = 0;
05567    }
05568    
05569    LOCAL_USER_REMOVE(u);
05570 
05571    return res;
05572 }

int vm_execmain struct ast_channel chan,
void *  data
[static]
 

Definition at line 5045 of file app_voicemail.c.

References ast_channel::_state, adsi_begin(), adsi_delete(), adsi_folders(), adsi_goodbye(), adsi_message(), adsi_status(), adsi_status2(), adsi_unload_session(), advanced_options(), ast_answer(), ast_app_parse_options(), ast_app_separate_args(), ast_log(), ast_play_and_wait(), ast_set_flag, ast_stopstream(), ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verbose(), ast_waitfordigit(), ast_vm_user::callback, calloc, close_mailbox(), ast_vm_user::context, create_dirpath(), dialout(), ast_vm_user::dialout, EVENT_FLAG_CALL, find_user(), forward_message(), free, free_user(), get_folder2(), globalflags, has_voicemail(), ast_channel::language, ast_vm_user::language, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_WARNING, ast_vm_user::mailbox, make_file(), manager_event(), maxlogins, ast_vm_user::maxmsg, mbox(), open_mailbox(), OPT_ARG_RECORDGAIN, OPT_PREPEND_MAILBOX, OPT_RECORDGAIN, OPT_SILENT, ast_vm_user::password, play_message(), run_externnotify(), save_to_folder(), say_and_wait(), VERBOSE_PREFIX_3, vm_authenticate(), vm_browse_messages(), VM_FORCEGREET, VM_FORCENAME, vm_instructions(), vm_intro(), vm_newuser(), vm_options(), vm_play_folder_name(), VM_SKIPAFTERCMD, VM_SVMAIL, and vmfmts.

Referenced by load_module().

05046 {
05047    /* XXX This is, admittedly, some pretty horrendus code.  For some
05048       reason it just seemed a lot easier to do with GOTO's.  I feel
05049       like I'm back in my GWBASIC days. XXX */
05050    int res=-1;
05051    int cmd=0;
05052    int valid = 0;
05053    struct localuser *u;
05054    char prefixstr[80] ="";
05055    char ext_context[256]="";
05056    int box;
05057    int useadsi = 0;
05058    int skipuser = 0;
05059    struct vm_state vms;
05060    struct ast_vm_user *vmu = NULL, vmus;
05061    char *context=NULL;
05062    int silentexit = 0;
05063    struct ast_flags flags = { 0 };
05064    signed char record_gain = 0;
05065 
05066    LOCAL_USER_ADD(u);
05067 
05068    memset(&vms, 0, sizeof(vms));
05069    vms.lastmsg = -1;
05070 
05071    memset(&vmus, 0, sizeof(vmus));
05072 
05073    if (chan->_state != AST_STATE_UP)
05074       ast_answer(chan);
05075 
05076    if (!ast_strlen_zero(data)) {
05077       char *tmp;
05078       int argc;
05079       char *argv[2];
05080       char *opts[OPT_ARG_ARRAY_SIZE];
05081 
05082       tmp = ast_strdupa(data);
05083       argc = ast_app_separate_args(tmp, '|', argv, sizeof(argv) / sizeof(argv[0]));
05084       if (argc == 2) {
05085          if (ast_app_parse_options(vm_app_options, &flags, opts, argv[1])) {
05086             LOCAL_USER_REMOVE(u);
05087             return -1;
05088          }
05089          if (ast_test_flag(&flags, OPT_RECORDGAIN)) {
05090             int gain;
05091 
05092             if (sscanf(opts[OPT_ARG_RECORDGAIN], "%d", &gain) != 1) {
05093                ast_log(LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]);
05094                LOCAL_USER_REMOVE(u);
05095                return -1;
05096             } else {
05097                record_gain = (signed char) gain;
05098             }
05099          }
05100       } else {
05101          /* old style options parsing */
05102          while (*argv[0]) {
05103             if (*argv[0] == 's') {
05104                ast_set_flag(&flags, OPT_SILENT);
05105                argv[0]++;
05106             } else if (*argv[0] == 'p') {
05107                ast_set_flag(&flags, OPT_PREPEND_MAILBOX);
05108                argv[0]++;
05109             } else 
05110                break;
05111          }
05112 
05113       }
05114 
05115       valid = ast_test_flag(&flags, OPT_SILENT);
05116 
05117       if ((context = strchr(argv[0], '@')))
05118          *context++ = '\0';
05119 
05120       if (ast_test_flag(&flags, OPT_PREPEND_MAILBOX))
05121          ast_copy_string(prefixstr, argv[0], sizeof(prefixstr));
05122       else
05123          ast_copy_string(vms.username, argv[0], sizeof(vms.username));
05124 
05125       if (!ast_strlen_zero(vms.username) && (vmu = find_user(&vmus, context ,vms.username)))
05126          skipuser++;
05127       else
05128          valid = 0;
05129    }
05130 
05131    if (!valid)
05132       res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
05133 
05134    if (!res) {
05135       valid = 1;
05136       if (!skipuser)
05137          vmu = &vmus;
05138    } else {
05139       res = 0;
05140    }
05141 
05142    /* If ADSI is supported, setup login screen */
05143    adsi_begin(chan, &useadsi);
05144 
05145    if (!valid)
05146       goto out;
05147 
05148    vms.deleted = calloc(vmu->maxmsg, sizeof(int));
05149    vms.heard = calloc(vmu->maxmsg, sizeof(int));
05150    
05151    /* Set language from config to override channel language */
05152    if (!ast_strlen_zero(vmu->language))
05153       ast_copy_string(chan->language, vmu->language, sizeof(chan->language));
05154    create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, "");
05155    /* Retrieve old and new message counts */
05156    res = open_mailbox(&vms, vmu, 1);
05157    if (res == ERROR_LOCK_PATH)
05158       goto out;
05159    vms.oldmessages = vms.lastmsg + 1;
05160    /* Start in INBOX */
05161    res = open_mailbox(&vms, vmu, 0);
05162    if (res == ERROR_LOCK_PATH)
05163       goto out;
05164    vms.newmessages = vms.lastmsg + 1;
05165       
05166    /* Select proper mailbox FIRST!! */
05167    if (!vms.newmessages && vms.oldmessages) {
05168       /* If we only have old messages start here */
05169       res = open_mailbox(&vms, vmu, 1);
05170       if (res == ERROR_LOCK_PATH)
05171          goto out;
05172    }
05173 
05174    if (useadsi)
05175       adsi_status(chan, &vms);
05176    res = 0;
05177 
05178    /* Check to see if this is a new user */
05179    if (!strcasecmp(vmu->mailbox, vmu->password) && 
05180        (ast_test_flag(vmu, VM_FORCENAME | VM_FORCEGREET))) {
05181       if (ast_play_and_wait(chan, "vm-newuser") == -1)
05182          ast_log(LOG_WARNING, "Couldn't stream new user file\n");
05183       cmd = vm_newuser(chan, vmu, &vms, vmfmts, record_gain);
05184       if ((cmd == 't') || (cmd == '#')) {
05185          /* Timeout */
05186          res = 0;
05187          goto out;
05188       } else if (cmd < 0) {
05189          /* Hangup */
05190          res = -1;
05191          goto out;
05192       }
05193    }
05194 
05195    cmd = vm_intro(chan, &vms);
05196 
05197    vms.repeats = 0;
05198    vms.starting = 1;
05199    while ((cmd > -1) && (cmd != 't') && (cmd != '#')) {
05200       /* Run main menu */
05201       switch(cmd) {
05202       case '1':
05203          vms.curmsg = 0;
05204          /* Fall through */
05205       case '5':
05206          cmd = vm_browse_messages(chan, &vms, vmu);
05207          break;
05208       case '2': /* Change folders */
05209          if (useadsi)
05210             adsi_folders(chan, 0, "Change to folder...");
05211          cmd = get_folder2(chan, "vm-changeto", 0);
05212          if (cmd == '#') {
05213             cmd = 0;
05214          } else if (cmd > 0) {
05215             cmd = cmd - '0';
05216             res = close_mailbox(&vms, vmu);
05217             if (res == ERROR_LOCK_PATH)
05218                goto out;
05219             res = open_mailbox(&vms, vmu, cmd);
05220             if (res == ERROR_LOCK_PATH)
05221                goto out;
05222             cmd = 0;
05223          }
05224          if (useadsi)
05225             adsi_status2(chan, &vms);
05226             
05227          if (!cmd)
05228             cmd = vm_play_folder_name(chan, vms.vmbox);
05229 
05230          vms.starting = 1;
05231          break;
05232       case '3': /* Advanced options */
05233          cmd = 0;
05234          vms.repeats = 0;
05235          while ((cmd > -1) && (cmd != 't') && (cmd != '#')) {
05236             switch(cmd) {
05237             case '1': /* Reply */
05238                if (vms.lastmsg > -1) {
05239                   cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 1, record_gain);
05240                   if (cmd == ERROR_LOCK_PATH) {
05241                      res = cmd;
05242                      goto out;
05243                   }
05244                } else
05245                   cmd = ast_play_and_wait(chan, "vm-sorry");
05246                cmd = 't';
05247                break;
05248             case '2': /* Callback */
05249                ast_verbose( VERBOSE_PREFIX_3 "Callback Requested\n");
05250                if (!ast_strlen_zero(vmu->callback) && vms.lastmsg > -1) {
05251                   cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 2, record_gain);
05252                   if (cmd == 9) {
05253                      silentexit = 1;
05254                      goto out;
05255                   } else if (cmd == ERROR_LOCK_PATH) {
05256                      res = cmd;
05257                      goto out;
05258                   }
05259                }
05260                else 
05261                   cmd = ast_play_and_wait(chan, "vm-sorry");
05262                cmd = 't';
05263                break;
05264             case '3': /* Envelope */
05265                if (vms.lastmsg > -1) {
05266                   cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 3, record_gain);
05267                   if (cmd == ERROR_LOCK_PATH) {
05268                      res = cmd;
05269                      goto out;
05270                   }
05271                } else
05272                   cmd = ast_play_and_wait(chan, "vm-sorry");
05273                cmd = 't';
05274                break;
05275             case '4': /* Dialout */
05276                if (!ast_strlen_zero(vmu->dialout)) {
05277                   cmd = dialout(chan, vmu, NULL, vmu->dialout);
05278                   if (cmd == 9) {
05279                      silentexit = 1;
05280                      goto out;
05281                   }
05282                }
05283                else 
05284                   cmd = ast_play_and_wait(chan, "vm-sorry");
05285                cmd = 't';
05286                break;
05287 
05288             case '5': /* Leave VoiceMail */
05289                if (ast_test_flag(vmu, VM_SVMAIL)) {
05290                   cmd = forward_message(chan, context, vms.curdir, vms.curmsg, vmu, vmfmts, 1, record_gain);
05291                   if (cmd == ERROR_LOCK_PATH) {
05292                      res = cmd;
05293                      goto out;
05294                   }
05295                } else
05296                   cmd = ast_play_and_wait(chan,"vm-sorry");
05297                cmd='t';
05298                break;
05299                
05300             case '*': /* Return to main menu */
05301                cmd = 't';
05302                break;
05303 
05304             default:
05305                cmd = 0;
05306                if (!vms.starting) {
05307                   cmd = ast_play_and_wait(chan, "vm-toreply");
05308                }
05309                if (!ast_strlen_zero(vmu->callback) && !vms.starting && !cmd) {
05310                   cmd = ast_play_and_wait(chan, "vm-tocallback");
05311                }
05312                if (!cmd && !vms.starting) {
05313                   cmd = ast_play_and_wait(chan, "vm-tohearenv");
05314                }
05315                if (!ast_strlen_zero(vmu->dialout) && !cmd) {
05316                   cmd = ast_play_and_wait(chan, "vm-tomakecall");
05317                }
05318                if (ast_test_flag(vmu, VM_SVMAIL) && !cmd)
05319                   cmd=ast_play_and_wait(chan, "vm-leavemsg");
05320                if (!cmd)
05321                   cmd = ast_play_and_wait(chan, "vm-starmain");
05322                if (!cmd)
05323                   cmd = ast_waitfordigit(chan,6000);
05324                if (!cmd)
05325                   vms.repeats++;
05326                if (vms.repeats > 3)
05327                   cmd = 't';
05328             }
05329          }
05330          if (cmd == 't') {
05331             cmd = 0;
05332             vms.repeats = 0;
05333          }
05334          break;
05335       case '4':
05336          if (vms.curmsg) {
05337             vms.curmsg--;
05338             cmd = play_message(chan, vmu, &vms);
05339          } else {
05340             cmd = ast_play_and_wait(chan, "vm-nomore");
05341          }
05342          break;
05343       case '6':
05344          if (vms.curmsg < vms.lastmsg) {
05345             vms.curmsg++;
05346             cmd = play_message(chan, vmu, &vms);
05347          } else {
05348             cmd = ast_play_and_wait(chan, "vm-nomore");
05349          }
05350          break;
05351       case '7':
05352          vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
05353          if (useadsi)
05354             adsi_delete(chan, &vms);
05355          if (vms.deleted[vms.curmsg]) 
05356             cmd = ast_play_and_wait(chan, "vm-deleted");
05357          else
05358             cmd = ast_play_and_wait(chan, "vm-undeleted");
05359          if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
05360             if (vms.curmsg < vms.lastmsg) {
05361                vms.curmsg++;
05362                cmd = play_message(chan, vmu, &vms);
05363             } else {
05364                cmd = ast_play_and_wait(chan, "vm-nomore");
05365             }
05366          }
05367          break;
05368    
05369       case '8':
05370          if (vms.lastmsg > -1) {
05371             cmd = forward_message(chan, context, vms.curdir, vms.curmsg, vmu, vmfmts, 0, record_gain);
05372             if (cmd == ERROR_LOCK_PATH) {
05373                res = cmd;
05374                goto out;
05375             }
05376          } else
05377             cmd = ast_play_and_wait(chan, "vm-nomore");
05378          break;
05379       case '9':
05380          if (useadsi)
05381             adsi_folders(chan, 1, "Save to folder...");
05382          cmd = get_folder2(chan, "vm-savefolder", 1);
05383          box = 0; /* Shut up compiler */
05384          if (cmd == '#') {
05385             cmd = 0;
05386             break;
05387          } else if (cmd > 0) {
05388             box = cmd = cmd - '0';
05389             cmd = save_to_folder(vmu, vms.curdir, vms.curmsg, vmu->context, vms.username, cmd);
05390             if (cmd == ERROR_LOCK_PATH) {
05391                res = cmd;
05392                goto out;
05393             } else if (!cmd) {
05394                vms.deleted[vms.curmsg] = 1;
05395             } else {
05396                vms.deleted[vms.curmsg] = 0;
05397                vms.heard[vms.curmsg] = 0;
05398             }
05399          }
05400          make_file(vms.fn, sizeof(vms.fn), vms.curdir, vms.curmsg);
05401          if (useadsi)
05402             adsi_message(chan, &vms);
05403          snprintf(vms.fn, sizeof(vms.fn), "vm-%s", mbox(box));
05404          if (!cmd) {
05405             cmd = ast_play_and_wait(chan, "vm-message");
05406             if (!cmd)
05407                cmd = say_and_wait(chan, vms.curmsg + 1, chan->language);
05408             if (!cmd)
05409                cmd = ast_play_and_wait(chan, "vm-savedto");
05410             if (!cmd)
05411                cmd = vm_play_folder_name(chan, vms.fn);
05412          } else {
05413             cmd = ast_play_and_wait(chan, "vm-mailboxfull");
05414          }
05415          if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
05416             if (vms.curmsg < vms.lastmsg) {
05417                vms.curmsg++;
05418                cmd = play_message(chan, vmu, &vms);
05419             } else {
05420                cmd = ast_play_and_wait(chan, "vm-nomore");
05421             }
05422          }
05423          break;
05424       case '*':
05425          if (!vms.starting) {
05426             cmd = ast_play_and_wait(chan, "vm-onefor");
05427             if (!cmd)
05428                cmd = vm_play_folder_name(chan, vms.vmbox);
05429             if (!cmd)
05430                cmd = ast_play_and_wait(chan, "vm-opts");
05431             if (!cmd)
05432                cmd = vm_instructions(chan, &vms, 1);
05433          } else
05434             cmd = 0;
05435          break;
05436       case '0':
05437          cmd = vm_options(chan, vmu, &vms, vmfmts, record_gain);
05438          if (useadsi)
05439             adsi_status(chan, &vms);
05440          break;
05441       default: /* Nothing */
05442          cmd = vm_instructions(chan, &vms, 0);
05443          break;
05444       }
05445    }
05446    if ((cmd == 't') || (cmd == '#')) {
05447       /* Timeout */
05448       res = 0;
05449    } else {
05450       /* Hangup */
05451       res = -1;
05452    }
05453 
05454 out:
05455    if (res > -1) {
05456       ast_stopstream(chan);
05457       adsi_goodbye(chan);
05458       if (valid) {
05459          if (silentexit)
05460             res = ast_play_and_wait(chan, "vm-dialout");
05461          else 
05462             res = ast_play_and_wait(chan, "vm-goodbye");
05463          if (res > 0)
05464             res = 0;
05465       }
05466       if (useadsi)
05467          adsi_unload_session(chan);
05468    }
05469    if (vmu)
05470       close_mailbox(&vms, vmu);
05471    if (valid) {
05472       snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context);
05473       manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL));
05474       run_externnotify(vmu->context, vmu->mailbox);
05475    }
05476    if (vmu)
05477       free_user(vmu);
05478    if (vms.deleted)
05479       free(vms.deleted);
05480    if (vms.heard)
05481       free(vms.heard);
05482    LOCAL_USER_REMOVE(u);
05483 
05484    return res;
05485 }

int vm_forwardoptions struct ast_channel chan,
struct ast_vm_user vmu,
char *  curdir,
int  curmsg,
char *  vmfts,
char *  context,
signed char  record_gain
[static]
 

Definition at line 3253 of file app_voicemail.c.

References ast_channel_setoption(), AST_OPTION_RXGAIN, ast_play_and_prepend(), ast_play_and_wait(), ast_waitfordigit(), maxsilence, silencethreshold, and vmfmts.

Referenced by forward_message().

03255 {
03256    int cmd = 0;
03257    int retries = 0;
03258    int duration = 0;
03259    signed char zero_gain = 0;
03260 
03261    while ((cmd >= 0) && (cmd != 't') && (cmd != '*')) {
03262       if (cmd)
03263          retries = 0;
03264       switch (cmd) {
03265       case '1': 
03266          /* prepend a message to the current message and return */
03267       {
03268          char file[200];
03269          snprintf(file, sizeof(file), "%s/msg%04d", curdir, curmsg);
03270          if (record_gain)
03271             ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
03272          cmd = ast_play_and_prepend(chan, NULL, file, 0, vmfmts, &duration, 1, silencethreshold, maxsilence);
03273          if (record_gain)
03274             ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
03275          break;
03276       }
03277       case '2': 
03278          cmd = 't';
03279          break;
03280       case '*':
03281          cmd = '*';
03282          break;
03283       default: 
03284          cmd = ast_play_and_wait(chan,"vm-forwardoptions");
03285             /* "Press 1 to prepend a message or 2 to forward the message without prepending" */
03286          if (!cmd)
03287             cmd = ast_play_and_wait(chan,"vm-starmain");
03288             /* "press star to return to the main menu" */
03289          if (!cmd)
03290             cmd = ast_waitfordigit(chan,6000);
03291          if (!cmd)
03292             retries++;
03293          if (retries > 3)
03294             cmd = 't';
03295        }
03296    }
03297    if (cmd == 't')
03298       cmd = 0;
03299    return cmd;
03300 }

int vm_instructions struct ast_channel chan,
struct vm_state vms,
int  skipadvanced
[static]
 

Definition at line 4540 of file app_voicemail.c.

References ast_play_and_wait(), ast_waitfordigit(), vm_state::curmsg, vm_state::deleted, vm_state::lastmsg, vm_state::repeats, vm_state::starting, vm_play_folder_name(), and vm_state::vmbox.

Referenced by vm_execmain().

04541 {
04542    int res = 0;
04543    /* Play instructions and wait for new command */
04544    while (!res) {
04545       if (vms->starting) {
04546          if (vms->lastmsg > -1) {
04547             res = ast_play_and_wait(chan, "vm-onefor");
04548             if (!res)
04549                res = vm_play_folder_name(chan, vms->vmbox);
04550          }
04551          if (!res)
04552             res = ast_play_and_wait(chan, "vm-opts");
04553       } else {
04554          if (vms->curmsg)
04555             res = ast_play_and_wait(chan, "vm-prev");
04556          if (!res && !skipadvanced)
04557             res = ast_play_and_wait(chan, "vm-advopts");
04558          if (!res)
04559             res = ast_play_and_wait(chan, "vm-repeat");
04560          if (!res && (vms->curmsg != vms->lastmsg))
04561             res = ast_play_and_wait(chan, "vm-next");
04562          if (!res) {
04563             if (!vms->deleted[vms->curmsg])
04564                res = ast_play_and_wait(chan, "vm-delete");
04565             else
04566                res = ast_play_and_wait(chan, "vm-undelete");
04567             if (!res)
04568                res = ast_play_and_wait(chan, "vm-toforward");
04569             if (!res)
04570                res = ast_play_and_wait(chan, "vm-savemessage");
04571          }
04572       }
04573       if (!res)
04574          res = ast_play_and_wait(chan, "vm-helpexit");
04575       if (!res)
04576          res = ast_waitfordigit(chan, 6000);
04577       if (!res) {
04578          vms->repeats++;
04579          if (vms->repeats > 2) {
04580             res = 't';
04581          }
04582       }
04583    }
04584    return res;
04585 }

int vm_intro struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4512 of file app_voicemail.c.

References ast_channel::language, vm_intro_cz(), vm_intro_de(), vm_intro_en(), vm_intro_es(), vm_intro_fr(), vm_intro_gr(), vm_intro_it(), vm_intro_nl(), vm_intro_no(), vm_intro_pt(), and vm_intro_se().

Referenced by vm_execmain().

04513 {
04514    /* Play voicemail intro - syntax is different for different languages */
04515    if (!strcasecmp(chan->language, "de")) {  /* GERMAN syntax */
04516       return vm_intro_de(chan, vms);
04517    } else if (!strcasecmp(chan->language, "es")) { /* SPANISH syntax */
04518       return vm_intro_es(chan, vms);
04519    } else if (!strcasecmp(chan->language, "it")) { /* ITALIAN syntax */
04520       return vm_intro_it(chan, vms);
04521    } else if (!strcasecmp(chan->language, "fr")) { /* FRENCH syntax */
04522       return vm_intro_fr(chan, vms);
04523    } else if (!strcasecmp(chan->language, "nl")) { /* DUTCH syntax */
04524       return vm_intro_nl(chan, vms);
04525    } else if (!strcasecmp(chan->language, "pt")) { /* PORTUGUESE syntax */
04526       return vm_intro_pt(chan, vms);
04527    } else if (!strcasecmp(chan->language, "cz")) { /* CZECH syntax */
04528       return vm_intro_cz(chan, vms);
04529    } else if (!strcasecmp(chan->language, "gr")) { /* GREEK syntax */
04530       return vm_intro_gr(chan, vms);
04531    } else if (!strcasecmp(chan->language, "se")) { /* SWEDISH syntax */
04532       return vm_intro_se(chan, vms);
04533    } else if (!strcasecmp(chan->language, "no")) { /* NORWEGIAN syntax */
04534       return vm_intro_no(chan, vms);
04535    } else {             /* Default to ENGLISH */
04536       return vm_intro_en(chan, vms);
04537    }
04538 }

int vm_intro_cz struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4452 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04453 {
04454    int res;
04455    res = ast_play_and_wait(chan, "vm-youhave");
04456    if (!res) {
04457       if (vms->newmessages) {
04458          if (vms->newmessages == 1) {
04459             res = ast_play_and_wait(chan, "digits/jednu");
04460          } else {
04461             res = say_and_wait(chan, vms->newmessages, chan->language);
04462          }
04463          if (!res) {
04464             if ((vms->newmessages == 1))
04465                res = ast_play_and_wait(chan, "vm-novou");
04466             if ((vms->newmessages) > 1 && (vms->newmessages < 5))
04467                res = ast_play_and_wait(chan, "vm-nove");
04468             if (vms->newmessages > 4)
04469                res = ast_play_and_wait(chan, "vm-novych");
04470          }
04471          if (vms->oldmessages && !res)
04472             res = ast_play_and_wait(chan, "vm-and");
04473          else if (!res) {
04474             if ((vms->newmessages == 1))
04475                res = ast_play_and_wait(chan, "vm-zpravu");
04476             if ((vms->newmessages) > 1 && (vms->newmessages < 5))
04477                res = ast_play_and_wait(chan, "vm-zpravy");
04478             if (vms->newmessages > 4)
04479                res = ast_play_and_wait(chan, "vm-zprav");
04480          }
04481       }
04482       if (!res && vms->oldmessages) {
04483          res = say_and_wait(chan, vms->oldmessages, chan->language);
04484          if (!res) {
04485             if ((vms->oldmessages == 1))
04486                res = ast_play_and_wait(chan, "vm-starou");
04487             if ((vms->oldmessages) > 1 && (vms->oldmessages < 5))
04488                res = ast_play_and_wait(chan, "vm-stare");
04489             if (vms->oldmessages > 4)
04490                res = ast_play_and_wait(chan, "vm-starych");
04491          }
04492          if (!res) {
04493             if ((vms->oldmessages == 1))
04494                res = ast_play_and_wait(chan, "vm-zpravu");
04495             if ((vms->oldmessages) > 1 && (vms->oldmessages < 5))
04496                res = ast_play_and_wait(chan, "vm-zpravy");
04497             if (vms->oldmessages > 4)
04498                res = ast_play_and_wait(chan, "vm-zprav");
04499          }
04500       }
04501       if (!res) {
04502          if (!vms->oldmessages && !vms->newmessages) {
04503             res = ast_play_and_wait(chan, "vm-no");
04504             if (!res)
04505                res = ast_play_and_wait(chan, "vm-zpravy");
04506          }
04507       }
04508    }
04509    return res;
04510 }

int vm_intro_de struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4193 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04194 {
04195    /* Introduce messages they have */
04196    int res;
04197    res = ast_play_and_wait(chan, "vm-youhave");
04198    if (!res) {
04199       if (vms->newmessages) {
04200          if ((vms->newmessages == 1))
04201             res = ast_play_and_wait(chan, "digits/1F");
04202          else
04203             res = say_and_wait(chan, vms->newmessages, chan->language);
04204          if (!res)
04205             res = ast_play_and_wait(chan, "vm-INBOX");
04206          if (vms->oldmessages && !res)
04207             res = ast_play_and_wait(chan, "vm-and");
04208          else if (!res) {
04209             if ((vms->newmessages == 1))
04210                res = ast_play_and_wait(chan, "vm-message");
04211             else
04212                res = ast_play_and_wait(chan, "vm-messages");
04213          }
04214             
04215       }
04216       if (!res && vms->oldmessages) {
04217          if (vms->oldmessages == 1)
04218             res = ast_play_and_wait(chan, "digits/1F");
04219          else
04220             res = say_and_wait(chan, vms->oldmessages, chan->language);
04221          if (!res)
04222             res = ast_play_and_wait(chan, "vm-Old");
04223          if (!res) {
04224             if (vms->oldmessages == 1)
04225                res = ast_play_and_wait(chan, "vm-message");
04226             else
04227                res = ast_play_and_wait(chan, "vm-messages");
04228          }
04229       }
04230       if (!res) {
04231          if (!vms->oldmessages && !vms->newmessages) {
04232             res = ast_play_and_wait(chan, "vm-no");
04233             if (!res)
04234                res = ast_play_and_wait(chan, "vm-messages");
04235          }
04236       }
04237    }
04238    return res;
04239 }

int vm_intro_en struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4027 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04028 {
04029    /* Introduce messages they have */
04030    int res;
04031    res = ast_play_and_wait(chan, "vm-youhave");
04032    if (!res) {
04033       if (vms->newmessages) {
04034          res = say_and_wait(chan, vms->newmessages, chan->language);
04035          if (!res)
04036             res = ast_play_and_wait(chan, "vm-INBOX");
04037          if (vms->oldmessages && !res)
04038             res = ast_play_and_wait(chan, "vm-and");
04039          else if (!res) {
04040             if ((vms->newmessages == 1))
04041                res = ast_play_and_wait(chan, "vm-message");
04042             else
04043                res = ast_play_and_wait(chan, "vm-messages");
04044          }
04045             
04046       }
04047       if (!res && vms->oldmessages) {
04048          res = say_and_wait(chan, vms->oldmessages, chan->language);
04049          if (!res)
04050             res = ast_play_and_wait(chan, "vm-Old");
04051          if (!res) {
04052             if (vms->oldmessages == 1)
04053                res = ast_play_and_wait(chan, "vm-message");
04054             else
04055                res = ast_play_and_wait(chan, "vm-messages");
04056          }
04057       }
04058       if (!res) {
04059          if (!vms->oldmessages && !vms->newmessages) {
04060             res = ast_play_and_wait(chan, "vm-no");
04061             if (!res)
04062                res = ast_play_and_wait(chan, "vm-messages");
04063          }
04064       }
04065    }
04066    return res;
04067 }

int vm_intro_es struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4242 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04243 {
04244    /* Introduce messages they have */
04245    int res;
04246    if (!vms->oldmessages && !vms->newmessages) {
04247       res = ast_play_and_wait(chan, "vm-youhaveno");
04248       if (!res)
04249          res = ast_play_and_wait(chan, "vm-messages");
04250    } else {
04251       res = ast_play_and_wait(chan, "vm-youhave");
04252    }
04253    if (!res) {
04254       if (vms->newmessages) {
04255          if (!res) {
04256             if ((vms->newmessages == 1)) {
04257                res = ast_play_and_wait(chan, "digits/1M");
04258                if (!res)
04259                   res = ast_play_and_wait(chan, "vm-message");
04260                if (!res)
04261                   res = ast_play_and_wait(chan, "vm-INBOXs");
04262             } else {
04263                res = say_and_wait(chan, vms->newmessages, chan->language);
04264                if (!res)
04265                   res = ast_play_and_wait(chan, "vm-messages");
04266                if (!res)
04267                   res = ast_play_and_wait(chan, "vm-INBOX");
04268             }
04269          }
04270          if (vms->oldmessages && !res)
04271             res = ast_play_and_wait(chan, "vm-and");
04272       }
04273       if (vms->oldmessages) {
04274          if (!res) {
04275             if (vms->oldmessages == 1) {
04276                res = ast_play_and_wait(chan, "digits/1M");
04277                if (!res)
04278                   res = ast_play_and_wait(chan, "vm-message");
04279                if (!res)
04280                   res = ast_play_and_wait(chan, "vm-Olds");
04281             } else {
04282                res = say_and_wait(chan, vms->oldmessages, chan->language);
04283                if (!res)
04284                   res = ast_play_and_wait(chan, "vm-messages");
04285                if (!res)
04286                   res = ast_play_and_wait(chan, "vm-Old");
04287             }
04288          }
04289       }
04290    }
04291 return res;
04292 }

int vm_intro_fr struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4295 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04296 {
04297    /* Introduce messages they have */
04298    int res;
04299    res = ast_play_and_wait(chan, "vm-youhave");
04300    if (!res) {
04301       if (vms->newmessages) {
04302          res = say_and_wait(chan, vms->newmessages, chan->language);
04303          if (!res)
04304             res = ast_play_and_wait(chan, "vm-INBOX");
04305          if (vms->oldmessages && !res)
04306             res = ast_play_and_wait(chan, "vm-and");
04307          else if (!res) {
04308             if ((vms->newmessages == 1))
04309                res = ast_play_and_wait(chan, "vm-message");
04310             else
04311                res = ast_play_and_wait(chan, "vm-messages");
04312          }
04313             
04314       }
04315       if (!res && vms->oldmessages) {
04316          res = say_and_wait(chan, vms->oldmessages, chan->language);
04317          if (!res) {
04318             if (vms->oldmessages == 1)
04319                res = ast_play_and_wait(chan, "vm-message");
04320             else
04321                res = ast_play_and_wait(chan, "vm-messages");
04322          }
04323          if (!res)
04324             res = ast_play_and_wait(chan, "vm-Old");
04325       }
04326       if (!res) {
04327          if (!vms->oldmessages && !vms->newmessages) {
04328             res = ast_play_and_wait(chan, "vm-no");
04329             if (!res)
04330                res = ast_play_and_wait(chan, "vm-messages");
04331          }
04332       }
04333    }
04334    return res;
04335 }

int vm_intro_gr struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 3989 of file app_voicemail.c.

References AST_DIGIT_ANY, ast_play_and_wait(), ast_say_number(), ast_channel::language, vm_state::newmessages, and vm_state::oldmessages.

Referenced by vm_intro().

03990 {
03991    int res = 0;
03992 
03993    if (vms->newmessages) {
03994       res = ast_play_and_wait(chan, "vm-youhave");
03995       if (!res) 
03996          res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, NULL);
03997       if (!res) {
03998          if ((vms->newmessages == 1)) {
03999             res = ast_play_and_wait(chan, "vm-INBOX");
04000             if (!res)
04001                res = ast_play_and_wait(chan, "vm-message");
04002          } else {
04003             res = ast_play_and_wait(chan, "vm-INBOXs");
04004             if (!res)
04005                res = ast_play_and_wait(chan, "vm-messages");
04006          }
04007       }    
04008    } else if (vms->oldmessages){
04009       res = ast_play_and_wait(chan, "vm-youhave");
04010       if (!res)
04011          res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, NULL);
04012       if ((vms->oldmessages == 1)){
04013          res = ast_play_and_wait(chan, "vm-Old");
04014          if (!res)
04015             res = ast_play_and_wait(chan, "vm-message");
04016       } else {
04017          res = ast_play_and_wait(chan, "vm-Olds");
04018          if (!res)
04019             res = ast_play_and_wait(chan, "vm-messages");
04020       }
04021     } else if (!vms->oldmessages && !vms->newmessages) 
04022          res = ast_play_and_wait(chan, "vm-denExeteMynhmata"); 
04023     return res;
04024 }

int vm_intro_it struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4070 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04071 {
04072    /* Introduce messages they have */
04073    int res;
04074    if (!vms->oldmessages && !vms->newmessages)
04075       res = ast_play_and_wait(chan, "vm-no") ||
04076          ast_play_and_wait(chan, "vm-message");
04077    else
04078       res = ast_play_and_wait(chan, "vm-youhave");
04079    if (!res && vms->newmessages) {
04080       res = (vms->newmessages == 1) ?
04081          ast_play_and_wait(chan, "digits/un") ||
04082          ast_play_and_wait(chan, "vm-nuovo") ||
04083          ast_play_and_wait(chan, "vm-message") :
04084          /* 2 or more new messages */
04085          say_and_wait(chan, vms->newmessages, chan->language) ||
04086          ast_play_and_wait(chan, "vm-nuovi") ||
04087          ast_play_and_wait(chan, "vm-messages");
04088       if (!res && vms->oldmessages)
04089          res = ast_play_and_wait(chan, "vm-and");
04090    }
04091    if (!res && vms->oldmessages) {
04092       res = (vms->oldmessages == 1) ?
04093          ast_play_and_wait(chan, "digits/un") ||
04094          ast_play_and_wait(chan, "vm-vecchio") ||
04095          ast_play_and_wait(chan, "vm-message") :
04096          /* 2 or more old messages */
04097          say_and_wait(chan, vms->oldmessages, chan->language) ||
04098          ast_play_and_wait(chan, "vm-vecchi") ||
04099          ast_play_and_wait(chan, "vm-messages");
04100    }
04101    return res ? -1 : 0;
04102 }

int vm_intro_nl struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4338 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04339 {
04340    /* Introduce messages they have */
04341    int res;
04342    res = ast_play_and_wait(chan, "vm-youhave");
04343    if (!res) {
04344       if (vms->newmessages) {
04345          res = say_and_wait(chan, vms->newmessages, chan->language);
04346          if (!res) {
04347             if (vms->oldmessages == 1)
04348                res = ast_play_and_wait(chan, "vm-INBOXs");
04349             else
04350                res = ast_play_and_wait(chan, "vm-INBOX");
04351          }
04352          if (vms->oldmessages && !res)
04353             res = ast_play_and_wait(chan, "vm-and");
04354          else if (!res) {
04355             if ((vms->newmessages == 1))
04356                res = ast_play_and_wait(chan, "vm-message");
04357             else
04358                res = ast_play_and_wait(chan, "vm-messages");
04359          }
04360             
04361       }
04362       if (!res && vms->oldmessages) {
04363          res = say_and_wait(chan, vms->oldmessages, chan->language);
04364          if (!res) {
04365             if (vms->oldmessages == 1)
04366                res = ast_play_and_wait(chan, "vm-Olds");
04367             else
04368                res = ast_play_and_wait(chan, "vm-Old");
04369          }
04370          if (!res) {
04371             if (vms->oldmessages == 1)
04372                res = ast_play_and_wait(chan, "vm-message");
04373             else
04374                res = ast_play_and_wait(chan, "vm-messages");
04375          }
04376       }
04377       if (!res) {
04378          if (!vms->oldmessages && !vms->newmessages) {
04379             res = ast_play_and_wait(chan, "vm-no");
04380             if (!res)
04381                res = ast_play_and_wait(chan, "vm-messages");
04382          }
04383       }
04384    }
04385    return res;
04386 }

int vm_intro_no struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4149 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04150 {
04151         /* Introduce messages they have */
04152         int res;
04153 
04154    res = ast_play_and_wait(chan, "vm-youhave");
04155    if (res)
04156       return res;
04157 
04158         if (!vms->oldmessages && !vms->newmessages) {
04159       res = ast_play_and_wait(chan, "vm-no");
04160       res = res ? res : ast_play_and_wait(chan, "vm-messages");
04161       return res;
04162         }
04163 
04164    if (vms->newmessages) {
04165       if ((vms->newmessages == 1)) {
04166          res = ast_play_and_wait(chan, "digits/1");
04167          res = res ? res : ast_play_and_wait(chan, "vm-ny");
04168          res = res ? res : ast_play_and_wait(chan, "vm-message");
04169       } else {
04170          res = say_and_wait(chan, vms->newmessages, chan->language);
04171          res = res ? res : ast_play_and_wait(chan, "vm-nye");
04172          res = res ? res : ast_play_and_wait(chan, "vm-messages");
04173       }
04174       if (!res && vms->oldmessages)
04175          res = ast_play_and_wait(chan, "vm-and");
04176    }
04177    if (!res && vms->oldmessages) {
04178       if (vms->oldmessages == 1) {
04179          res = ast_play_and_wait(chan, "digits/1");
04180          res = res ? res : ast_play_and_wait(chan, "vm-gamel");
04181          res = res ? res : ast_play_and_wait(chan, "vm-message");
04182       } else {
04183          res = say_and_wait(chan, vms->oldmessages, chan->language);
04184          res = res ? res : ast_play_and_wait(chan, "vm-gamle");
04185          res = res ? res : ast_play_and_wait(chan, "vm-messages");
04186       }
04187    }
04188 
04189    return res;
04190 }

int vm_intro_pt struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4389 of file app_voicemail.c.

References AST_DIGIT_ANY, ast_play_and_wait(), ast_say_number(), ast_channel::language, vm_state::newmessages, and vm_state::oldmessages.

Referenced by vm_intro().

04390 {
04391    /* Introduce messages they have */
04392    int res;
04393    res = ast_play_and_wait(chan, "vm-youhave");
04394    if (!res) {
04395       if (vms->newmessages) {
04396          res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, "f");
04397          if (!res) {
04398             if ((vms->newmessages == 1)) {
04399                res = ast_play_and_wait(chan, "vm-message");
04400                if (!res)
04401                   res = ast_play_and_wait(chan, "vm-INBOXs");
04402             } else {
04403                res = ast_play_and_wait(chan, "vm-messages");
04404                if (!res)
04405                   res = ast_play_and_wait(chan, "vm-INBOX");
04406             }
04407          }
04408          if (vms->oldmessages && !res)
04409             res = ast_play_and_wait(chan, "vm-and");
04410       }
04411       if (!res && vms->oldmessages) {
04412          res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f");
04413          if (!res) {
04414             if (vms->oldmessages == 1) {
04415                res = ast_play_and_wait(chan, "vm-message");
04416                if (!res)
04417                   res = ast_play_and_wait(chan, "vm-Olds");
04418             } else {
04419                res = ast_play_and_wait(chan, "vm-messages");
04420                if (!res)
04421                   res = ast_play_and_wait(chan, "vm-Old");
04422             }
04423          }
04424       }
04425       if (!res) {
04426          if (!vms->oldmessages && !vms->newmessages) {
04427             res = ast_play_and_wait(chan, "vm-no");
04428             if (!res)
04429                res = ast_play_and_wait(chan, "vm-messages");
04430          }
04431       }
04432    }
04433    return res;
04434 }

int vm_intro_se struct ast_channel chan,
struct vm_state vms
[static]
 

Definition at line 4105 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and say_and_wait().

Referenced by vm_intro().

04106 {
04107         /* Introduce messages they have */
04108         int res;
04109 
04110    res = ast_play_and_wait(chan, "vm-youhave");
04111    if (res)
04112       return res;
04113 
04114         if (!vms->oldmessages && !vms->newmessages) {
04115       res = ast_play_and_wait(chan, "vm-no");
04116       res = res ? res : ast_play_and_wait(chan, "vm-messages");
04117       return res;
04118         }
04119 
04120    if (vms->newmessages) {
04121       if ((vms->newmessages == 1)) {
04122          res = ast_play_and_wait(chan, "digits/ett");
04123          res = res ? res : ast_play_and_wait(chan, "vm-nytt");
04124          res = res ? res : ast_play_and_wait(chan, "vm-message");
04125       } else {
04126          res = say_and_wait(chan, vms->newmessages, chan->language);
04127          res = res ? res : ast_play_and_wait(chan, "vm-nya");
04128          res = res ? res : ast_play_and_wait(chan, "vm-messages");
04129       }
04130       if (!res && vms->oldmessages)
04131          res = ast_play_and_wait(chan, "vm-and");
04132    }
04133    if (!res && vms->oldmessages) {
04134       if (vms->oldmessages == 1) {
04135          res = ast_play_and_wait(chan, "digits/ett");
04136          res = res ? res : ast_play_and_wait(chan, "vm-gammalt");
04137          res = res ? res : ast_play_and_wait(chan, "vm-message");
04138       } else {
04139          res = say_and_wait(chan, vms->oldmessages, chan->language);
04140          res = res ? res : ast_play_and_wait(chan, "vm-gamla");
04141          res = res ? res : ast_play_and_wait(chan, "vm-messages");
04142       }
04143    }
04144 
04145    return res;
04146 }

int vm_lock_path const char *  path  )  [static]
 

Definition at line 821 of file app_voicemail.c.

References ast_lock_path(), and AST_LOCK_TIMEOUT.

Referenced by close_mailbox(), copy_message(), count_messages(), last_message_index(), leave_voicemail(), resequence_mailbox(), and save_to_folder().

00822 {
00823    switch (ast_lock_path(path)) {
00824    case AST_LOCK_TIMEOUT:
00825       return -1;
00826    default:
00827       return 0;
00828    }
00829 }

int vm_newuser struct ast_channel chan,
struct ast_vm_user vmu,
struct vm_state vms,
char *  fmtc,
signed char  record_gain
[static]
 

Definition at line 4587 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_CENT, adsi_logo(), ADSI_MSG_DISPLAY, adsi_set_line(), adsi_transmit_message(), adsi_voice_mode(), ast_log(), ast_play_and_wait(), ast_readstring(), ast_strlen_zero(), ast_test_flag, ast_vm_user::context, ext_pass_cmd, LOG_NOTICE, maxgreet, play_record_review(), vm_state::username, vm_change_password(), vm_change_password_shell(), VM_FORCEGREET, VM_FORCENAME, and VM_SPOOL_DIR.

Referenced by vm_execmain().

04588 {
04589    int cmd = 0;
04590    int duration = 0;
04591    int tries = 0;
04592    char newpassword[80] = "";
04593    char newpassword2[80] = "";
04594    char prefile[256]="";
04595    unsigned char buf[256];
04596    int bytes=0;
04597 
04598    if (adsi_available(chan)) {
04599       bytes += adsi_logo(buf + bytes);
04600       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "New User Setup", "");
04601       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", "");
04602       bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
04603       bytes += adsi_voice_mode(buf + bytes, 0);
04604       adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
04605    }
04606 
04607    /* First, have the user change their password 
04608       so they won't get here again */
04609    for (;;) {
04610       newpassword[1] = '\0';
04611       newpassword[0] = cmd = ast_play_and_wait(chan,"vm-newpassword");
04612       if (cmd == '#')
04613          newpassword[0] = '\0';
04614       if (cmd < 0 || cmd == 't' || cmd == '#')
04615          return cmd;
04616       cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#");
04617       if (cmd < 0 || cmd == 't' || cmd == '#')
04618          return cmd;
04619       newpassword2[1] = '\0';
04620       newpassword2[0] = cmd = ast_play_and_wait(chan,"vm-reenterpassword");
04621       if (cmd == '#')
04622          newpassword2[0] = '\0';
04623       if (cmd < 0 || cmd == 't' || cmd == '#')
04624          return cmd;
04625       cmd = ast_readstring(chan,newpassword2 + strlen(newpassword2),sizeof(newpassword2)-1,2000,10000,"#");
04626       if (cmd < 0 || cmd == 't' || cmd == '#')
04627          return cmd;
04628       if (!strcmp(newpassword, newpassword2))
04629          break;
04630       ast_log(LOG_NOTICE,"Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2);
04631       cmd = ast_play_and_wait(chan, "vm-mismatch");
04632       if (++tries == 3)
04633          return -1;
04634    }
04635    if (ast_strlen_zero(ext_pass_cmd)) 
04636       vm_change_password(vmu,newpassword);
04637    else 
04638       vm_change_password_shell(vmu,newpassword);
04639    
04640    cmd = ast_play_and_wait(chan,"vm-passchanged");
04641 
04642    /* If forcename is set, have the user record their name */  
04643    if (ast_test_flag(vmu, VM_FORCENAME)) {
04644       snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
04645       cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04646       if (cmd < 0 || cmd == 't' || cmd == '#')
04647          return cmd;
04648    }
04649 
04650    /* If forcegreetings is set, have the user record their greetings */
04651    if (ast_test_flag(vmu, VM_FORCEGREET)) {
04652       snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
04653       cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04654       if (cmd < 0 || cmd == 't' || cmd == '#')
04655          return cmd;
04656       snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
04657       cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04658       if (cmd < 0 || cmd == 't' || cmd == '#')
04659          return cmd;
04660    }
04661 
04662    return cmd;
04663 }

int vm_options struct ast_channel chan,
struct ast_vm_user vmu,
struct vm_state vms,
char *  fmtc,
signed char  record_gain
[static]
 

Definition at line 4665 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_CENT, adsi_logo(), ADSI_MSG_DISPLAY, adsi_set_line(), adsi_transmit_message(), adsi_voice_mode(), ast_log(), ast_play_and_wait(), ast_readstring(), ast_strlen_zero(), ast_waitfordigit(), ast_vm_user::context, ext_pass_cmd, LOG_DEBUG, LOG_NOTICE, maxgreet, ast_vm_user::password, play_record_review(), vm_state::username, vm_change_password(), vm_change_password_shell(), VM_SPOOL_DIR, and vm_tempgreeting().

Referenced by vm_execmain().

04666 {
04667    int cmd = 0;
04668    int retries = 0;
04669    int duration = 0;
04670    char newpassword[80] = "";
04671    char newpassword2[80] = "";
04672    char prefile[256]="";
04673    unsigned char buf[256];
04674    int bytes=0;
04675 
04676    if (adsi_available(chan))
04677    {
04678       bytes += adsi_logo(buf + bytes);
04679       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Options Menu", "");
04680       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", "");
04681       bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
04682       bytes += adsi_voice_mode(buf + bytes, 0);
04683       adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
04684    }
04685    while ((cmd >= 0) && (cmd != 't')) {
04686       if (cmd)
04687          retries = 0;
04688       switch (cmd) {
04689       case '1':
04690          snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
04691          cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04692          break;
04693       case '2': 
04694          snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
04695          cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04696          break;
04697       case '3': 
04698          snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
04699          cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04700          break;
04701       case '4': 
04702          cmd = vm_tempgreeting(chan, vmu, vms, fmtc, record_gain);
04703          break;
04704       case '5':
04705          if (vmu->password[0] == '-') {
04706             cmd = ast_play_and_wait(chan, "vm-no");
04707             break;
04708          }
04709          newpassword[1] = '\0';
04710          newpassword[0] = cmd = ast_play_and_wait(chan,"vm-newpassword");
04711          if (cmd == '#')
04712             newpassword[0] = '\0';
04713          else {
04714             if (cmd < 0)
04715                break;
04716             if ((cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#")) < 0) {
04717                break;
04718             }
04719          }
04720          newpassword2[1] = '\0';
04721          newpassword2[0] = cmd = ast_play_and_wait(chan,"vm-reenterpassword");
04722          if (cmd == '#')
04723             newpassword2[0] = '\0';
04724          else {
04725             if (cmd < 0)
04726                break;
04727 
04728             if ((cmd = ast_readstring(chan,newpassword2 + strlen(newpassword2),sizeof(newpassword2)-1,2000,10000,"#"))) {
04729                break;
04730             }
04731          }
04732          if (strcmp(newpassword, newpassword2)) {
04733             ast_log(LOG_NOTICE,"Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2);
04734             cmd = ast_play_and_wait(chan, "vm-mismatch");
04735             break;
04736          }
04737          if (ast_strlen_zero(ext_pass_cmd)) 
04738             vm_change_password(vmu,newpassword);
04739          else 
04740             vm_change_password_shell(vmu,newpassword);
04741          ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
04742          cmd = ast_play_and_wait(chan,"vm-passchanged");
04743          break;
04744       case '*': 
04745          cmd = 't';
04746          break;
04747       default: 
04748          cmd = ast_play_and_wait(chan,"vm-options");
04749          if (!cmd)
04750             cmd = ast_waitfordigit(chan,6000);
04751          if (!cmd)
04752             retries++;
04753          if (retries > 3)
04754             cmd = 't';
04755        }
04756    }
04757    if (cmd == 't')
04758       cmd = 0;
04759    return cmd;
04760 }

int vm_play_folder_name struct ast_channel chan,
char *  mbox
[static]
 

Definition at line 3958 of file app_voicemail.c.

References ast_play_and_wait(), ast_channel::language, mbox(), and vm_play_folder_name_gr().

Referenced by get_folder(), vm_execmain(), and vm_instructions().

03959 {
03960    int cmd;
03961 
03962    if (!strcasecmp(chan->language, "it") || !strcasecmp(chan->language, "es") || !strcasecmp(chan->language, "fr") || !strcasecmp(chan->language, "pt")) { /* Italian, Spanish, French or Portuguese syntax */
03963       cmd = ast_play_and_wait(chan, "vm-messages"); /* "messages */
03964       if (cmd)
03965          return cmd;
03966       return ast_play_and_wait(chan, mbox);
03967    } else if (!strcasecmp(chan->language, "gr")){
03968       return vm_play_folder_name_gr(chan, mbox);
03969    } else {  /* Default English */
03970       cmd = ast_play_and_wait(chan, mbox);
03971       if (cmd)
03972          return cmd;
03973       return ast_play_and_wait(chan, "vm-messages"); /* "messages */
03974    }
03975 }

int vm_play_folder_name_gr struct ast_channel chan,
char *  mbox
[static]
 

Definition at line 3936 of file app_voicemail.c.

References ast_play_and_wait(), and mbox().

Referenced by vm_play_folder_name().

03937 {
03938    int cmd;
03939    char *buf;
03940 
03941    buf = alloca(strlen(mbox)+2); 
03942    strcpy(buf, mbox);
03943    strcat(buf,"s");
03944 
03945    if (!strcasecmp(mbox, "vm-INBOX") || !strcasecmp(mbox, "vm-Old")){
03946       cmd = ast_play_and_wait(chan, buf); /* "NEA / PALIA" */
03947       if (cmd)
03948       return cmd;
03949       return ast_play_and_wait(chan, "vm-messages"); /* "messages" -> "MYNHMATA" */
03950    } else {
03951       cmd = ast_play_and_wait(chan, "vm-messages"); /* "messages" -> "MYNHMATA" */
03952       if (cmd)
03953          return cmd;
03954       return ast_play_and_wait(chan, mbox); /* friends/family/work... -> "FILWN"/"OIKOGENIAS"/"DOULEIAS"*/
03955    }
03956 }

int vm_tempgreeting struct ast_channel chan,
struct ast_vm_user vmu,
struct vm_state vms,
char *  fmtc,
signed char  record_gain
[static]
 

Definition at line 4762 of file app_voicemail.c.

References adsi_available(), ADSI_COMM_PAGE, adsi_display(), ADSI_JUST_CENT, adsi_logo(), ADSI_MSG_DISPLAY, adsi_set_line(), adsi_transmit_message(), adsi_voice_mode(), ast_fileexists(), ast_play_and_wait(), ast_waitfordigit(), ast_vm_user::context, DELETE, DISPOSE, maxgreet, play_record_review(), RETRIEVE, vm_state::username, and VM_SPOOL_DIR.

Referenced by vm_options().

04763 {
04764    int cmd = 0;
04765    int retries = 0;
04766    int duration = 0;
04767    char prefile[256]="";
04768    unsigned char buf[256];
04769    int bytes=0;
04770 
04771    if (adsi_available(chan))
04772    {
04773       bytes += adsi_logo(buf + bytes);
04774       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Temp Greeting Menu", "");
04775       bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", "");
04776       bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
04777       bytes += adsi_voice_mode(buf + bytes, 0);
04778       adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
04779    }
04780    snprintf(prefile,sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
04781    while((cmd >= 0) && (cmd != 't')) {
04782       if (cmd)
04783          retries = 0;
04784       RETRIEVE(prefile, -1);
04785       if (ast_fileexists(prefile, NULL, NULL) > 0) {
04786          switch (cmd) {
04787          case '1':
04788             cmd = play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04789             break;
04790          case '2':
04791             DELETE(prefile, -1, prefile);
04792             ast_play_and_wait(chan,"vm-tempremoved");
04793             cmd = 't';  
04794             break;
04795          case '*': 
04796             cmd = 't';
04797             break;
04798          default:
04799             if (ast_fileexists(prefile, NULL, NULL) > 0) {
04800                cmd = ast_play_and_wait(chan,"vm-tempgreeting2");
04801             } else {
04802                cmd = ast_play_and_wait(chan,"vm-tempgreeting");
04803             } if (!cmd) {
04804                cmd = ast_waitfordigit(chan,6000);
04805             } if (!cmd) {
04806                retries++;
04807             } if (retries > 3) {
04808                cmd = 't';
04809             }
04810          }
04811       } else {
04812          play_record_review(chan,"vm-rec-temp",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
04813          cmd = 't';  
04814       }
04815       DISPOSE(prefile, -1);
04816    }
04817    if (cmd == 't')
04818       cmd = 0;
04819    return cmd;
04820 }

int vmauthenticate struct ast_channel chan,
void *  data
[static]
 

Definition at line 5661 of file app_voicemail.c.

References ast_log(), ast_play_and_wait(), ast_strdupa, ast_strlen_zero(), ast_vm_user::context, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, pbx_builtin_setvar_helper(), s, strsep(), and vm_authenticate().

Referenced by load_module().

05662 {
05663    struct localuser *u;
05664    char *s = data, *user=NULL, *context=NULL, mailbox[AST_MAX_EXTENSION] = "";
05665    struct ast_vm_user vmus;
05666    char *options = NULL;
05667    int silent = 0, skipuser = 0;
05668    int res = -1;
05669 
05670    LOCAL_USER_ADD(u);
05671    
05672    if (s) {
05673       s = ast_strdupa(s);
05674       if (!s) {
05675          ast_log(LOG_ERROR, "Out of memory\n");
05676          return -1;
05677       }
05678       user = strsep(&s, "|");
05679       options = strsep(&s, "|");
05680       if (user) {
05681          s = user;
05682          user = strsep(&s, "@");
05683          context = strsep(&s, "");
05684          if (!ast_strlen_zero(user))
05685             skipuser++;
05686          ast_copy_string(mailbox, user, sizeof(mailbox));
05687       }
05688    }
05689 
05690    if (options) {
05691       silent = (strchr(options, 's')) != NULL;
05692    }
05693 
05694    if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, skipuser, 3, silent)) {
05695       pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", mailbox);
05696       pbx_builtin_setvar_helper(chan, "AUTH_CONTEXT", vmus.context);
05697       ast_play_and_wait(chan, "auth-thankyou");
05698       res = 0;
05699    }
05700 
05701    LOCAL_USER_REMOVE(u);
05702    return res;
05703 }

int wait_file struct ast_channel chan,
struct vm_state vms,
char *  file
[static]
 

Definition at line 3595 of file app_voicemail.c.

References ast_control_streamfile(), and skipms.

Referenced by advanced_options(), ast_say_date_da(), ast_say_date_de(), ast_say_date_pt(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pt(), ast_say_date_with_format_tw(), ast_say_datetime_from_now_pt(), ast_say_number_full_pt(), ast_say_time_pt(), gr_say_number_female(), and play_message().

03596 {
03597    return ast_control_streamfile(chan, file, "#", "*", "1456789", "0", "2", skipms);
03598 }

int wait_file2 struct ast_channel chan,
struct vm_state vms,
char *  file
[static]
 

Definition at line 3585 of file app_voicemail.c.

References AST_DIGIT_ANY, ast_log(), ast_streamfile(), ast_waitstream(), ast_channel::language, and LOG_WARNING.

Referenced by play_message(), play_message_callerid(), and play_message_duration().

03586 {
03587    int res;
03588    if ((res = ast_streamfile(chan, file, chan->language))) 
03589       ast_log(LOG_WARNING, "Unable to play message %s\n", file); 
03590    if (!res)
03591       res = ast_waitstream(chan, AST_DIGIT_ANY);
03592    return res;
03593 }


Variable Documentation

char* addesc = "Comedian Mail" [static]
 

Definition at line 295 of file app_voicemail.c.

Referenced by adsi_load_vmail().

unsigned char adsifdn[4] = "\x00\x00\x00\x0F" [static]
 

Definition at line 415 of file app_voicemail.c.

Referenced by adsi_begin(), adsi_load_vmail(), and load_config().

unsigned char adsisec[4] = "\x9B\xDB\xF7\xAC" [static]
 

Definition at line 416 of file app_voicemail.c.

Referenced by adsi_load_vmail(), and load_config().

int adsiver = 1 [static]
 

Definition at line 417 of file app_voicemail.c.

Referenced by adsi_begin(), adsi_load_vmail(), and load_config().

char* app = "VoiceMail" [static]
 

Definition at line 368 of file app_voicemail.c.

Referenced by forward_message(), load_module(), and unload_module().

char* app2 = "VoiceMailMain" [static]
 

Definition at line 371 of file app_voicemail.c.

Referenced by load_module(), and unload_module().

char* app3 = "MailboxExists" [static]
 

Definition at line 373 of file app_voicemail.c.

Referenced by load_module(), and unload_module().

char* app4 = "VMAuthenticate" [static]
 

Definition at line 374 of file app_voicemail.c.

Referenced by load_module(), and unload_module().

char callcontext[AST_MAX_CONTEXT] [static]
 

Definition at line 400 of file app_voicemail.c.

Referenced by load_config(), and populate_defaults().

char charset[32] = "ISO-8859-1" [static]
 

Definition at line 413 of file app_voicemail.c.

Referenced by load_config(), and sendmail().

char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64] [static]
 

Definition at line 403 of file app_voicemail.c.

Referenced by load_config(), and play_message_callerid().

char* descrip_vm [static]
 

Definition at line 300 of file app_voicemail.c.

Referenced by load_module().

char* descrip_vm_box_exists [static]
 

Definition at line 343 of file app_voicemail.c.

Referenced by load_module().

char* descrip_vmain [static]
 

Definition at line 327 of file app_voicemail.c.

Referenced by load_module().

char* descrip_vmauthenticate [static]
 

Definition at line 357 of file app_voicemail.c.

Referenced by load_module().

char dialcontext[AST_MAX_CONTEXT] [static]
 

Definition at line 399 of file app_voicemail.c.

Referenced by load_config(), and populate_defaults().

char* emailbody = NULL [static]
 

Definition at line 406 of file app_voicemail.c.

Referenced by load_config(), and sendmail().

char emaildateformat[32] = "%A, %B %d, %Y at %r" [static]
 

Definition at line 418 of file app_voicemail.c.

Referenced by load_config(), and sendmail().

char* emailsubject = NULL [static]
 

Definition at line 407 of file app_voicemail.c.

Referenced by load_config(), and sendmail().

char emailtitle[100] [static]
 

Definition at line 412 of file app_voicemail.c.

Referenced by load_config(), and sendmail().

char exitcontext[AST_MAX_CONTEXT] [static]
 

Definition at line 401 of file app_voicemail.c.

Referenced by load_config(), and populate_defaults().

char ext_pass_cmd[128] [static]
 

Definition at line 291 of file app_voicemail.c.

Referenced by load_config(), vm_change_password_shell(), vm_newuser(), and vm_options().

char externnotify[160] [static]
 

Definition at line 386 of file app_voicemail.c.

Referenced by load_config(), and run_externnotify().

char fromstring[100] [static]
 

Definition at line 410 of file app_voicemail.c.

Referenced by load_config(), sendmail(), and sendpage().

struct ast_flags globalflags = {0} [static]
 

Definition at line 395 of file app_voicemail.c.

Referenced by find_user(), find_user_realtime(), forward_message(), load_config(), notify_new_message(), populate_defaults(), sendmail(), and vm_execmain().

LOCAL_USER_DECL
 

Definition at line 422 of file app_voicemail.c.

char mailcmd[160] [static]
 

Definition at line 385 of file app_voicemail.c.

Referenced by load_config(), sendmail(), and sendpage().

int maxgreet [static]
 

Definition at line 391 of file app_voicemail.c.

Referenced by load_config(), vm_newuser(), vm_options(), and vm_tempgreeting().

int maxlogins [static]
 

Definition at line 393 of file app_voicemail.c.

Referenced by load_config(), and vm_execmain().

int maxmsg [static]
 

Definition at line 382 of file app_voicemail.c.

Referenced by load_config().

int maxsilence [static]
 

Definition at line 381 of file app_voicemail.c.

Referenced by load_config(), play_record_review(), and vm_forwardoptions().

char* pagerbody = NULL [static]
 

Definition at line 408 of file app_voicemail.c.

Referenced by load_config(), and sendpage().

char pagerfromstring[100] [static]
 

Definition at line 411 of file app_voicemail.c.

Referenced by load_config(), and sendpage().

char* pagersubject = NULL [static]
 

Definition at line 409 of file app_voicemail.c.

Referenced by load_config(), and sendpage().

int saydurationminfo [static]
 

Definition at line 397 of file app_voicemail.c.

Referenced by load_config().

char serveremail[80] [static]
 

Definition at line 384 of file app_voicemail.c.

Referenced by load_config().

struct ast_cli_entry show_voicemail_users_cli [static]
 

Initial value:

   { { "show", "voicemail", "users", NULL },
   handle_show_voicemail_users, "List defined voicemail boxes",
   show_voicemail_users_help, complete_show_voicemail_users }

Definition at line 5816 of file app_voicemail.c.

Referenced by load_module(), and unload_module().

char show_voicemail_users_help[] [static]
 

Initial value:

"Usage: show voicemail users [for <context>]\n"
"       Lists all mailboxes currently set up\n"

Definition at line 5705 of file app_voicemail.c.

struct ast_cli_entry show_voicemail_zones_cli [static]
 

Initial value:

   { { "show", "voicemail", "zones", NULL },
   handle_show_voicemail_zones, "List zone message formats",
   show_voicemail_zones_help, NULL }

Definition at line 5821 of file app_voicemail.c.

Referenced by load_module(), and unload_module().

char show_voicemail_zones_help[] [static]
 

Initial value:

"Usage: show voicemail zones\n"
"       Lists zone message formats\n"

Definition at line 5709 of file app_voicemail.c.

int silencethreshold = 128 [static]
 

Definition at line 383 of file app_voicemail.c.

Referenced by load_config(), play_record_review(), and vm_forwardoptions().

int skipms [static]
 

Definition at line 392 of file app_voicemail.c.

Referenced by load_config(), and wait_file().

STANDARD_LOCAL_USER
 

Definition at line 420 of file app_voicemail.c.

char* synopsis_vm [static]
 

Initial value:

"Leave a Voicemail message"

Definition at line 297 of file app_voicemail.c.

Referenced by load_module().

char* synopsis_vm_box_exists [static]
 

Initial value:

"Check to see if Voicemail mailbox exists"

Definition at line 340 of file app_voicemail.c.

Referenced by load_module().

char* synopsis_vmain [static]
 

Initial value:

"Check Voicemail messages"

Definition at line 324 of file app_voicemail.c.

Referenced by load_module().

char* synopsis_vmauthenticate [static]
 

Initial value:

"Authenticate with Voicemail passwords"

Definition at line 354 of file app_voicemail.c.

Referenced by load_module().

char* tdesc = "Comedian Mail (Voicemail System)" [static]
 

Definition at line 293 of file app_voicemail.c.

struct ast_vm_user* users
 

Definition at line 377 of file app_voicemail.c.

Referenced by append_mailbox(), and load_config().

struct ast_vm_user* usersl
 

Definition at line 378 of file app_voicemail.c.

Referenced by append_mailbox(), and load_config().

enum { ... } vm_option_args
 

enum { ... } vm_option_flags
 

char VM_SPOOL_DIR[AST_CONFIG_MAX_PATH] [static]
 

Definition at line 289 of file app_voicemail.c.

Referenced by forward_message(), has_voicemail(), invent_message(), leave_voicemail(), load_module(), make_dir(), messagecount(), play_message_callerid(), vm_newuser(), vm_options(), and vm_tempgreeting().

char vmfmts[80] [static]
 

Definition at line 388 of file app_voicemail.c.

Referenced by forward_message(), leave_voicemail(), load_config(), vm_execmain(), and vm_forwardoptions().

int vmmaxmessage [static]
 

Definition at line 390 of file app_voicemail.c.

Referenced by leave_voicemail(), and load_config().

int vmminmessage [static]
 

Definition at line 389 of file app_voicemail.c.

Referenced by leave_voicemail(), and load_config().

struct vm_zone* zones = NULL
 

Definition at line 379 of file app_voicemail.c.

Referenced by load_config().

struct vm_zone* zonesl = NULL
 

Definition at line 380 of file app_voicemail.c.

Referenced by load_config().


Generated on Mon Mar 20 08:25:48 2006 for Asterisk - the Open Source PBX by  doxygen 1.3.9.1