#include "asterisk.h"
#include "asterisk/paths.h"
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <time.h>
#include <dirent.h>
#include "asterisk/logger.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.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"
#include "asterisk/stringfields.h"
#include "asterisk/smdi.h"
#include "asterisk/astobj2.h"
#include "asterisk/event.h"
#include "asterisk/taskprocessor.h"

Go to the source code of this file.
Data Structures | |
| struct | ast_vm_user |
| struct | baseio |
| struct | inprocess |
| struct | leave_vm_options |
| Options for leaving voicemail with the voicemail() application. More... | |
| struct | mwi_sub |
| An MWI subscription. More... | |
| struct | mwi_sub_task |
| struct | mwi_subs |
| struct | users |
| list of users found in the config file More... | |
| struct | vm_state |
| struct | vm_zone |
| struct | zones |
Defines | |
| #define | ASTERISK_USERNAME "asterisk" |
| #define | BASELINELEN 72 |
| #define | BASEMAXINLINE 256 |
| #define | CHUNKSIZE 65536 |
| #define | COMMAND_TIMEOUT 5000 |
| #define | COPY(a, b, c, d, e, f, g, h) (copy_plain_file(g,h)); |
| #define | DEFAULT_LISTEN_CONTROL_FORWARD_KEY "#" |
| #define | DEFAULT_LISTEN_CONTROL_PAUSE_KEY "0" |
| #define | DEFAULT_LISTEN_CONTROL_RESTART_KEY "2" |
| #define | DEFAULT_LISTEN_CONTROL_REVERSE_KEY "*" |
| #define | DEFAULT_LISTEN_CONTROL_STOP_KEY "13456789" |
| #define | DEFAULT_POLL_FREQ 30 |
| #define | DELETE(a, b, c, d) (vm_delete(c)) |
| #define | DISPOSE(a, b) |
| #define | ENDL "\n" |
| #define | ERROR_LOCK_PATH -100 |
| #define | EXISTS(a, b, c, d) (ast_fileexists(c,NULL,d) > 0) |
| #define | HVSU_OUTPUT_FORMAT "%-10s %-5s %-25s %-10s %6s\n" |
| #define | HVSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n" |
| #define | INTRO "vm-intro" |
| #define | MAX_DATETIME_FORMAT 512 |
| #define | MAX_NUM_CID_CONTEXTS 10 |
| #define | MAXMSG 100 |
| #define | MAXMSGLIMIT 9999 |
| #define | MINPASSWORD 0 |
| #define | OPERATOR_EXIT 300 |
| #define | PWDCHANGE_EXTERNAL (1 << 2) |
| #define | PWDCHANGE_INTERNAL (1 << 1) |
| #define | RENAME(a, b, c, d, e, f, g, h) (rename_file(g,h)); |
| #define | RETRIEVE(a, b, c, d) |
| #define | SENDMAIL "/usr/sbin/sendmail -t" |
| #define | SMDI_MWI_WAIT_TIMEOUT 1000 |
| #define | STORE(a, b, c, d, e, f, g, h, i, j) |
| #define | tdesc "Comedian Mail (Voicemail System)" |
| #define | VALID_DTMF "1234567890*#" |
| #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_FWDURGAUTO (1 << 18) |
| #define | VM_MESSAGEWRAP (1 << 17) |
| #define | VM_MOVEHEARD (1 << 16) |
| #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 | VM_TEMPGREETWARN (1 << 15) |
| #define | VMSTATE_MAX_MSG_ARRAY 256 |
| #define | VOICEMAIL_CONFIG "voicemail.conf" |
| #define | VOICEMAIL_DIR_MODE 0777 |
| #define | VOICEMAIL_FILE_MODE 0666 |
Enumerations | |
| enum | { NEW_FOLDER, OLD_FOLDER, WORK_FOLDER, FAMILY_FOLDER, FRIENDS_FOLDER, GREETINGS_FOLDER } |
| 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_AUTOPLAY = (1 << 6), OPT_DTMFEXIT = (1 << 7), OPT_MESSAGE_Urgent = (1 << 8), OPT_MESSAGE_PRIORITY = (1 << 9) } |
| enum | { OPT_ARG_RECORDGAIN = 0, OPT_ARG_PLAYFOLDER = 1, OPT_ARG_DTMFEXIT = 2, OPT_ARG_ARRAY_SIZE = 3 } |
Functions | |
| static int | __has_voicemail (const char *context, const char *mailbox, const char *folder, int shortcircuit) |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | acf_mailbox_exists (struct ast_channel *chan, const char *cmd, char *args, char *buf, size_t len) |
| static int | add_email_attachment (FILE *p, struct ast_vm_user *vmu, char *format, char *attach, char *greeting_attachment, char *mailbox, char *bound, char *filename, int last, int msgnum) |
| static void | adsi_begin (struct ast_channel *chan, int *useadsi) |
| static void | adsi_delete (struct ast_channel *chan, struct vm_state *vms) |
| static void | adsi_folders (struct ast_channel *chan, int start, char *label) |
| static void | adsi_goodbye (struct ast_channel *chan) |
| static int | adsi_load_vmail (struct ast_channel *chan, int *useadsi) |
| static void | adsi_login (struct ast_channel *chan) |
| static int | adsi_logo (unsigned char *buf) |
| static void | adsi_message (struct ast_channel *chan, struct vm_state *vms) |
| static void | adsi_password (struct ast_channel *chan) |
| static void | adsi_status (struct ast_channel *chan, struct vm_state *vms) |
| static void | adsi_status2 (struct ast_channel *chan, struct vm_state *vms) |
| static int | advanced_options (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msg, int option, signed char record_gain) |
| The advanced options within a message. | |
| static int | append_mailbox (const char *context, const char *box, const char *data) |
| static void | apply_option (struct ast_vm_user *vmu, const char *var, const char *value) |
| Sets a a specific property value. | |
| static void | apply_options (struct ast_vm_user *vmu, const char *options) |
| Destructively Parse options and apply. | |
| static void | apply_options_full (struct ast_vm_user *retval, struct ast_variable *var) |
| Loads the options specific to a voicemail user. | |
| static int | base_encode (char *filename, FILE *so) |
| Performs a base 64 encode algorithm on the contents of a File. | |
| static int | change_password_realtime (struct ast_vm_user *vmu, const char *password) |
| Performs a change of the voicemail passowrd in the realtime engine. | |
| static int | check_mime (const char *str) |
| Check if the string would need encoding within the MIME standard, to avoid confusing certain mail software that expects messages to be 7-bit clean. | |
| static int | check_password (struct ast_vm_user *vmu, char *password) |
| Check that password meets minimum required length. | |
| static int | close_mailbox (struct vm_state *vms, struct ast_vm_user *vmu) |
| static char * | complete_voicemail_show_users (const char *line, const char *word, int pos, int state) |
| static int | copy (char *infile, char *outfile) |
| Utility function to copy a file. | |
| static 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, char *dir, const char *flag) |
| Copies a message from one mailbox to another. | |
| static void | copy_plain_file (char *frompath, char *topath) |
| Copies a voicemail information (envelope) file. | |
| static int | count_messages (struct ast_vm_user *vmu, char *dir) |
| Find all .txt files - even if they are not in sequence from 0000. | |
| static int | create_dirpath (char *dest, int len, const char *context, const char *ext, const char *folder) |
| basically mkdir -p $dest/$context/$ext/$folder | |
| static int | dialout (struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context) |
| static char * | encode_mime_str (const char *start, char *end, size_t endsize, size_t preamble, size_t postamble) |
| Encode a string according to the MIME rules for encoding strings that are not 7-bit clean or contain control characters. | |
| static struct ast_vm_user * | find_or_create (const char *context, const char *box) |
| static struct ast_vm_user * | find_user (struct ast_vm_user *ivm, const char *context, const char *mailbox) |
| Finds a voicemail user from the users file or the realtime engine. | |
| static struct ast_vm_user * | find_user_realtime (struct ast_vm_user *ivm, const char *context, const char *mailbox) |
| Finds a voicemail user from the realtime engine. | |
| static int | forward_message (struct ast_channel *chan, char *context, struct vm_state *vms, struct ast_vm_user *sender, char *fmt, int is_new_message, signed char record_gain, int urgent) |
| Sends a voicemail message to a mailbox recipient. | |
| static void | free_user (struct ast_vm_user *vmu) |
| static void | free_vm_users (void) |
| Free the users structure. | |
| static void | free_vm_zones (void) |
| Free the zones structure. | |
| static void | free_zone (struct vm_zone *z) |
| static int | get_date (char *s, int len) |
| Gets the current date and time, as formatted string. | |
| static int | get_folder (struct ast_channel *chan, int start) |
| get_folder: Folder menu Plays "press 1 for INBOX messages" etc. Should possibly be internationalized | |
| static int | get_folder2 (struct ast_channel *chan, char *fn, int start) |
| plays a prompt and waits for a keypress. | |
| static int | handle_subscribe (void *datap) |
| static int | handle_unsubscribe (void *datap) |
| static char * | handle_voicemail_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Reload voicemail configuration from the CLI. | |
| static char * | handle_voicemail_show_users (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show a list of voicemail users in the CLI. | |
| static char * | handle_voicemail_show_zones (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show a list of voicemail zones in the CLI. | |
| static int | has_voicemail (const char *mailbox, const char *folder) |
| Determines if the given folder has messages. | |
| static int | inboxcount (const char *mailbox, int *newmsgs, int *oldmsgs) |
| static int | inboxcount2 (const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs) |
| static int | inbuf (struct baseio *bio, FILE *fi) |
| utility used by inchar(), for base_encode() | |
| static int | inchar (struct baseio *bio, FILE *fi) |
| utility used by base_encode() | |
| static int | inprocess_cmp_fn (void *obj, void *arg, int flags) |
| static int | inprocess_count (const char *context, const char *mailbox, int delta) |
| static int | inprocess_hash_fn (const void *obj, const int flags) |
| static int | invent_message (struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes) |
| static int | is_valid_dtmf (const char *key) |
| Determines if a DTMF key entered is valid. | |
| static int | last_message_index (struct ast_vm_user *vmu, char *dir) |
| Determines the highest message number in use for a given user and mailbox folder. | |
| static int | leave_voicemail (struct ast_channel *chan, char *ext, struct leave_vm_options *options) |
| Prompts the user and records a voicemail to a mailbox. | |
| static int | load_config (int reload) |
| static int | load_module (void) |
| static int | make_dir (char *dest, int len, const char *context, const char *ext, const char *folder) |
| Creates a file system path expression for a folder within the voicemail data folder and the appropriate context. | |
| static void | make_email_file (FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap, const char *flag) |
| Creates the email file to be sent to indicate a new voicemail exists for a user. | |
| static int | make_file (char *dest, const int len, const char *dir, const int num) |
| Creates a file system path expression for a folder within the voicemail data folder and the appropriate context. | |
| static int | manager_list_voicemail_users (struct mansession *s, const struct message *m) |
| Manager list voicemail users command. | |
| static void * | mb_poll_thread (void *data) |
| static const char * | mbox (int id) |
| static int | messagecount (const char *context, const char *mailbox, const char *folder) |
| static void | mwi_sub_destroy (struct mwi_sub *mwi_sub) |
| static void | mwi_sub_event_cb (const struct ast_event *event, void *userdata) |
| static void | mwi_unsub_event_cb (const struct ast_event *event, void *userdata) |
| static int | notify_new_message (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msgnum, long duration, char *fmt, char *cidnum, char *cidname, const char *flag) |
| Sends email notification that a user has a new voicemail waiting for them. | |
| static int | ochar (struct baseio *bio, int c, FILE *so) |
| utility used by base_encode() | |
| static int | open_mailbox (struct vm_state *vms, struct ast_vm_user *vmu, int box) |
| static int | play_message (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms) |
| static int | play_message_callerid (struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback) |
| static int | play_message_category (struct ast_channel *chan, const char *category) |
| static int | play_message_datetime (struct ast_channel *chan, struct ast_vm_user *vmu, const char *origtime, const char *filename) |
| static int | play_message_duration (struct ast_channel *chan, struct vm_state *vms, const char *duration, int minduration) |
| static 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, struct vm_state *vms, char *flag) |
| static void | poll_subscribed_mailbox (struct mwi_sub *mwi_sub) |
| static void | poll_subscribed_mailboxes (void) |
| static void | populate_defaults (struct ast_vm_user *vmu) |
| Sets default voicemail system options to a voicemail user. | |
| static void | prep_email_sub_vars (struct ast_channel *ast, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *dur, char *date, char *passdata, size_t passdatasize, const char *category, const char *flag) |
| static void | queue_mwi_event (const char *box, int urgent, int new, int old) |
| static char * | quote (const char *from, char *to, size_t len) |
| Wraps a character sequence in double quotes, escaping occurences of quotes within the string. | |
| static int | reload (void) |
| static void | rename_file (char *sfn, char *dfn) |
| Renames a message in a mailbox folder. | |
| static int | reset_user_pw (const char *context, const char *mailbox, const char *newpass) |
| Resets a user password to a specified password. | |
| static void | run_externnotify (char *context, char *extension, const char *flag) |
| static int | save_to_folder (struct ast_vm_user *vmu, struct vm_state *vms, int msg, int box) |
| static int | say_and_wait (struct ast_channel *chan, int num, const char *language) |
| static int | sayname (struct ast_channel *chan, const char *mailbox, const char *context) |
| static int | sendmail (char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, const char *flag) |
| static int | sendpage (char *srcemail, char *pager, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, int duration, struct ast_vm_user *vmu, const char *category, const char *flag) |
| static char * | show_users_realtime (int fd, const char *context) |
| static void | start_poll_thread (void) |
| static void | stop_poll_thread (void) |
| static char * | strip_control_and_high (const char *input, char *buf, size_t buflen) |
| Strips control and non 7-bit clean characters from input string. | |
| static const char * | substitute_escapes (const char *value) |
| static int | unload_module (void) |
| static int | vm_allocate_dh (struct vm_state *vms, struct ast_vm_user *vmu, int count_msg) |
| static 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 max_logins, int silent) |
| static int | vm_box_exists (struct ast_channel *chan, void *data) |
| static int | vm_browse_messages (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| Top level method to invoke the language variant vm_browse_messages_XX function. | |
| static int | vm_browse_messages_en (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| Default English syntax for 'You have N messages' greeting. | |
| static int | vm_browse_messages_es (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| Spanish syntax for 'You have N messages' greeting. | |
| static int | vm_browse_messages_gr (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| Greek syntax for 'You have N messages' greeting. | |
| static int | vm_browse_messages_he (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| static int | vm_browse_messages_it (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| Italian syntax for 'You have N messages' greeting. | |
| static int | vm_browse_messages_pt (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| Portuguese syntax for 'You have N messages' greeting. | |
| static int | vm_browse_messages_zh (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) |
| Chinese (Taiwan)syntax for 'You have N messages' greeting. | |
| static void | vm_change_password (struct ast_vm_user *vmu, const char *newpassword) |
| The handler for the change password option. | |
| static void | vm_change_password_shell (struct ast_vm_user *vmu, char *newpassword) |
| static char * | vm_check_password_shell (char *command, char *buf, size_t len) |
| static int | vm_delete (char *file) |
| Removes the voicemail sound and information file. | |
| static int | vm_exec (struct ast_channel *chan, void *data) |
| static int | vm_execmain (struct ast_channel *chan, void *data) |
| static int | vm_forwardoptions (struct ast_channel *chan, struct ast_vm_user *vmu, char *curdir, int curmsg, char *vm_fmts, char *context, signed char record_gain, long *duration, struct vm_state *vms, char *flag) |
| presents the option to prepend to an existing message when forwarding it. | |
| static int | vm_instructions (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int skipadvanced, int in_urgent) |
| static int | vm_instructions_en (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int skipadvanced, int in_urgent) |
| static int | vm_instructions_zh (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int skipadvanced, int in_urgent) |
| static int | vm_intro (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms) |
| static int | vm_intro_cs (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_de (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_en (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_es (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_fr (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_gr (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_he (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_it (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_multilang (struct ast_channel *chan, struct vm_state *vms, const char message_gender[]) |
| static int | vm_intro_nl (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_no (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_pl (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_pt (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_pt_BR (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_se (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_intro_zh (struct ast_channel *chan, struct vm_state *vms) |
| static int | vm_lock_path (const char *path) |
| Lock file path only return failure if ast_lock_path returns 'timeout', not if the path does not exist or any other reason. | |
| static FILE * | vm_mkftemp (char *template) |
| static int | vm_newuser (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain) |
| static int | vm_options (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain) |
| static int | vm_play_folder_name (struct ast_channel *chan, char *mbox) |
| static int | vm_play_folder_name_gr (struct ast_channel *chan, char *box) |
| static int | vm_play_folder_name_pl (struct ast_channel *chan, char *box) |
| static int | vm_play_folder_name_ua (struct ast_channel *chan, char *box) |
| static int | vm_tempgreeting (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain) |
| The handler for 'record a temporary greeting'. | |
| static int | vmauthenticate (struct ast_channel *chan, void *data) |
| static struct ast_tm * | vmu_tm (const struct ast_vm_user *vmu, struct ast_tm *tm) |
| fill in *tm for current time according to the proper timezone, if any. Return tm so it can be used as a function argument. | |
| static int | wait_file (struct ast_channel *chan, struct vm_state *vms, char *file) |
| static int | wait_file2 (struct ast_channel *chan, struct vm_state *vms, char *file) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Comedian Mail (Voicemail System)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } |
| static char * | addesc = "Comedian Mail" |
| static unsigned char | adsifdn [4] = "\x00\x00\x00\x0F" |
| static unsigned char | adsisec [4] = "\x9B\xDB\xF7\xAC" |
| static int | adsiver = 1 |
| static char * | app = "VoiceMail" |
| static char * | app2 = "VoiceMailMain" |
| static char * | app3 = "MailboxExists" |
| static char * | app4 = "VMAuthenticate" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static char | callcontext [AST_MAX_CONTEXT] = "" |
| static char | charset [32] = "ISO-8859-1" |
| static char | cidinternalcontexts [MAX_NUM_CID_CONTEXTS][64] |
| static struct ast_cli_entry | cli_voicemail [] |
| static char | dialcontext [AST_MAX_CONTEXT] = "" |
| static char * | emailbody = NULL |
| static char | emaildateformat [32] = "%A, %B %d, %Y at %r" |
| static char * | emailsubject = NULL |
| static char | exitcontext [AST_MAX_CONTEXT] = "" |
| static char | ext_pass_check_cmd [128] |
| static char | ext_pass_cmd [128] |
| static char | externnotify [160] |
| static char | fromstring [100] |
| static struct ast_flags | globalflags = {0} |
| struct ao2_container * | inprocess_container |
| static char | listen_control_forward_key [12] |
| static char | listen_control_pause_key [12] |
| static char | listen_control_restart_key [12] |
| static char | listen_control_reverse_key [12] |
| static char | listen_control_stop_key [12] |
| static struct ast_custom_function | mailbox_exists_acf |
| static char | mailcmd [160] |
| static int | maxdeletedmsg |
| static int | maxgreet |
| static int | maxlogins |
| static int | maxmsg |
| static int | maxsilence |
| static int | minpassword |
| static struct ast_event_sub * | mwi_sub_sub |
| static struct ast_taskprocessor * | mwi_subscription_tps |
| static struct ast_event_sub * | mwi_unsub_sub |
| static int | my_umask |
| static char * | pagerbody = NULL |
| static char | pagerfromstring [100] |
| static char * | pagersubject = NULL |
| static ast_cond_t | poll_cond = PTHREAD_COND_INITIALIZER |
| static unsigned int | poll_freq |
| static ast_mutex_t | poll_lock = ((ast_mutex_t) PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP ) |
| static unsigned int | poll_mailboxes |
| static pthread_t | poll_thread = AST_PTHREADT_NULL |
| static unsigned char | poll_thread_run |
| static int | pwdchange = PWDCHANGE_INTERNAL |
| static int | saydurationminfo |
| static char | serveremail [80] |
| static int | silencethreshold = 128 |
| static int | skipms |
| static struct ast_smdi_interface * | smdi_iface = NULL |
| static char | userscontext [AST_MAX_EXTENSION] = "default" |
| static struct ast_app_option | vm_app_options [128] = { [ 's' ] = { .flag = OPT_SILENT }, [ 'b' ] = { .flag = OPT_BUSY_GREETING }, [ 'u' ] = { .flag = OPT_UNAVAIL_GREETING }, [ 'g' ] = { .flag = OPT_RECORDGAIN , .arg_index = OPT_ARG_RECORDGAIN + 1 }, [ 'd' ] = { .flag = OPT_DTMFEXIT , .arg_index = OPT_ARG_DTMFEXIT + 1 }, [ 'p' ] = { .flag = OPT_PREPEND_MAILBOX }, [ 'a' ] = { .flag = OPT_AUTOPLAY , .arg_index = OPT_ARG_PLAYFOLDER + 1 }, [ 'U' ] = { .flag = OPT_MESSAGE_Urgent }, [ 'P' ] = { .flag = OPT_MESSAGE_PRIORITY }} |
| enum { ... } | vm_box |
| static char | vm_invalid_password [80] = "vm-invalid-password" |
| static char | vm_mismatch [80] = "vm-mismatch" |
| static char | vm_newpassword [80] = "vm-newpassword" |
| enum { ... } | vm_option_args |
| enum { ... } | vm_option_flags |
| static char | vm_passchanged [80] = "vm-passchanged" |
| static char | vm_password [80] = "vm-password" |
| static char | vm_pls_try_again [80] = "vm-pls-try-again" |
| static char | vm_reenterpassword [80] = "vm-reenterpassword" |
| static char | VM_SPOOL_DIR [PATH_MAX] |
| static char | vmfmts [80] |
| static int | vmmaxsecs |
| static int | vmminsecs |
| static double | volgain |
| static char | zonetag [80] |
This module requires res_adsi to load. This needs to be optional during compilation.
This file is now almost impossible to work with, due to all #ifdefs. Feels like the database code before realtime. Someone - please come up with a plan to clean this up.
Definition in file app_voicemail.c.
| #define ASTERISK_USERNAME "asterisk" |
Definition at line 383 of file app_voicemail.c.
| #define BASELINELEN 72 |
| #define BASEMAXINLINE 256 |
| #define CHUNKSIZE 65536 |
Definition at line 380 of file app_voicemail.c.
| #define COMMAND_TIMEOUT 5000 |
Definition at line 376 of file app_voicemail.c.
| #define COPY | ( | a, | |||
| b, | |||||
| c, | |||||
| d, | |||||
| e, | |||||
| f, | |||||
| g, | |||||
| h | ) | (copy_plain_file(g,h)); |
| #define DEFAULT_LISTEN_CONTROL_FORWARD_KEY "#" |
| #define DEFAULT_LISTEN_CONTROL_PAUSE_KEY "0" |
| #define DEFAULT_LISTEN_CONTROL_RESTART_KEY "2" |
| #define DEFAULT_LISTEN_CONTROL_REVERSE_KEY "*" |
| #define DEFAULT_LISTEN_CONTROL_STOP_KEY "13456789" |
| #define DEFAULT_POLL_FREQ 30 |
By default, poll every 30 seconds
Definition at line 745 of file app_voicemail.c.
Referenced by load_config().
| #define DELETE | ( | a, | |||
| b, | |||||
| c, | |||||
| d | ) | (vm_delete(c)) |
Definition at line 680 of file app_voicemail.c.
Referenced by close_mailbox(), notify_new_message(), play_record_review(), and vm_tempgreeting().
| #define DISPOSE | ( | a, | |||
| b | ) |
Definition at line 675 of file app_voicemail.c.
Referenced by advanced_options(), forward_message(), invent_message(), leave_voicemail(), notify_new_message(), play_message(), play_record_review(), sayname(), vm_intro(), vm_options(), and vm_tempgreeting().
| #define ENDL "\n" |
Definition at line 411 of file app_voicemail.c.
Referenced by add_email_attachment(), base_encode(), make_email_file(), and ochar().
| #define ERROR_LOCK_PATH -100 |
Definition at line 436 of file app_voicemail.c.
| #define EXISTS | ( | a, | |||
| b, | |||||
| c, | |||||
| d | ) | (ast_fileexists(c,NULL,d) > 0) |
Definition at line 677 of file app_voicemail.c.
Referenced by close_mailbox(), copy_message(), and save_to_folder().
| #define HVSU_OUTPUT_FORMAT "%-10s %-5s %-25s %-10s %6s\n" |
Referenced by handle_voicemail_show_users().
| #define HVSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n" |
Referenced by handle_voicemail_show_zones().
| #define INTRO "vm-intro" |
Definition at line 399 of file app_voicemail.c.
Referenced by leave_voicemail(), play_record_review(), and vm_forwardoptions().
| #define MAX_DATETIME_FORMAT 512 |
Definition at line 414 of file app_voicemail.c.
| #define MAX_NUM_CID_CONTEXTS 10 |
Definition at line 415 of file app_voicemail.c.
| #define MAXMSG 100 |
| #define MAXMSGLIMIT 9999 |
Definition at line 402 of file app_voicemail.c.
Referenced by apply_option(), last_message_index(), and load_config().
| #define MINPASSWORD 0 |
Default minimum mailbox password length
Definition at line 404 of file app_voicemail.c.
Referenced by load_config().
| #define OPERATOR_EXIT 300 |
Definition at line 437 of file app_voicemail.c.
Referenced by leave_voicemail(), vm_exec(), and vm_execmain().
| #define PWDCHANGE_EXTERNAL (1 << 2) |
Definition at line 692 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
| #define PWDCHANGE_INTERNAL (1 << 1) |
Definition at line 691 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
| #define RENAME | ( | a, | |||
| b, | |||||
| c, | |||||
| d, | |||||
| e, | |||||
| f, | |||||
| g, | |||||
| h | ) | (rename_file(g,h)); |
Definition at line 678 of file app_voicemail.c.
Referenced by close_mailbox(), leave_voicemail(), and save_to_folder().
| #define RETRIEVE | ( | a, | |||
| b, | |||||
| c, | |||||
| d | ) |
Definition at line 674 of file app_voicemail.c.
Referenced by advanced_options(), forward_message(), invent_message(), leave_voicemail(), notify_new_message(), play_message(), sayname(), vm_intro(), vm_options(), and vm_tempgreeting().
| #define SENDMAIL "/usr/sbin/sendmail -t" |
Definition at line 397 of file app_voicemail.c.
| #define SMDI_MWI_WAIT_TIMEOUT 1000 |
| #define STORE | ( | a, | |||
| b, | |||||
| c, | |||||
| d, | |||||
| e, | |||||
| f, | |||||
| g, | |||||
| h, | |||||
| i, | |||||
| j | ) |
Definition at line 676 of file app_voicemail.c.
Referenced by copy_message(), forward_message(), leave_voicemail(), and play_record_review().
| #define tdesc "Comedian Mail (Voicemail System)" |
Definition at line 701 of file app_voicemail.c.
| #define VALID_DTMF "1234567890*#" |
| #define VM_ALLOCED (1 << 13) |
Structure was malloc'ed, instead of placed in a return (usually static) buffer
Definition at line 430 of file app_voicemail.c.
Referenced by find_user(), find_user_realtime(), free_user(), and free_vm_users().
| #define VM_ATTACH (1 << 11) |
Attach message to voicemail notifications?
Definition at line 428 of file app_voicemail.c.
Referenced by apply_option(), forward_message(), load_config(), manager_list_voicemail_users(), notify_new_message(), and sendmail().
| #define VM_DELETE (1 << 12) |
Delete message after sending notification
Definition at line 429 of file app_voicemail.c.
Referenced by apply_option(), manager_list_voicemail_users(), and notify_new_message().
| #define VM_DIRECFORWARD (1 << 10) |
Permit caller to use the Directory app for selecting to which mailbox to forward a VM
Definition at line 427 of file app_voicemail.c.
Referenced by forward_message(), and load_config().
| #define VM_ENVELOPE (1 << 4) |
Play the envelope information (who-from, time received, etc.)
Definition at line 421 of file app_voicemail.c.
Referenced by apply_option(), load_config(), manager_list_voicemail_users(), and play_message().
| #define VM_FORCEGREET (1 << 8) |
Have new users record their greetings
Definition at line 425 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 424 of file app_voicemail.c.
Referenced by apply_option(), load_config(), vm_execmain(), and vm_newuser().
| #define VM_FWDURGAUTO (1 << 18) |
Autoset of Urgent flag on forwarded Urgent messages set globally
Definition at line 435 of file app_voicemail.c.
Referenced by forward_message(), and load_config().
| #define VM_MESSAGEWRAP (1 << 17) |
Wrap around from the last message to the first, and vice-versa
Definition at line 434 of file app_voicemail.c.
Referenced by apply_option(), load_config(), vm_execmain(), and vm_instructions_en().
| #define VM_MOVEHEARD (1 << 16) |
Move a "heard" message to Old after listening to it
Definition at line 433 of file app_voicemail.c.
Referenced by apply_option(), close_mailbox(), and load_config().
| #define VM_OPERATOR (1 << 1) |
Allow 0 to be pressed to go to 'o' extension
Definition at line 418 of file app_voicemail.c.
Referenced by apply_option(), leave_voicemail(), load_config(), manager_list_voicemail_users(), and play_record_review().
| #define VM_PBXSKIP (1 << 9) |
Skip the [PBX] preamble in the Subject line of emails
Definition at line 426 of file app_voicemail.c.
Referenced by load_config(), and make_email_file().
| #define VM_REVIEW (1 << 0) |
After recording, permit the caller to review the recording before saving
Definition at line 417 of file app_voicemail.c.
Referenced by apply_option(), load_config(), manager_list_voicemail_users(), and play_record_review().
| #define VM_SAYCID (1 << 2) |
Repeat the CallerID info during envelope playback
Definition at line 419 of file app_voicemail.c.
Referenced by apply_option(), load_config(), manager_list_voicemail_users(), and play_message().
| #define VM_SAYDURATION (1 << 5) |
Play the length of the message during envelope playback
Definition at line 422 of file app_voicemail.c.
Referenced by apply_option(), load_config(), and play_message().
| #define VM_SEARCH (1 << 14) |
Search all contexts for a matching mailbox
Definition at line 431 of file app_voicemail.c.
Referenced by find_or_create(), find_user(), find_user_realtime(), and load_config().
| #define VM_SKIPAFTERCMD (1 << 6) |
After deletion, assume caller wants to go to the next message
Definition at line 423 of file app_voicemail.c.
Referenced by load_config(), and vm_execmain().
| #define VM_SVMAIL (1 << 3) |
Allow the user to compose a new VM from within VoicemailMain
Definition at line 420 of file app_voicemail.c.
Referenced by apply_option(), load_config(), and vm_execmain().
| #define VM_TEMPGREETWARN (1 << 15) |
Remind user tempgreeting is set
Definition at line 432 of file app_voicemail.c.
Referenced by apply_option(), load_config(), and vm_intro().
| #define VMSTATE_MAX_MSG_ARRAY 256 |
Definition at line 617 of file app_voicemail.c.
| #define VOICEMAIL_CONFIG "voicemail.conf" |
Definition at line 382 of file app_voicemail.c.
| #define VOICEMAIL_DIR_MODE 0777 |
Definition at line 378 of file app_voicemail.c.
| #define VOICEMAIL_FILE_MODE 0666 |
Definition at line 379 of file app_voicemail.c.
Referenced by add_email_attachment(), copy(), leave_voicemail(), and vm_mkftemp().
| anonymous enum |
Definition at line 440 of file app_voicemail.c.
00440 { 00441 NEW_FOLDER, 00442 OLD_FOLDER, 00443 WORK_FOLDER, 00444 FAMILY_FOLDER, 00445 FRIENDS_FOLDER, 00446 GREETINGS_FOLDER 00447 } vm_box;
| anonymous enum |
| OPT_SILENT | |
| OPT_BUSY_GREETING | |
| OPT_UNAVAIL_GREETING | |
| OPT_RECORDGAIN | |
| OPT_PREPEND_MAILBOX | |
| OPT_AUTOPLAY | |
| OPT_DTMFEXIT | |
| OPT_MESSAGE_Urgent | |
| OPT_MESSAGE_PRIORITY |
Definition at line 449 of file app_voicemail.c.
00449 { 00450 OPT_SILENT = (1 << 0), 00451 OPT_BUSY_GREETING = (1 << 1), 00452 OPT_UNAVAIL_GREETING = (1 << 2), 00453 OPT_RECORDGAIN = (1 << 3), 00454 OPT_PREPEND_MAILBOX = (1 << 4), 00455 OPT_AUTOPLAY = (1 << 6), 00456 OPT_DTMFEXIT = (1 << 7), 00457 OPT_MESSAGE_Urgent = (1 << 8), 00458 OPT_MESSAGE_PRIORITY = (1 << 9) 00459 } vm_option_flags;
| anonymous enum |
Definition at line 461 of file app_voicemail.c.
00461 { 00462 OPT_ARG_RECORDGAIN = 0, 00463 OPT_ARG_PLAYFOLDER = 1, 00464 OPT_ARG_DTMFEXIT = 2, 00465 /* This *must* be the last value in this enum! */ 00466 OPT_ARG_ARRAY_SIZE = 3, 00467 } vm_option_args;
| static int __has_voicemail | ( | const char * | context, | |
| const char * | mailbox, | |||
| const char * | folder, | |||
| int | shortcircuit | |||
| ) | [static] |
Definition at line 5041 of file app_voicemail.c.
References ast_strlen_zero().
Referenced by has_voicemail(), inboxcount2(), and messagecount().
05042 { 05043 DIR *dir; 05044 struct dirent *de; 05045 char fn[256]; 05046 int ret = 0; 05047 05048 /* If no mailbox, return immediately */ 05049 if (ast_strlen_zero(mailbox)) 05050 return 0; 05051 05052 if (ast_strlen_zero(folder)) 05053 folder = "INBOX"; 05054 if (ast_strlen_zero(context)) 05055 context = "default"; 05056 05057 snprintf(fn, sizeof(fn), "%s%s/%s/%s", VM_SPOOL_DIR, context, mailbox, folder); 05058 05059 if (!(dir = opendir(fn))) 05060 return 0; 05061 05062 while ((de = readdir(dir))) { 05063 if (!strncasecmp(de->d_name, "msg", 3)) { 05064 if (shortcircuit) { 05065 ret = 1; 05066 break; 05067 } else if (!strncasecmp(de->d_name + 8, "txt", 3)) { 05068 ret++; 05069 } 05070 } 05071 } 05072 05073 closedir(dir); 05074 05075 return ret; 05076 }
| static void __reg_module | ( | void | ) | [static] |
Definition at line 12023 of file app_voicemail.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 12023 of file app_voicemail.c.
| static int acf_mailbox_exists | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | args, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 10156 of file app_voicemail.c.
References AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_strlen_zero(), find_user(), LOG_ERROR, and mbox().
10157 { 10158 struct ast_vm_user svm; 10159 AST_DECLARE_APP_ARGS(arg, 10160 AST_APP_ARG(mbox); 10161 AST_APP_ARG(context); 10162 ); 10163 10164 AST_NONSTANDARD_APP_ARGS(arg, args, '@'); 10165 10166 if (ast_strlen_zero(arg.mbox)) { 10167 ast_log(LOG_ERROR, "MAILBOX_EXISTS requires an argument (<mailbox>[@<context>])\n"); 10168 return -1; 10169 } 10170 10171 ast_copy_string(buf, find_user(&svm, ast_strlen_zero(arg.context) ? "default" : arg.context, arg.mbox) ? "1" : "0", len); 10172 return 0; 10173 }
| static int add_email_attachment | ( | FILE * | p, | |
| struct ast_vm_user * | vmu, | |||
| char * | format, | |||
| char * | attach, | |||
| char * | greeting_attachment, | |||
| char * | mailbox, | |||
| char * | bound, | |||
| char * | filename, | |||
| int | last, | |||
| int | msgnum | |||
| ) | [static] |
Definition at line 4522 of file app_voicemail.c.
References ast_debug, ast_log(), ast_safe_system(), base_encode(), ast_vm_user::context, create_dirpath(), ENDL, LOG_WARNING, ast_vm_user::mailbox, VOICEMAIL_FILE_MODE, and ast_vm_user::volgain.
Referenced by make_email_file().
04523 { 04524 char tmpdir[256], newtmp[256]; 04525 char fname[256]; 04526 char tmpcmd[256]; 04527 int tmpfd = -1; 04528 04529 /* Eww. We want formats to tell us their own MIME type */ 04530 char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-"; 04531 04532 if (vmu->volgain < -.001 || vmu->volgain > .001) { 04533 create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp"); 04534 snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir); 04535 tmpfd = mkstemp(newtmp); 04536 chmod(newtmp, VOICEMAIL_FILE_MODE & ~my_umask); 04537 ast_debug(3, "newtmp: %s\n", newtmp); 04538 if (tmpfd > -1) { 04539 int soxstatus; 04540 snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format); 04541 if ((soxstatus = ast_safe_system(tmpcmd)) == 0) { 04542 attach = newtmp; 04543 ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox); 04544 } else { 04545 ast_log(LOG_WARNING, "Sox failed to re-encode %s.%s: %s (have you installed support for all sox file formats?)\n", attach, format, 04546 soxstatus == 1 ? "Problem with command line options" : "An error occurred during file processing"); 04547 ast_log(LOG_WARNING, "Voicemail attachment will have no volume gain.\n"); 04548 } 04549 } 04550 } 04551 fprintf(p, "--%s" ENDL, bound); 04552 if (msgnum > -1) 04553 fprintf(p, "Content-Type: %s%s; name=\"%s\"" ENDL, ctype, format, filename); 04554 else 04555 fprintf(p, "Content-Type: %s%s; name=\"%s.%s\"" ENDL, ctype, format, greeting_attachment, format); 04556 fprintf(p, "Content-Transfer-Encoding: base64" ENDL); 04557 fprintf(p, "Content-Description: Voicemail sound attachment." ENDL); 04558 if (msgnum > -1) 04559 fprintf(p, "Content-Disposition: attachment; filename=\"%s\"" ENDL ENDL, filename); 04560 else 04561 fprintf(p, "Content-Disposition: attachment; filename=\"%s.%s\"" ENDL ENDL, greeting_attachment, format); 04562 snprintf(fname, sizeof(fname), "%s.%s", attach, format); 04563 base_encode(fname, p); 04564 if (last) 04565 fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound); 04566 if (tmpfd > -1) { 04567 unlink(fname); 04568 close(tmpfd); 04569 unlink(newtmp); 04570 } 04571 return 0; 04572 }
| static void adsi_begin | ( | struct ast_channel * | chan, | |
| int * | useadsi | |||
| ) | [static] |
Definition at line 5976 of file app_voicemail.c.
References adsi_load_vmail(), adsifdn, adsiver, ast_adsi_available, ast_adsi_load_session, ast_log(), and AST_LOG_WARNING.
Referenced by vm_authenticate(), and vm_execmain().
05977 { 05978 int x; 05979 if (!ast_adsi_available(chan)) 05980 return; 05981 x = ast_adsi_load_session(chan, adsifdn, adsiver, 1); 05982 if (x < 0) 05983 return; 05984 if (!x) { 05985 if (adsi_load_vmail(chan, useadsi)) { 05986 ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n"); 05987 return; 05988 } 05989 } else 05990 *useadsi = 1; 05991 }
| static void adsi_delete | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 6165 of file app_voicemail.c.
References ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_set_keys, ast_adsi_transmit_message, ast_adsi_voice_mode, vm_state::curmsg, vm_state::deleted, and vm_state::lastmsg.
Referenced by vm_execmain().
06166 { 06167 int bytes=0; 06168 unsigned char buf[256]; 06169 unsigned char keys[8]; 06170 06171 int x; 06172 06173 if (!ast_adsi_available(chan)) 06174 return; 06175 06176 /* New meaning for keys */ 06177 for (x=0;x<5;x++) 06178 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x); 06179 06180 keys[6] = 0x0; 06181 keys[7] = 0x0; 06182 06183 if (!vms->curmsg) { 06184 /* No prev key, provide "Folder" instead */ 06185 keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1); 06186 } 06187 if (vms->curmsg >= vms->lastmsg) { 06188 /* If last message ... */ 06189 if (vms->curmsg) { 06190 /* but not only message, provide "Folder" instead */ 06191 keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1); 06192 } else { 06193 /* Otherwise if only message, leave blank */ 06194 keys[3] = 1; 06195 } 06196 } 06197 06198 /* If deleted, show "undeleted" */ 06199 if (vms->deleted[vms->curmsg]) 06200 keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11); 06201 06202 /* Except "Exit" */ 06203 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5); 06204 bytes += ast_adsi_set_keys(buf + bytes, keys); 06205 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06206 06207 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06208 }
| static void adsi_folders | ( | struct ast_channel * | chan, | |
| int | start, | |||
| char * | label | |||
| ) | [static] |
Definition at line 6041 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_CENT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_keys, ast_adsi_set_line, ast_adsi_transmit_message, and ast_adsi_voice_mode.
Referenced by vm_execmain().
06042 { 06043 unsigned char buf[256]; 06044 int bytes=0; 06045 unsigned char keys[8]; 06046 int x,y; 06047 06048 if (!ast_adsi_available(chan)) 06049 return; 06050 06051 for (x=0;x<5;x++) { 06052 y = ADSI_KEY_APPS + 12 + start + x; 06053 if (y > ADSI_KEY_APPS + 12 + 4) 06054 y = 0; 06055 keys[x] = ADSI_KEY_SKT | y; 06056 } 06057 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17); 06058 keys[6] = 0; 06059 keys[7] = 0; 06060 06061 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, ""); 06062 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", ""); 06063 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 06064 bytes += ast_adsi_set_keys(buf + bytes, keys); 06065 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06066 06067 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06068 }
| static void adsi_goodbye | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 6313 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_CENT, ADSI_JUST_LEFT, adsi_logo(), ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_line, ast_adsi_transmit_message, and ast_adsi_voice_mode.
Referenced by vm_execmain().
06314 { 06315 unsigned char buf[256]; 06316 int bytes=0; 06317 06318 if (!ast_adsi_available(chan)) 06319 return; 06320 bytes += adsi_logo(buf + bytes); 06321 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", ""); 06322 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", ""); 06323 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 06324 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06325 06326 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06327 }
| static int adsi_load_vmail | ( | struct ast_channel * | chan, | |
| int * | useadsi | |||
| ) | [static] |
Definition at line 5847 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_KEY_APPS, adsi_logo(), ADSI_MSG_DISPLAY, ADSI_MSG_DOWNLOAD, adsifdn, adsisec, adsiver, ast_adsi_begin_download, ast_adsi_data_mode, ast_adsi_display, ast_adsi_download_disconnect, ast_adsi_end_download, ast_adsi_load_session, ast_adsi_load_soft_key, ast_adsi_set_line, ast_adsi_transmit_message, ast_adsi_voice_mode, ast_debug, mbox(), and num.
Referenced by adsi_begin().
05848 { 05849 unsigned char buf[256]; 05850 int bytes=0; 05851 int x; 05852 char num[5]; 05853 05854 *useadsi = 0; 05855 bytes += ast_adsi_data_mode(buf + bytes); 05856 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05857 05858 bytes = 0; 05859 bytes += adsi_logo(buf); 05860 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", ""); 05861 #ifdef DISPLAY 05862 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .", ""); 05863 #endif 05864 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05865 bytes += ast_adsi_data_mode(buf + bytes); 05866 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05867 05868 if (ast_adsi_begin_download(chan, addesc, adsifdn, adsisec, adsiver)) { 05869 bytes = 0; 05870 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", ""); 05871 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", ""); 05872 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05873 bytes += ast_adsi_voice_mode(buf + bytes, 0); 05874 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05875 return 0; 05876 } 05877 05878 #ifdef DISPLAY 05879 /* Add a dot */ 05880 bytes = 0; 05881 bytes += ast_adsi_logo(buf); 05882 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", ""); 05883 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ..", ""); 05884 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05885 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05886 #endif 05887 bytes = 0; 05888 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1); 05889 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1); 05890 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advnced", "3", 1); 05891 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1); 05892 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1); 05893 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1); 05894 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD); 05895 05896 #ifdef DISPLAY 05897 /* Add another dot */ 05898 bytes = 0; 05899 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ...", ""); 05900 bytes += ast_adsi_voice_mode(buf + bytes, 0); 05901 05902 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05903 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05904 #endif 05905 05906 bytes = 0; 05907 /* These buttons we load but don't use yet */ 05908 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 6, "Previous", "Prev", "4", 1); 05909 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 8, "Repeat", "Repeat", "5", 1); 05910 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 7, "Delete", "Delete", "7", 1); 05911 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 9, "Next", "Next", "6", 1); 05912 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 10, "Save", "Save", "9", 1); 05913 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 11, "Undelete", "Restore", "7", 1); 05914 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD); 05915 05916 #ifdef DISPLAY 05917 /* Add another dot */ 05918 bytes = 0; 05919 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ....", ""); 05920 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05921 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05922 #endif 05923 05924 bytes = 0; 05925 for (x=0;x<5;x++) { 05926 snprintf(num, sizeof(num), "%d", x); 05927 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(x), mbox(x), num, 1); 05928 } 05929 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + 5, "Cancel", "Cancel", "#", 1); 05930 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD); 05931 05932 #ifdef DISPLAY 05933 /* Add another dot */ 05934 bytes = 0; 05935 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .....", ""); 05936 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05937 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05938 #endif 05939 05940 if (ast_adsi_end_download(chan)) { 05941 bytes = 0; 05942 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Download Unsuccessful.", ""); 05943 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", ""); 05944 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05945 bytes += ast_adsi_voice_mode(buf + bytes, 0); 05946 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05947 return 0; 05948 } 05949 bytes = 0; 05950 bytes += ast_adsi_download_disconnect(buf + bytes); 05951 bytes += ast_adsi_voice_mode(buf + bytes, 0); 05952 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD); 05953 05954 ast_debug(1, "Done downloading scripts...\n"); 05955 05956 #ifdef DISPLAY 05957 /* Add last dot */ 05958 bytes = 0; 05959 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", ""); 05960 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 05961 #endif 05962 ast_debug(1, "Restarting session...\n"); 05963 05964 bytes = 0; 05965 /* Load the session now */ 05966 if (ast_adsi_load_session(chan, adsifdn, adsiver, 1) == 1) { 05967 *useadsi = 1; 05968 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", ""); 05969 } else 05970 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Failed!", ""); 05971 05972 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 05973 return 0; 05974 }
| static void adsi_login | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 5993 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_DIR_FROM_LEFT, ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_KEY_APPS, adsi_logo(), ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_input_control, ast_adsi_input_format, ast_adsi_load_soft_key, ast_adsi_set_keys, ast_adsi_set_line, ast_adsi_transmit_message, and ast_adsi_voice_mode.
Referenced by vm_authenticate().
05994 { 05995 unsigned char buf[256]; 05996 int bytes=0; 05997 unsigned char keys[8]; 05998 int x; 05999 if (!ast_adsi_available(chan)) 06000 return; 06001 06002 for (x=0;x<8;x++) 06003 keys[x] = 0; 06004 /* Set one key for next */ 06005 keys[3] = ADSI_KEY_APPS + 3; 06006 06007 bytes += adsi_logo(buf + bytes); 06008 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, " ", ""); 06009 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ", ""); 06010 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 06011 bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Mailbox: ******", ""); 06012 bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 1, 1, ADSI_JUST_LEFT); 06013 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Enter", "Enter", "#", 1); 06014 bytes += ast_adsi_set_keys(buf + bytes, keys); 06015 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06016 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06017 }
| static int adsi_logo | ( | unsigned char * | buf | ) | [static] |
Definition at line 5839 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_CENT, and ast_adsi_display.
Referenced by adsi_goodbye(), adsi_load_vmail(), adsi_login(), vm_newuser(), vm_options(), and vm_tempgreeting().
05840 { 05841 int bytes = 0; 05842 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", ""); 05843 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", ""); 05844 return bytes; 05845 }
| static void adsi_message | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 6070 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_keys, ast_adsi_set_line, ast_adsi_transmit_message, ast_adsi_voice_mode, ast_callerid_parse(), ast_copy_string(), ast_strlen_zero(), buf1, buf2, vm_state::curbox, vm_state::curmsg, vm_state::deleted, vm_state::fn, vm_state::lastmsg, num, and strsep().
Referenced by play_message(), and vm_execmain().
06071 { 06072 int bytes=0; 06073 unsigned char buf[256]; 06074 char buf1[256], buf2[256]; 06075 char fn2[PATH_MAX]; 06076 06077 char cid[256]=""; 06078 char *val; 06079 char *name, *num; 06080 char datetime[21]=""; 06081 FILE *f; 06082 06083 unsigned char keys[8]; 06084 06085 int x; 06086 06087 if (!ast_adsi_available(chan)) 06088 return; 06089 06090 /* Retrieve important info */ 06091 snprintf(fn2, sizeof(fn2), "%s.txt", vms->fn); 06092 f = fopen(fn2, "r"); 06093 if (f) { 06094 while (!feof(f)) { 06095 if (!fgets((char *)buf, sizeof(buf), f)) { 06096 continue; 06097 } 06098 if (!feof(f)) { 06099 char *stringp=NULL; 06100 stringp = (char *)buf; 06101 strsep(&stringp, "="); 06102 val = strsep(&stringp, "="); 06103 if (!ast_strlen_zero(val)) { 06104 if (!strcmp((char *)buf, "callerid")) 06105 ast_copy_string(cid, val, sizeof(cid)); 06106 if (!strcmp((char *)buf, "origdate")) 06107 ast_copy_string(datetime, val, sizeof(datetime)); 06108 } 06109 } 06110 } 06111 fclose(f); 06112 } 06113 /* New meaning for keys */ 06114 for (x=0;x<5;x++) 06115 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x); 06116 keys[6] = 0x0; 06117 keys[7] = 0x0; 06118 06119 if (!vms->curmsg) { 06120 /* No prev key, provide "Folder" instead */ 06121 keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1); 06122 } 06123 if (vms->curmsg >= vms->lastmsg) { 06124 /* If last message ... */ 06125 if (vms->curmsg) { 06126 /* but not only message, provide "Folder" instead */ 06127 keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1); 06128 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06129 06130 } else { 06131 /* Otherwise if only message, leave blank */ 06132 keys[3] = 1; 06133 } 06134 } 06135 06136 if (!ast_strlen_zero(cid)) { 06137 ast_callerid_parse(cid, &name, &num); 06138 if (!name) 06139 name = num; 06140 } else 06141 name = "Unknown Caller"; 06142 06143 /* If deleted, show "undeleted" */ 06144 06145 if (vms->deleted[vms->curmsg]) 06146 keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11); 06147 06148 /* Except "Exit" */ 06149 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5); 06150 snprintf(buf1, sizeof(buf1), "%s%s", vms->curbox, 06151 strcasecmp(vms->curbox, "INBOX") ? " Messages" : ""); 06152 snprintf(buf2, sizeof(buf2), "Message %d of %d", vms->curmsg + 1, vms->lastmsg + 1); 06153 06154 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, ""); 06155 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, ""); 06156 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, name, ""); 06157 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, datetime, ""); 06158 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 06159 bytes += ast_adsi_set_keys(buf + bytes, keys); 06160 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06161 06162 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06163 }
| static void adsi_password | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 6019 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_DIR_FROM_LEFT, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_input_control, ast_adsi_input_format, ast_adsi_set_keys, ast_adsi_set_line, ast_adsi_transmit_message, and ast_adsi_voice_mode.
Referenced by vm_authenticate().
06020 { 06021 unsigned char buf[256]; 06022 int bytes=0; 06023 unsigned char keys[8]; 06024 int x; 06025 if (!ast_adsi_available(chan)) 06026 return; 06027 06028 for (x=0;x<8;x++) 06029 keys[x] = 0; 06030 /* Set one key for next */ 06031 keys[3] = ADSI_KEY_APPS + 3; 06032 06033 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 06034 bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", ""); 06035 bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT); 06036 bytes += ast_adsi_set_keys(buf + bytes, keys); 06037 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06038 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06039 }
| static void adsi_status | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 6210 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_keys, ast_adsi_set_line, ast_adsi_transmit_message, ast_adsi_voice_mode, buf1, buf2, vm_state::lastmsg, vm_state::newmessages, and vm_state::oldmessages.
Referenced by vm_execmain().
06211 { 06212 unsigned char buf[256] = ""; 06213 char buf1[256] = "", buf2[256] = ""; 06214 int bytes=0; 06215 unsigned char keys[8]; 06216 int x; 06217 06218 char *newm = (vms->newmessages == 1) ? "message" : "messages"; 06219 char *oldm = (vms->oldmessages == 1) ? "message" : "messages"; 06220 if (!ast_adsi_available(chan)) 06221 return; 06222 if (vms->newmessages) { 06223 snprintf(buf1, sizeof(buf1), "You have %d new", vms->newmessages); 06224 if (vms->oldmessages) { 06225 strncat(buf1, " and", sizeof(buf1) - strlen(buf1) - 1); 06226 snprintf(buf2, sizeof(buf2), "%d old %s.", vms->oldmessages, oldm); 06227 } else { 06228 snprintf(buf2, sizeof(buf2), "%s.", newm); 06229 } 06230 } else if (vms->oldmessages) { 06231 snprintf(buf1, sizeof(buf1), "You have %d old", vms->oldmessages); 06232 snprintf(buf2, sizeof(buf2), "%s.", oldm); 06233 } else { 06234 strcpy(buf1, "You have no messages."); 06235 buf2[0] = ' '; 06236 buf2[1] = '\0'; 06237 } 06238 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, ""); 06239 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, ""); 06240 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 06241 06242 for (x=0;x<6;x++) 06243 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x); 06244 keys[6] = 0; 06245 keys[7] = 0; 06246 06247 /* Don't let them listen if there are none */ 06248 if (vms->lastmsg < 0) 06249 keys[0] = 1; 06250 bytes += ast_adsi_set_keys(buf + bytes, keys); 06251 06252 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06253 06254 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06255 }
| static void adsi_status2 | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 6257 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_keys, ast_adsi_set_line, ast_adsi_transmit_message, ast_adsi_voice_mode, buf1, buf2, vm_state::curbox, and vm_state::lastmsg.
Referenced by vm_execmain().
06258 { 06259 unsigned char buf[256] = ""; 06260 char buf1[256] = "", buf2[256] = ""; 06261 int bytes=0; 06262 unsigned char keys[8]; 06263 int x; 06264 06265 char *mess = (vms->lastmsg == 0) ? "message" : "messages"; 06266 06267 if (!ast_adsi_available(chan)) 06268 return; 06269 06270 /* Original command keys */ 06271 for (x=0;x<6;x++) 06272 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x); 06273 06274 keys[6] = 0; 06275 keys[7] = 0; 06276 06277 if ((vms->lastmsg + 1) < 1) 06278 keys[0] = 0; 06279 06280 snprintf(buf1, sizeof(buf1), "%s%s has", vms->curbox, 06281 strcasecmp(vms->curbox, "INBOX") ? " folder" : ""); 06282 06283 if (vms->lastmsg + 1) 06284 snprintf(buf2, sizeof(buf2), "%d %s.", vms->lastmsg + 1, mess); 06285 else 06286 strcpy(buf2, "no messages."); 06287 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, ""); 06288 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, ""); 06289 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, "", ""); 06290 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 06291 bytes += ast_adsi_set_keys(buf + bytes, keys); 06292 06293 bytes += ast_adsi_voice_mode(buf + bytes, 0); 06294 06295 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 06296 06297 }
| static 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] |
The advanced options within a message.
| chan | ||
| vmu | ||
| vms | ||
| msg | ||
| option | ||
| record_gain | Provides handling for the play message envelope, call the person back, or reply to message. |
Definition at line 11590 of file app_voicemail.c.
References ast_callerid_parse(), ast_config_destroy(), ast_config_load, ast_log(), AST_LOG_WARNING, AST_MAX_EXTENSION, ast_play_and_wait(), ast_strdupa, ast_strlen_zero(), ast_variable_retrieve(), ast_verb, ast_waitfordigit(), ast_vm_user::callback, CONFIG_FLAG_NOCACHE, CONFIG_STATUS_FILEINVALID, ast_vm_user::context, vm_state::curdir, vm_state::curmsg, ast_vm_user::dialout, dialout(), DISPOSE, find_user(), vm_state::fn, vm_state::heard, leave_voicemail(), ast_vm_user::mailbox, make_file(), num, play_message_callerid(), play_message_datetime(), leave_vm_options::record_gain, RETRIEVE, vm_state::starting, and wait_file().
Referenced by vm_execmain().
11591 { 11592 int res = 0; 11593 char filename[PATH_MAX]; 11594 struct ast_config *msg_cfg = NULL; 11595 const char *origtime, *context; 11596 char *name, *num; 11597 int retries = 0; 11598 char *cid; 11599 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE, }; 11600 11601 vms->starting = 0; 11602 11603 make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg); 11604 11605 /* Retrieve info from VM attribute file */ 11606 snprintf(filename,sizeof(filename), "%s.txt", vms->fn); 11607 RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context); 11608 msg_cfg = ast_config_load(filename, config_flags); 11609 DISPOSE(vms->curdir, vms->curmsg); 11610 if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) { 11611 ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename); 11612 return 0; 11613 } 11614 11615 if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) { 11616 ast_config_destroy(msg_cfg); 11617 return 0; 11618 } 11619 11620 cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid")); 11621 11622 context = ast_variable_retrieve(msg_cfg, "message", "context"); 11623 if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */ 11624 context = ast_variable_retrieve(msg_cfg, "message","macrocontext"); 11625 switch (option) { 11626 case 3: /* Play message envelope */ 11627 if (!res) 11628 res = play_message_datetime(chan, vmu, origtime, filename); 11629 if (!res) 11630 res = play_message_callerid(chan, vms, cid, context, 0); 11631 11632 res = 't'; 11633 break; 11634 11635 case 2: /* Call back */ 11636 11637 if (ast_strlen_zero(cid)) 11638 break; 11639 11640 ast_callerid_parse(cid, &name, &num); 11641 while ((res > -1) && (res != 't')) { 11642 switch (res) { 11643 case '1': 11644 if (num) { 11645 /* Dial the CID number */ 11646 res = dialout(chan, vmu, num, vmu->callback); 11647 if (res) { 11648 ast_config_destroy(msg_cfg); 11649 return 9; 11650 } 11651 } else { 11652 res = '2'; 11653 } 11654 break; 11655 11656 case '2': 11657 /* Want to enter a different number, can only do this if there's a dialout context for this user */ 11658 if (!ast_strlen_zero(vmu->dialout)) { 11659 res = dialout(chan, vmu, NULL, vmu->dialout); 11660 if (res) { 11661 ast_config_destroy(msg_cfg); 11662 return 9; 11663 } 11664 } else { 11665 ast_verb(3, "Caller can not specify callback number - no dialout context available\n"); 11666 res = ast_play_and_wait(chan, "vm-sorry"); 11667 } 11668 ast_config_destroy(msg_cfg); 11669 return res; 11670 case '*': 11671 res = 't'; 11672 break; 11673 case '3': 11674 case '4': 11675 case '5': 11676 case '6': 11677 case '7': 11678 case '8': 11679 case '9': 11680 case '0': 11681 11682 res = ast_play_and_wait(chan, "vm-sorry"); 11683 retries++; 11684 break; 11685 default: 11686 if (num) { 11687 ast_verb(3, "Confirm CID number '%s' is number to use for callback\n", num); 11688 res = ast_play_and_wait(chan, "vm-num-i-have"); 11689 if (!res) 11690 res = play_message_callerid(chan, vms, num, vmu->context, 1); 11691 if (!res) 11692 res = ast_play_and_wait(chan, "vm-tocallnum"); 11693 /* Only prompt for a caller-specified number if there is a dialout context specified */ 11694 if (!ast_strlen_zero(vmu->dialout)) { 11695 if (!res) 11696 res = ast_play_and_wait(chan, "vm-calldiffnum"); 11697 } 11698 } else { 11699 res = ast_play_and_wait(chan, "vm-nonumber"); 11700 if (!ast_strlen_zero(vmu->dialout)) { 11701 if (!res) 11702 res = ast_play_and_wait(chan, "vm-toenternumber"); 11703 } 11704 } 11705 if (!res) 11706 res = ast_play_and_wait(chan, "vm-star-cancel"); 11707 if (!res) 11708 res = ast_waitfordigit(chan, 6000); 11709 if (!res) { 11710 retries++; 11711 if (retries > 3) 11712 res = 't'; 11713 } 11714 break; 11715 11716 } 11717 if (res == 't') 11718 res = 0; 11719 else if (res == '*') 11720 res = -1; 11721 } 11722 break; 11723 11724 case 1: /* Reply */ 11725 /* Send reply directly to sender */ 11726 if (ast_strlen_zero(cid)) 11727 break; 11728 11729 ast_callerid_parse(cid, &name, &num); 11730 if (!num) { 11731 ast_verb(3, "No CID number available, no reply sent\n"); 11732 if (!res) 11733 res = ast_play_and_wait(chan, "vm-nonumber"); 11734 ast_config_destroy(msg_cfg); 11735 return res; 11736 } else { 11737 struct ast_vm_user vmu2; 11738 if (find_user(&vmu2, vmu->context, num)) { 11739 struct leave_vm_options leave_options; 11740 char mailbox[AST_MAX_EXTENSION * 2 + 2]; 11741 snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context); 11742 11743 ast_verb(3, "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context); 11744 11745 memset(&leave_options, 0, sizeof(leave_options)); 11746 leave_options.record_gain = record_gain; 11747 res = leave_voicemail(chan, mailbox, &leave_options); 11748 if (!res) 11749 res = 't'; 11750 ast_config_destroy(msg_cfg); 11751 return res; 11752 } else { 11753 /* Sender has no mailbox, can't reply */ 11754 ast_verb(3, "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context); 11755 ast_play_and_wait(chan, "vm-nobox"); 11756 res = 't'; 11757 ast_config_destroy(msg_cfg); 11758 return res; 11759 } 11760 } 11761 res = 0; 11762 11763 break; 11764 } 11765 11766 #ifndef IMAP_STORAGE 11767 ast_config_destroy(msg_cfg); 11768 11769 if (!res) { 11770 make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg); 11771 vms->heard[msg] = 1; 11772 res = wait_file(chan, vms, vms->fn); 11773 } 11774 #endif 11775 return res; 11776 }
| static int append_mailbox | ( | const char * | context, | |
| const char * | box, | |||
| const char * | data | |||
| ) | [static] |
Definition at line 10076 of file app_voicemail.c.
References apply_options(), ast_copy_string(), ast_strdupa, ast_vm_user::email, find_or_create(), ast_vm_user::fullname, inboxcount2(), ast_vm_user::pager, ast_vm_user::password, populate_defaults(), queue_mwi_event(), s, and strsep().
Referenced by load_config().
10077 { 10078 /* Assumes lock is already held */ 10079 char *tmp; 10080 char *stringp; 10081 char *s; 10082 struct ast_vm_user *vmu; 10083 char *mailbox_full; 10084 int new = 0, old = 0, urgent = 0; 10085 10086 tmp = ast_strdupa(data); 10087 10088 if (!(vmu = find_or_create(context, box))) 10089 return -1; 10090 10091 populate_defaults(vmu); 10092 10093 stringp = tmp; 10094 if ((s = strsep(&stringp, ","))) 10095 ast_copy_string(vmu->password, s, sizeof(vmu->password)); 10096 if (stringp && (s = strsep(&stringp, ","))) 10097 ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname)); 10098 if (stringp && (s = strsep(&stringp, ","))) 10099 ast_copy_string(vmu->email, s, sizeof(vmu->email)); 10100 if (stringp && (s = strsep(&stringp, ","))) 10101 ast_copy_string(vmu->pager, s, sizeof(vmu->pager)); 10102 if (stringp && (s = strsep(&stringp, ","))) 10103 apply_options(vmu, s); 10104 10105 mailbox_full = alloca(strlen(box) + strlen(context) + 1); 10106 strcpy(mailbox_full, box); 10107 strcat(mailbox_full, "@"); 10108 strcat(mailbox_full, context); 10109 10110 inboxcount2(mailbox_full, &urgent, &new, &old); 10111 queue_mwi_event(mailbox_full, urgent, new, old); 10112 10113 return 0; 10114 }
| static void apply_option | ( | struct ast_vm_user * | vmu, | |
| const char * | var, | |||
| const char * | value | |||
| ) | [static] |
Sets a a specific property value.
| vmu | The voicemail user object to work with. | |
| var | The name of the property to be set. | |
| value | The value to be set to the property. |
Definition at line 958 of file app_voicemail.c.
References apply_options(), ast_copy_string(), ast_log(), AST_LOG_WARNING, ast_set2_flag, ast_true(), ast_vm_user::attachfmt, ast_vm_user::callback, ast_vm_user::dialout, ast_vm_user::exit, ast_vm_user::language, ast_vm_user::maxdeletedmsg, MAXMSG, ast_vm_user::maxmsg, MAXMSGLIMIT, ast_vm_user::maxsecs, ast_vm_user::saydurationm, ast_vm_user::serveremail, VM_ATTACH, VM_DELETE, VM_ENVELOPE, VM_FORCEGREET, VM_FORCENAME, VM_MESSAGEWRAP, VM_MOVEHEARD, VM_OPERATOR, VM_REVIEW, VM_SAYCID, VM_SAYDURATION, VM_SVMAIL, VM_TEMPGREETWARN, ast_vm_user::volgain, and ast_vm_user::zonetag.
Referenced by apply_options(), and apply_options_full().
00959 { 00960 int x; 00961 if (!strcasecmp(var, "attach")) { 00962 ast_set2_flag(vmu, ast_true(value), VM_ATTACH); 00963 } else if (!strcasecmp(var, "attachfmt")) { 00964 ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt)); 00965 } else if (!strcasecmp(var, "serveremail")) { 00966 ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail)); 00967 } else if (!strcasecmp(var, "language")) { 00968 ast_copy_string(vmu->language, value, sizeof(vmu->language)); 00969 } else if (!strcasecmp(var, "tz")) { 00970 ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag)); 00971 #ifdef IMAP_STORAGE 00972 } else if (!strcasecmp(var, "imapuser")) { 00973 ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser)); 00974 vmu->imapversion = imapversion; 00975 } else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) { 00976 ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword)); 00977 vmu->imapversion = imapversion; 00978 } else if (!strcasecmp(var, "imapvmshareid")) { 00979 ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid)); 00980 vmu->imapversion = imapversion; 00981 #endif 00982 } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) { 00983 ast_set2_flag(vmu, ast_true(value), VM_DELETE); 00984 } else if (!strcasecmp(var, "saycid")){ 00985 ast_set2_flag(vmu, ast_true(value), VM_SAYCID); 00986 } else if (!strcasecmp(var,"sendvoicemail")){ 00987 ast_set2_flag(vmu, ast_true(value), VM_SVMAIL); 00988 } else if (!strcasecmp(var, "review")){ 00989 ast_set2_flag(vmu, ast_true(value), VM_REVIEW); 00990 } else if (!strcasecmp(var, "tempgreetwarn")){ 00991 ast_set2_flag(vmu, ast_true(value), VM_TEMPGREETWARN); 00992 } else if (!strcasecmp(var, "messagewrap")){ 00993 ast_set2_flag(vmu, ast_true(value), VM_MESSAGEWRAP); 00994 } else if (!strcasecmp(var, "operator")) { 00995 ast_set2_flag(vmu, ast_true(value), VM_OPERATOR); 00996 } else if (!strcasecmp(var, "envelope")){ 00997 ast_set2_flag(vmu, ast_true(value), VM_ENVELOPE); 00998 } else if (!strcasecmp(var, "moveheard")){ 00999 ast_set2_flag(vmu, ast_true(value), VM_MOVEHEARD); 01000 } else if (!strcasecmp(var, "sayduration")){ 01001 ast_set2_flag(vmu, ast_true(value), VM_SAYDURATION); 01002 } else if (!strcasecmp(var, "saydurationm")){ 01003 if (sscanf(value, "%30d", &x) == 1) { 01004 vmu->saydurationm = x; 01005 } else { 01006 ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n"); 01007 } 01008 } else if (!strcasecmp(var, "forcename")){ 01009 ast_set2_flag(vmu, ast_true(value), VM_FORCENAME); 01010 } else if (!strcasecmp(var, "forcegreetings")){ 01011 ast_set2_flag(vmu, ast_true(value), VM_FORCEGREET); 01012 } else if (!strcasecmp(var, "callback")) { 01013 ast_copy_string(vmu->callback, value, sizeof(vmu->callback)); 01014 } else if (!strcasecmp(var, "dialout")) { 01015 ast_copy_string(vmu->dialout, value, sizeof(vmu->dialout)); 01016 } else if (!strcasecmp(var, "exitcontext")) { 01017 ast_copy_string(vmu->exit, value, sizeof(vmu->exit)); 01018 } else if (!strcasecmp(var, "maxmessage") || !strcasecmp(var, "maxsecs")) { 01019 vmu->maxsecs = atoi(value); 01020 if (vmu->maxsecs <= 0) { 01021 ast_log(AST_LOG_WARNING, "Invalid max message length of %s. Using global value %d\n", value, vmmaxsecs); 01022 vmu->maxsecs = vmmaxsecs; 01023 } else { 01024 vmu->maxsecs = atoi(value); 01025 } 01026 if (!strcasecmp(var, "maxmessage")) 01027 ast_log(AST_LOG_WARNING, "Option 'maxmessage' has been deprecated in favor of 'maxsecs'. Please make that change in your voicemail config.\n"); 01028 } else if (!strcasecmp(var, "maxmsg")) { 01029 vmu->maxmsg = atoi(value); 01030 if (vmu->maxmsg <= 0) { 01031 ast_log(AST_LOG_WARNING, "Invalid number of messages per folder maxmsg=%s. Using default value %d\n", value, MAXMSG); 01032 vmu->maxmsg = MAXMSG; 01033 } else if (vmu->maxmsg > MAXMSGLIMIT) { 01034 ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %d. Cannot accept value maxmsg=%s\n", MAXMSGLIMIT, value); 01035 vmu->maxmsg = MAXMSGLIMIT; 01036 } 01037 } else if (!strcasecmp(var, "backupdeleted")) { 01038 if (sscanf(value, "%30d", &x) == 1) 01039 vmu->maxdeletedmsg = x; 01040 else if (ast_true(value)) 01041 vmu->maxdeletedmsg = MAXMSG; 01042 else 01043 vmu->maxdeletedmsg = 0; 01044 01045 if (vmu->maxdeletedmsg < 0) { 01046 ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox backupdeleted=%s. Using default value %d\n", value, MAXMSG); 01047 vmu->maxdeletedmsg = MAXMSG; 01048 } else if (vmu->maxdeletedmsg > MAXMSGLIMIT) { 01049 ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %d. Cannot accept value backupdeleted=%s\n", MAXMSGLIMIT, value); 01050 vmu->maxdeletedmsg = MAXMSGLIMIT; 01051 } 01052 } else if (!strcasecmp(var, "volgain")) { 01053 sscanf(value, "%30lf", &vmu->volgain); 01054 } else if (!strcasecmp(var, "options")) { 01055 apply_options(vmu, value); 01056 } 01057 }
| static void apply_options | ( | struct ast_vm_user * | vmu, | |
| const char * | options | |||
| ) | [static] |
Destructively Parse options and apply.
Definition at line 1171 of file app_voicemail.c.
References apply_option(), ast_strdupa, s, strsep(), and var.
Referenced by append_mailbox(), and apply_option().
01172 { 01173 char *stringp; 01174 char *s; 01175 char *var, *value; 01176 stringp = ast_strdupa(options); 01177 while ((s = strsep(&stringp, "|"))) { 01178 value = s; 01179 if ((var = strsep(&value, "=")) && value) { 01180 apply_option(vmu, var, value); 01181 } 01182 } 01183 }
| static void apply_options_full | ( | struct ast_vm_user * | retval, | |
| struct ast_variable * | var | |||
| ) | [static] |
Loads the options specific to a voicemail user.
This is called when a vm_user structure is being set up, such as from load_options.
Definition at line 1190 of file app_voicemail.c.
References apply_option(), ast_copy_string(), ast_strdup, ast_strlen_zero(), ast_vm_user::context, ast_vm_user::email, ast_vm_user::emailbody, ast_vm_user::emailsubject, ast_vm_user::fullname, ast_variable::name, ast_variable::next, ast_vm_user::pager, ast_vm_user::password, ast_vm_user::uniqueid, and ast_variable::value.
Referenced by find_user_realtime(), and load_config().
01191 { 01192 for (; var; var = var->next) { 01193 if (!strcasecmp(var->name, "vmsecret")) { 01194 ast_copy_string(retval->password, var->value, sizeof(retval->password)); 01195 } else if (!strcasecmp(var->name, "secret") || !strcasecmp(var->name, "password")) { /* don't overwrite vmsecret if it exists */ 01196 if (ast_strlen_zero(retval->password)) 01197 ast_copy_string(retval->password, var->value, sizeof(retval->password)); 01198 } else if (!strcasecmp(var->name, "uniqueid")) { 01199 ast_copy_string(retval->uniqueid, var->value, sizeof(retval->uniqueid)); 01200 } else if (!strcasecmp(var->name, "pager")) { 01201 ast_copy_string(retval->pager, var->value, sizeof(retval->pager)); 01202 } else if (!strcasecmp(var->name, "email")) { 01203 ast_copy_string(retval->email, var->value, sizeof(retval->email)); 01204 } else if (!strcasecmp(var->name, "fullname")) { 01205 ast_copy_string(retval->fullname, var->value, sizeof(retval->fullname)); 01206 } else if (!strcasecmp(var->name, "context")) { 01207 ast_copy_string(retval->context, var->value, sizeof(retval->context)); 01208 } else if (!strcasecmp(var->name, "emailsubject")) { 01209 retval->emailsubject = ast_strdup(var->value); 01210 } else if (!strcasecmp(var->name, "emailbody")) { 01211 retval->emailbody = ast_strdup(var->value); 01212 #ifdef IMAP_STORAGE 01213 } else if (!strcasecmp(var->name, "imapuser")) { 01214 ast_copy_string(retval->imapuser, var->value, sizeof(retval->imapuser)); 01215 retval->imapversion = imapversion; 01216 } else if (!strcasecmp(var->name, "imappassword") || !strcasecmp(var->name, "imapsecret")) { 01217 ast_copy_string(retval->imappassword, var->value, sizeof(retval->imappassword)); 01218 retval->imapversion = imapversion; 01219 } else if (!strcasecmp(var->name, "imapvmshareid")) { 01220 ast_copy_string(retval->imapvmshareid, var->value, sizeof(retval->imapvmshareid)); 01221 retval->imapversion = imapversion; 01222 #endif 01223 } else 01224 apply_option(retval, var->name, var->value); 01225 } 01226 }
| static int base_encode | ( | char * | filename, | |
| FILE * | so | |||
| ) | [static] |
Performs a base 64 encode algorithm on the contents of a File.
| filename | The path to the file to be encoded. Must be readable, file is opened in read mode. | |
| so | A FILE handle to the output file to receive the base 64 encoded contents of the input file, identified by filename. |
Definition at line 3997 of file app_voicemail.c.
References ast_log(), AST_LOG_WARNING, BASEMAXINLINE, ENDL, errno, inchar(), baseio::iocp, and ochar().
Referenced by add_email_attachment().
03998 { 03999 static const unsigned char dtable[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 04000 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 04001 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', 04002 '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; 04003 int i,hiteof= 0; 04004 FILE *fi; 04005 struct baseio bio; 04006 04007 memset(&bio, 0, sizeof(bio)); 04008 bio.iocp = BASEMAXINLINE; 04009 04010 if (!(fi = fopen(filename, "rb"))) { 04011 ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s\n", filename, strerror(errno)); 04012 return -1; 04013 } 04014 04015 while (!hiteof){ 04016 unsigned char igroup[3], ogroup[4]; 04017 int c,n; 04018 04019 igroup[0]= igroup[1]= igroup[2]= 0; 04020 04021 for (n= 0;n<3;n++) { 04022 if ((c = inchar(&bio, fi)) == EOF) { 04023 hiteof= 1; 04024 break; 04025 } 04026 04027 igroup[n]= (unsigned char)c; 04028 } 04029 04030 if (n> 0) { 04031 ogroup[0]= dtable[igroup[0]>>2]; 04032 ogroup[1]= dtable[((igroup[0]&3)<<4) | (igroup[1]>>4)]; 04033 ogroup[2]= dtable[((igroup[1]&0xF)<<2) | (igroup[2]>>6)]; 04034 ogroup[3]= dtable[igroup[2]&0x3F]; 04035 04036 if (n<3) { 04037 ogroup[3]= '='; 04038 04039 if (n<2) 04040 ogroup[2]= '='; 04041 } 04042 04043 for (i= 0;i<4;i++) 04044 ochar(&bio, ogroup[i], so); 04045 } 04046 } 04047 04048 fclose(fi); 04049 04050 if (fputs(ENDL, so) == EOF) { 04051 return 0; 04052 } 04053 04054 return 1; 04055 }
| static int change_password_realtime | ( | struct ast_vm_user * | vmu, | |
| const char * | password | |||
| ) | [static] |
Performs a change of the voicemail passowrd in the realtime engine.
| vmu | The voicemail user to change the password for. | |
| password | The new value to be set to the password for this user. |
Definition at line 1150 of file app_voicemail.c.
References ast_copy_string(), ast_realtime_require_field(), ast_update2_realtime(), ast_vm_user::context, ast_vm_user::mailbox, ast_vm_user::password, RQ_CHAR, and SENTINEL.
Referenced by vm_change_password().
01151 { 01152 int res = -1; 01153 if (!strcmp(vmu->password, password)) { 01154 /* No change (but an update would return 0 rows updated, so we opt out here) */ 01155 return 0; 01156 } 01157 01158 if (strlen(password) > 10) { 01159 ast_realtime_require_field("voicemail", "password", RQ_CHAR, strlen(password), SENTINEL); 01160 } 01161 if (ast_update2_realtime("voicemail", "context", vmu->context, "mailbox", vmu->mailbox, SENTINEL, "password", password, SENTINEL) > 0) { 01162 ast_copy_string(vmu->password, password, sizeof(vmu->password)); 01163 res = 0; 01164 } 01165 return res; 01166 }
| static int check_mime | ( | const char * | str | ) | [static] |
Check if the string would need encoding within the MIME standard, to avoid confusing certain mail software that expects messages to be 7-bit clean.
Definition at line 4163 of file app_voicemail.c.
Referenced by make_email_file().
04164 { 04165 for (; *str; str++) { 04166 if (*str > 126 || *str < 32 || strchr("()<>@,:;/\"[]?.=", *str)) { 04167 return 1; 04168 } 04169 } 04170 return 0; 04171 }
| static int check_password | ( | struct ast_vm_user * | vmu, | |
| char * | password | |||
| ) | [static] |
Check that password meets minimum required length.
| vmu | The voicemail user to change the password for. | |
| password | The password string to check |
Definition at line 1112 of file app_voicemail.c.
References ast_debug, ast_log(), AST_LOG_DEBUG, AST_LOG_NOTICE, AST_LOG_WARNING, ast_strlen_zero(), buf, ast_vm_user::context, ast_vm_user::mailbox, ast_vm_user::password, and vm_check_password_shell().
Referenced by vm_newuser(), and vm_options().
01113 { 01114 /* check minimum length */ 01115 if (strlen(password) < minpassword) 01116 return 1; 01117 if (!ast_strlen_zero(ext_pass_check_cmd)) { 01118 char cmd[255], buf[255]; 01119 01120 ast_log(AST_LOG_DEBUG, "Verify password policies for %s\n", password); 01121 01122 snprintf(cmd, sizeof(cmd), "%s %s %s %s %s", ext_pass_check_cmd, vmu->mailbox, vmu->context, vmu->password, password); 01123 if (vm_check_password_shell(cmd, buf, sizeof(buf))) { 01124 ast_debug(5, "Result: %s\n", buf); 01125 if (!strncasecmp(buf, "VALID", 5)) { 01126 ast_debug(3, "Passed password check: '%s'\n", buf); 01127 return 0; 01128 } else if (!strncasecmp(buf, "FAILURE", 7)) { 01129 ast_log(AST_LOG_WARNING, "Unable to execute password validation script: '%s'.\n", buf); 01130 return 0; 01131 } else { 01132 ast_log(AST_LOG_NOTICE, "Password doesn't match policies for user %s %s\n", vmu->mailbox, password); 01133 return 1; 01134 } 01135 } 01136 } 01137 return 0; 01138 }
| static int close_mailbox | ( | struct vm_state * | vms, | |
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Definition at line 7451 of file app_voicemail.c.
References ast_check_realtime(), ast_debug, ast_log(), AST_LOG_WARNING, ast_test_flag, ast_unlock_path(), ast_vm_user::context, vm_state::curbox, vm_state::curdir, vm_state::curmsg, DELETE, vm_state::deleted, vm_state::dh_arraysize, ERROR_LOCK_PATH, EXISTS, vm_state::fn, vm_state::heard, vm_state::lastmsg, ast_vm_user::mailbox, make_file(), ast_vm_user::maxdeletedmsg, RENAME, save_to_folder(), vm_lock_path(), and VM_MOVEHEARD.
Referenced by vm_execmain().
07452 { 07453 int x = 0; 07454 #ifndef IMAP_STORAGE 07455 int res = 0, nummsg; 07456 char fn2[PATH_MAX]; 07457 #endif 07458 07459 if (vms->lastmsg <= -1) { 07460 goto done; 07461 } 07462 07463 vms->curmsg = -1; 07464 #ifndef IMAP_STORAGE 07465 /* Get the deleted messages fixed */ 07466 if (vm_lock_path(vms->curdir)) { 07467 return ERROR_LOCK_PATH; 07468 } 07469 07470 /* must check up to last detected message, just in case it is erroneously greater than maxmsg */ 07471 for (x = 0; x < vms->lastmsg + 1; x++) { 07472 if (!vms->deleted[x] && ((strcasecmp(vms->curbox, "INBOX") && strcasecmp(vms->curbox, "Urgent")) || !vms->heard[x] || (vms->heard[x] && !ast_test_flag(vmu, VM_MOVEHEARD)))) { 07473 /* Save this message. It's not in INBOX or hasn't been heard */ 07474 make_file(vms->fn, sizeof(vms->fn), vms->curdir, x); 07475 if (!EXISTS(vms->curdir, x, vms->fn, NULL)) { 07476 break; 07477 } 07478 vms->curmsg++; 07479 make_file(fn2, sizeof(fn2), vms->curdir, vms->curmsg); 07480 if (strcmp(vms->fn, fn2)) { 07481 RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, fn2); 07482 } 07483 } else if ((!strcasecmp(vms->curbox, "INBOX") || !strcasecmp(vms->curbox, "Urgent")) && vms->heard[x] && ast_test_flag(vmu, VM_MOVEHEARD) && !vms->deleted[x]) { 07484 /* Move to old folder before deleting */ 07485 res = save_to_folder(vmu, vms, x, 1); 07486 if (res == ERROR_LOCK_PATH) { 07487 /* If save failed do not delete the message */ 07488 ast_log(AST_LOG_WARNING, "Save failed. Not moving message: %s.\n", res == ERROR_LOCK_PATH ? "unable to lock path" : "destination folder full"); 07489 vms->deleted[x] = 0; 07490 vms->heard[x] = 0; 07491 --x; 07492 } 07493 } else if (vms->deleted[x] && vmu->maxdeletedmsg) { 07494 /* Move to deleted folder */ 07495 res = save_to_folder(vmu, vms, x, 10); 07496 if (res == ERROR_LOCK_PATH) { 07497 /* If save failed do not delete the message */ 07498 vms->deleted[x] = 0; 07499 vms->heard[x] = 0; 07500 --x; 07501 } 07502 } else if (vms->deleted[x] && ast_check_realtime("voicemail_data")) { 07503 /* If realtime storage enabled - we should explicitly delete this message, 07504 cause RENAME() will overwrite files, but will keep duplicate records in RT-storage */ 07505 make_file(vms->fn, sizeof(vms->fn), vms->curdir, x); 07506 if (EXISTS(vms->curdir, x, vms->fn, NULL)) { 07507 DELETE(vms->curdir, x, vms->fn, vmu); 07508 } 07509 } 07510 } 07511 07512 /* Delete ALL remaining messages */ 07513 nummsg = x - 1; 07514 for (x = vms->curmsg + 1; x <= nummsg; x++) { 07515 make_file(vms->fn, sizeof(vms->fn), vms->curdir, x); 07516 if (EXISTS(vms->curdir, x, vms->fn, NULL)) { 07517 DELETE(vms->curdir, x, vms->fn, vmu); 07518 } 07519 } 07520 ast_unlock_path(vms->curdir); 07521 #else /* defined(IMAP_STORAGE) */ 07522 if (vms->deleted) { 07523 /* Since we now expunge after each delete, deleting in reverse order 07524 * ensures that no reordering occurs between each step. */ 07525 for (x = vms->dh_arraysize - 1; x >= 0; x--) { 07526 if (vms->deleted[x]) { 07527 ast_debug(3, "IMAP delete of %d\n", x); 07528 DELETE(vms->curdir, x, vms->fn, vmu); 07529 } 07530 } 07531 } 07532 #endif 07533 07534 done: 07535 if (vms->deleted) { 07536 memset(vms->deleted, 0, vms->dh_arraysize * sizeof(int)); 07537 } 07538 if (vms->heard) { 07539 memset(vms->heard, 0, vms->dh_arraysize * sizeof(int)); 07540 } 07541 07542 return 0; 07543 }
| static char* complete_voicemail_show_users | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 10255 of file app_voicemail.c.
References AST_LIST_TRAVERSE, ast_strdup, and ast_vm_user::context.
Referenced by handle_voicemail_show_users().
10256 { 10257 int which = 0; 10258 int wordlen; 10259 struct ast_vm_user *vmu; 10260 const char *context = ""; 10261 10262 /* 0 - show; 1 - voicemail; 2 - users; 3 - for; 4 - <context> */ 10263 if (pos > 4) 10264 return NULL; 10265 if (pos == 3) 10266 return (state == 0) ? ast_strdup("for") : NULL; 10267 wordlen = strlen(word); 10268 AST_LIST_TRAVERSE(&users, vmu, list) { 10269 if (!strncasecmp(word, vmu->context, wordlen)) { 10270 if (context && strcmp(context, vmu->context) && ++which > state) 10271 return ast_strdup(vmu->context); 10272 /* ignore repeated contexts ? */ 10273 context = vmu->context; 10274 } 10275 } 10276 return NULL; 10277 }
| static int copy | ( | char * | infile, | |
| char * | outfile | |||
| ) | [static] |
Utility function to copy a file.
| infile | The path to the file to be copied. The file must be readable, it is opened in read only mode. | |
| outfile | The path for which to copy the file to. The directory permissions must allow the creation (or truncation) of the file, and allow for opening the file in write only mode. |
Definition at line 3801 of file app_voicemail.c.
References ast_log(), AST_LOG_WARNING, errno, and VOICEMAIL_FILE_MODE.
Referenced by ast_func_read(), ast_func_write(), copy_plain_file(), iax2_register(), and vm_forwardoptions().
03802 { 03803 int ifd; 03804 int ofd; 03805 int res; 03806 int len; 03807 char buf[4096]; 03808 03809 #ifdef HARDLINK_WHEN_POSSIBLE 03810 /* Hard link if possible; saves disk space & is faster */ 03811 if (link(infile, outfile)) { 03812 #endif 03813 if ((ifd = open(infile, O_RDONLY)) < 0) { 03814 ast_log(AST_LOG_WARNING, "Unable to open %s in read-only mode: %s\n", infile, strerror(errno)); 03815 return -1; 03816 } 03817 if ((ofd = open(outfile, O_WRONLY | O_TRUNC | O_CREAT, VOICEMAIL_FILE_MODE)) < 0) { 03818 ast_log(AST_LOG_WARNING, "Unable to open %s in write-only mode: %s\n", outfile, strerror(errno)); 03819 close(ifd); 03820 return -1; 03821 } 03822 do { 03823 len = read(ifd, buf, sizeof(buf)); 03824 if (len < 0) { 03825 ast_log(AST_LOG_WARNING, "Read failed on %s: %s\n", infile, strerror(errno)); 03826 close(ifd); 03827 close(ofd); 03828 unlink(outfile); 03829 } 03830 if (len) { 03831 res = write(ofd, buf, len); 03832 if (errno == ENOMEM || errno == ENOSPC || res != len) { 03833 ast_log(AST_LOG_WARNING, "Write failed on %s (%d of %d): %s\n", outfile, res, len, strerror(errno)); 03834 close(ifd); 03835 close(ofd); 03836 unlink(outfile); 03837 } 03838 } 03839 } while (len); 03840 close(ifd); 03841 close(ofd); 03842 return 0; 03843 #ifdef HARDLINK_WHEN_POSSIBLE 03844 } else { 03845 /* Hard link succeeded */ 03846 return 0; 03847 } 03848 #endif 03849 }
| static 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, | |||
| char * | dir, | |||
| const char * | flag | |||
| ) | [static] |
Copies a message from one mailbox to another.
| chan | ||
| vmu | ||
| imbox | ||
| msgnum | ||
| duration | ||
| recip | ||
| fmt | ||
| dir | This is only used by file storage based mailboxes. |
Definition at line 4981 of file app_voicemail.c.
References ast_copy_string(), ast_log(), AST_LOG_ERROR, AST_LOG_NOTICE, ast_strlen_zero(), ast_unlock_path(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_vm_user::context, COPY, copy_plain_file(), create_dirpath(), ERROR_LOCK_PATH, EXISTS, inprocess_count(), ast_channel::language, last_message_index(), ast_vm_user::mailbox, make_dir(), make_file(), mbox(), notify_new_message(), S_OR, STORE, vm_delete(), and vm_lock_path().
Referenced by forward_message(), and leave_voicemail().
04982 { 04983 char fromdir[PATH_MAX], todir[PATH_MAX], frompath[PATH_MAX], topath[PATH_MAX]; 04984 const char *frombox = mbox(imbox); 04985 int recipmsgnum; 04986 int res = 0; 04987 04988 ast_log(AST_LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context); 04989 04990 if (!ast_strlen_zero(flag) && !strcmp(flag, "Urgent")) { /* If urgent, copy to Urgent folder */ 04991 create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "Urgent"); 04992 } else { 04993 create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX"); 04994 } 04995 04996 if (!dir) 04997 make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox); 04998 else 04999 ast_copy_string(fromdir, dir, sizeof(fromdir)); 05000 05001 make_file(frompath, sizeof(frompath), fromdir, msgnum); 05002 make_dir(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX"); 05003 05004 if (vm_lock_path(todir)) 05005 return ERROR_LOCK_PATH; 05006 05007 recipmsgnum = last_message_index(recip, todir) + 1; 05008 if (recipmsgnum < recip->maxmsg - (imbox ? 0 : inprocess_count(vmu->mailbox, vmu->context, 0))) { 05009 make_file(topath, sizeof(topath), todir, recipmsgnum); 05010 #ifndef ODBC_STORAGE 05011 if (EXISTS(fromdir, msgnum, frompath, chan->language)) { 05012 COPY(fromdir, msgnum, todir, recipmsgnum, recip->mailbox, recip->context, frompath, topath); 05013 } else { 05014 #endif 05015 /* If we are prepending a message for ODBC, then the message already 05016 * exists in the database, but we want to force copying from the 05017 * filesystem (since only the FS contains the prepend). */ 05018 copy_plain_file(frompath, topath); 05019 STORE(todir, recip->mailbox, recip->context, recipmsgnum, chan, recip, fmt, duration, NULL, NULL); 05020 vm_delete(topath); 05021 #ifndef ODBC_STORAGE 05022 } 05023 #endif 05024 } else { 05025 ast_log(AST_LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context); 05026 res = -1; 05027 } 05028 ast_unlock_path(todir); 05029 notify_new_message(chan, recip, NULL, recipmsgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), flag); 05030 05031 return res; 05032 }
| static void copy_plain_file | ( | char * | frompath, | |
| char * | topath | |||
| ) | [static] |
Copies a voicemail information (envelope) file.
| frompath | ||
| topath |
Definition at line 3860 of file app_voicemail.c.
References ast_check_realtime(), ast_filecopy(), ast_load_realtime(), ast_store_realtime(), ast_variables_destroy(), copy(), exten, ast_variable::name, ast_variable::next, SENTINEL, and ast_variable::value.
Referenced by copy_message().
03861 { 03862 char frompath2[PATH_MAX], topath2[PATH_MAX]; 03863 struct ast_variable *tmp,*var = NULL; 03864 const char *origmailbox = NULL, *context = NULL, *macrocontext = NULL, *exten = NULL, *priority = NULL, *callerchan = NULL, *callerid = NULL, *origdate = NULL, *origtime = NULL, *category = NULL, *duration = NULL; 03865 ast_filecopy(frompath, topath, NULL); 03866 snprintf(frompath2, sizeof(frompath2), "%s.txt", frompath); 03867 snprintf(topath2, sizeof(topath2), "%s.txt", topath); 03868 if (ast_check_realtime("voicemail_data")) { 03869 var = ast_load_realtime("voicemail_data", "filename", frompath, SENTINEL); 03870 /* This cycle converts ast_variable linked list, to va_list list of arguments, may be there is a better way to do it? */ 03871 for (tmp = var; tmp; tmp = tmp->next) { 03872 if (!strcasecmp(tmp->name, "origmailbox")) { 03873 origmailbox = tmp->value; 03874 } else if (!strcasecmp(tmp->name, "context")) { 03875 context = tmp->value; 03876 } else if (!strcasecmp(tmp->name, "macrocontext")) { 03877 macrocontext = tmp->value; 03878 } else if (!strcasecmp(tmp->name, "exten")) { 03879 exten = tmp->value; 03880 } else if (!strcasecmp(tmp->name, "priority")) { 03881 priority = tmp->value; 03882 } else if (!strcasecmp(tmp->name, "callerchan")) { 03883 callerchan = tmp->value; 03884 } else if (!strcasecmp(tmp->name, "callerid")) { 03885 callerid = tmp->value; 03886 } else if (!strcasecmp(tmp->name, "origdate")) { 03887 origdate = tmp->value; 03888 } else if (!strcasecmp(tmp->name, "origtime")) { 03889 origtime = tmp->value; 03890 } else if (!strcasecmp(tmp->name, "category")) { 03891 category = tmp->value; 03892 } else if (!strcasecmp(tmp->name, "duration")) { 03893 duration = tmp->value; 03894 } 03895 } 03896 ast_store_realtime("voicemail_data", "filename", topath, "origmailbox", origmailbox, "context", context, "macrocontext", macrocontext, "exten", exten, "priority", priority, "callerchan", callerchan, "callerid", callerid, "origdate", origdate, "origtime", origtime, "category", category, "duration", duration, SENTINEL); 03897 } 03898 copy(frompath2, topath2); 03899 ast_variables_destroy(var); 03900 }
| static int count_messages | ( | struct ast_vm_user * | vmu, | |
| char * | dir | |||
| ) | [static] |
Find all .txt files - even if they are not in sequence from 0000.
| vmu | ||
| dir | This method is used when mailboxes are stored on the filesystem. (not ODBC and not IMAP). |
Definition at line 3704 of file app_voicemail.c.
References ast_unlock_path(), ERROR_LOCK_PATH, and vm_lock_path().
Referenced by leave_voicemail(), manager_list_voicemail_users(), and open_mailbox().
03705 { 03706 03707 int vmcount = 0; 03708 DIR *vmdir = NULL; 03709 struct dirent *vment = NULL; 03710 03711 if (vm_lock_path(dir)) 03712 return ERROR_LOCK_PATH; 03713 03714 if ((vmdir = opendir(dir))) { 03715 while ((vment = readdir(vmdir))) { 03716 if (strlen(vment->d_name) > 7 && !strncmp(vment->d_name + 7, ".txt", 4)) { 03717 vmcount++; 03718 } 03719 } 03720 closedir(vmdir); 03721 } 03722 ast_unlock_path(dir); 03723 03724 return vmcount; 03725 }
| static int create_dirpath | ( | char * | dest, | |
| int | len, | |||
| const char * | context, | |||
| const char * | ext, | |||
| const char * | folder | |||
| ) | [static] |
basically mkdir -p $dest/$context/$ext/$folder
| dest | String. base directory. | |
| len | Length of dest. | |
| context | String. Ignored if is null or empty string. | |
| ext | String. Ignored if is null or empty string. | |
| folder | String. Ignored if is null or empty string. |
Definition at line 1502 of file app_voicemail.c.
References ast_log(), AST_LOG_WARNING, ast_mkdir(), make_dir(), and VOICEMAIL_DIR_MODE.
Referenced by add_email_attachment(), copy_message(), invent_message(), leave_voicemail(), open_mailbox(), and save_to_folder().
01503 { 01504 mode_t mode = VOICEMAIL_DIR_MODE; 01505 int res; 01506 01507 make_dir(dest, len, context, ext, folder); 01508 if ((res = ast_mkdir(dest, mode))) { 01509 ast_log(AST_LOG_WARNING, "ast_mkdir '%s' failed: %s\n", dest, strerror(res)); 01510 return -1; 01511 } 01512 return 0; 01513 }
| static int dialout | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| char * | num, | |||
| char * | outgoing_context | |||
| ) | [static] |
Definition at line 11518 of file app_voicemail.c.
References ast_copy_string(), ast_play_and_wait(), ast_readstring(), ast_strlen_zero(), ast_verb, ast_verbose, ast_waitfordigit(), ast_channel::context, ast_channel::exten, option_verbose, ast_channel::priority, and VERBOSE_PREFIX_3.
Referenced by advanced_options(), and vm_execmain().
11519 { 11520 int cmd = 0; 11521 char destination[80] = ""; 11522 int retries = 0; 11523 11524 if (!num) { 11525 ast_verb(3, "Destination number will be entered manually\n"); 11526 while (retries < 3 && cmd != 't') { 11527 destination[1] = '\0'; 11528 destination[0] = cmd = ast_play_and_wait(chan,"vm-enter-num-to-call"); 11529 if (!cmd) 11530 destination[0] = cmd = ast_play_and_wait(chan, "vm-then-pound"); 11531 if (!cmd) 11532 destination[0] = cmd = ast_play_and_wait(chan, "vm-star-cancel"); 11533 if (!cmd) { 11534 cmd = ast_waitfordigit(chan, 6000); 11535 if (cmd) 11536 destination[0] = cmd; 11537 } 11538 if (!cmd) { 11539 retries++; 11540 } else { 11541 11542 if (cmd < 0) 11543 return 0; 11544 if (cmd == '*') { 11545 ast_verb(3, "User hit '*' to cancel outgoing call\n"); 11546 return 0; 11547 } 11548 if ((cmd = ast_readstring(chan,destination + strlen(destination),sizeof(destination)-1,6000,10000,"#")) < 0) 11549 retries++; 11550 else 11551 cmd = 't'; 11552 } 11553 } 11554 if (retries >= 3) { 11555 return 0; 11556 } 11557 11558 } else { 11559 if (option_verbose > 2) 11560 ast_verbose( VERBOSE_PREFIX_3 "Destination number is CID number '%s'\n", num); 11561 ast_copy_string(destination, num, sizeof(destination)); 11562 } 11563 11564 if (!ast_strlen_zero(destination)) { 11565 if (destination[strlen(destination) -1 ] == '*') 11566 return 0; 11567 if (option_verbose > 2) 11568 ast_verbose( VERBOSE_PREFIX_3 "Placing outgoing call to extension '%s' in context '%s' from context '%s'\n", destination, outgoing_context, chan->context); 11569 ast_copy_string(chan->exten, destination, sizeof(chan->exten)); 11570 ast_copy_string(chan->context, outgoing_context, sizeof(chan->context)); 11571 chan->priority = 0; 11572 return 9; 11573 } 11574 return 0; 11575 }
| static char* encode_mime_str | ( | const char * | start, | |
| char * | end, | |||
| size_t | endsize, | |||
| size_t | preamble, | |||
| size_t | postamble | |||
| ) | [static] |
Encode a string according to the MIME rules for encoding strings that are not 7-bit clean or contain control characters.
Additionally, if the encoded string would exceed the MIME limit of 76 characters per line, then the encoding will be broken up into multiple sections, separated by a space character, in order to facilitate breaking up the associated header across multiple lines.
| start | A string to be encoded | |
| end | An expandable buffer for holding the result | |
| preamble | The length of the first line already used for this string, to ensure that each line maintains a maximum length of 76 chars. | |
| postamble | the length of any additional characters appended to the line, used to ensure proper field wrapping. |
| The | encoded string. |
Definition at line 4189 of file app_voicemail.c.
References charset.
Referenced by make_email_file().
04190 { 04191 char tmp[80]; 04192 int first_section = 1; 04193 size_t endlen = 0, tmplen = 0; 04194 *end = '\0'; 04195 04196 tmplen = snprintf(tmp, sizeof(tmp), "=?%s?Q?", charset); 04197 for (; *start; start++) { 04198 int need_encoding = 0; 04199 if (*start < 33 || *start > 126 || strchr("()<>@,:;/\"[]?.=_", *start)) { 04200 need_encoding = 1; 04201 } 04202 if ((first_section && need_encoding && preamble + tmplen > 70) || 04203 (first_section && !need_encoding && preamble + tmplen > 72) || 04204 (!first_section && need_encoding && tmplen > 70) || 04205 (!first_section && !need_encoding && tmplen > 72)) { 04206 /* Start new line */ 04207 endlen += snprintf(end + endlen, endsize - endlen, "%s%s?=", first_section ? "" : " ", tmp); 04208 tmplen = snprintf(tmp, sizeof(tmp), "=?%s?Q?", charset); 04209 first_section = 0; 04210 } 04211 if (need_encoding && *start == ' ') { 04212 tmplen += snprintf(tmp + tmplen, sizeof(tmp) - tmplen, "_"); 04213 } else if (need_encoding) { 04214 tmplen += snprintf(tmp + tmplen, sizeof(tmp) - tmplen, "=%hhX", *start); 04215 } else { 04216 tmplen += snprintf(tmp + tmplen, sizeof(tmp) - tmplen, "%c", *start); 04217 } 04218 } 04219 snprintf(end + endlen, endsize - endlen, "%s%s?=%s", first_section ? "" : " ", tmp, endlen + postamble > 74 ? " " : ""); 04220 return end; 04221 }
| static struct ast_vm_user* find_or_create | ( | const char * | context, | |
| const char * | box | |||
| ) | [static, read] |
Definition at line 10044 of file app_voicemail.c.
References ast_calloc, ast_copy_string(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log(), ast_test_flag, ast_vm_user::context, globalflags, LOG_WARNING, ast_vm_user::mailbox, and VM_SEARCH.
Referenced by append_mailbox(), and load_config().
10045 { 10046 struct ast_vm_user *vmu; 10047 10048 AST_LIST_TRAVERSE(&users, vmu, list) { 10049 if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(box, vmu->mailbox)) { 10050 if (strcasecmp(vmu->context, context)) { 10051 ast_log(LOG_WARNING, "\nIt has been detected that you have defined mailbox '%s' in separate\ 10052 \n\tcontexts and that you have the 'searchcontexts' option on. This type of\ 10053 \n\tconfiguration creates an ambiguity that you likely do not want. Please\ 10054 \n\tamend your voicemail.conf file to avoid this situation.\n", box); 10055 } 10056 ast_log(LOG_WARNING, "Ignoring duplicated mailbox %s\n", box); 10057 return NULL; 10058 } 10059 if (!strcasecmp(context, vmu->context) && !strcasecmp(box, vmu->mailbox)) { 10060 ast_log(LOG_WARNING, "Ignoring duplicated mailbox %s in context %s\n", box, context); 10061 return NULL; 10062 } 10063 } 10064 10065 if (!(vmu = ast_calloc(1, sizeof(*vmu)))) 10066 return NULL; 10067 10068 ast_copy_string(vmu->context, context, sizeof(vmu->context)); 10069 ast_copy_string(vmu->mailbox, box, sizeof(vmu->mailbox)); 10070 10071 AST_LIST_INSERT_TAIL(&users, vmu, list); 10072 10073 return vmu; 10074 }
| static struct ast_vm_user* find_user | ( | struct ast_vm_user * | ivm, | |
| const char * | context, | |||
| const char * | mailbox | |||
| ) | [static, read] |
Finds a voicemail user from the users file or the realtime engine.
| ivm | ||
| context | ||
| mailbox |
Definition at line 1297 of file app_voicemail.c.
References AST_LIST_LOCK, AST_LIST_NEXT, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_malloc, ast_set2_flag, ast_test_flag, find_user_realtime(), globalflags, VM_ALLOCED, and VM_SEARCH.
Referenced by acf_mailbox_exists(), advanced_options(), forward_message(), leave_voicemail(), vm_authenticate(), vm_box_exists(), and vm_execmain().
01298 { 01299 /* This function could be made to generate one from a database, too */ 01300 struct ast_vm_user *vmu=NULL, *cur; 01301 AST_LIST_LOCK(&users); 01302 01303 if (!context && !ast_test_flag((&globalflags), VM_SEARCH)) 01304 context = "default"; 01305 01306 AST_LIST_TRAVERSE(&users, cur, list) { 01307 #ifdef IMAP_STORAGE 01308 if (cur->imapversion != imapversion) { 01309 continue; 01310 } 01311 #endif 01312 if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mailbox, cur->mailbox)) 01313 break; 01314 if (context && (!strcasecmp(context, cur->context)) && (!strcasecmp(mailbox, cur->mailbox))) 01315 break; 01316 } 01317 if (cur) { 01318 /* Make a copy, so that on a reload, we have no race */ 01319 if ((vmu = (ivm ? ivm : ast_malloc(sizeof(*vmu))))) { 01320 memcpy(vmu, cur, sizeof(*vmu)); 01321 ast_set2_flag(vmu, !ivm, VM_ALLOCED); 01322 AST_LIST_NEXT(vmu, list) = NULL; 01323 } 01324 } else 01325 vmu = find_user_realtime(ivm, context, mailbox); 01326 AST_LIST_UNLOCK(&users); 01327 return vmu; 01328 }
| static struct ast_vm_user* find_user_realtime | ( | struct ast_vm_user * | ivm, | |
| const char * | context, | |||
| const char * | mailbox | |||
| ) | [static, read] |
Finds a voicemail user from the realtime engine.
| ivm | ||
| context | ||
| mailbox | This is called as a fall through case when the normal find_user() was not able to find a user. That is, the default it so look in the usual voicemail users file first. |
Definition at line 1260 of file app_voicemail.c.
References apply_options_full(), ast_calloc, ast_copy_string(), ast_free, ast_load_realtime(), ast_set_flag, ast_test_flag, ast_variables_destroy(), globalflags, ast_vm_user::mailbox, populate_defaults(), SENTINEL, var, VM_ALLOCED, and VM_SEARCH.
Referenced by find_user().
01261 { 01262 struct ast_variable *var; 01263 struct ast_vm_user *retval; 01264 01265 if ((retval = (ivm ? ivm : ast_calloc(1, sizeof(*retval))))) { 01266 if (!ivm) 01267 ast_set_flag(retval, VM_ALLOCED); 01268 else 01269 memset(retval, 0, sizeof(*retval)); 01270 if (mailbox) 01271 ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox)); 01272 populate_defaults(retval); 01273 if (!context && ast_test_flag((&globalflags), VM_SEARCH)) 01274 var = ast_load_realtime("voicemail", "mailbox", mailbox, SENTINEL); 01275 else 01276 var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, SENTINEL); 01277 if (var) { 01278 apply_options_full(retval, var); 01279 ast_variables_destroy(var); 01280 } else { 01281 if (!ivm) 01282 ast_free(retval); 01283 retval = NULL; 01284 } 01285 } 01286 return retval; 01287 }
| static int forward_message | ( | struct ast_channel * | chan, | |
| char * | context, | |||
| struct vm_state * | vms, | |||
| struct ast_vm_user * | sender, | |||
| char * | fmt, | |||
| int | is_new_message, | |||
| signed char | record_gain, | |||
| int | urgent | |||
| ) | [static] |
Sends a voicemail message to a mailbox recipient.
| ast_channel | ||
| context | ||
| vms | ||
| sender | ||
| fmt | ||
| is_new_message | Used to indicate the mode for which this method was invoked. Will be 0 when called to forward an existing message (option 8) Will be 1 when called to leave a message (option 3->5) | |
| record_gain |
When in the leave message mode (is_new_message == 1):
When in the forward message mode (is_new_message == 0):
Definition at line 6689 of file app_voicemail.c.
References ast_clear_flag, ast_copy_string(), ast_fileexists(), ast_filerename(), AST_LIST_EMPTY, AST_LIST_HEAD_NOLOCK_STATIC, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), AST_LOG_ERROR, AST_LOG_WARNING, AST_MAX_EXTENSION, ast_play_and_wait(), ast_readstring(), ast_say_digit_str(), ast_stream_and_wait(), ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_waitfordigit(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_vm_user::context, ast_channel::context, copy_message(), vm_state::curbox, vm_state::curdir, vm_state::curmsg, DISPOSE, ast_channel::exten, find_user(), vm_state::fn, free_user(), globalflags, inboxcount(), inprocess_count(), ast_channel::language, leave_voicemail(), LOG_ERROR, LOG_NOTICE, ast_vm_user::mailbox, make_file(), ast_vm_user::maxmsg, pbx_exec(), pbx_findapp(), ast_channel::priority, leave_vm_options::record_gain, RETRIEVE, run_externnotify(), s, S_OR, sendmail(), STORE, strsep(), vm_state::username, VM_ATTACH, VM_DIRECFORWARD, vm_forwardoptions(), and VM_FWDURGAUTO.
Referenced by vm_execmain().
06690 { 06691 #ifdef IMAP_STORAGE 06692 int todircount=0; 06693 struct vm_state *dstvms; 06694 #endif 06695 char username[70]=""; 06696 char fn[PATH_MAX]; /* for playback of name greeting */ 06697 char ecodes[16] = "#"; 06698 int res = 0, cmd = 0; 06699 struct ast_vm_user *receiver = NULL, *vmtmp; 06700 AST_LIST_HEAD_NOLOCK_STATIC(extensions, ast_vm_user); 06701 char *stringp; 06702 const char *s; 06703 int saved_messages = 0; 06704 int valid_extensions = 0; 06705 char *dir; 06706 int curmsg; 06707 char urgent_str[7] = ""; 06708 char tmptxtfile[PATH_MAX]; 06709 int prompt_played = 0; 06710 #ifndef IMAP_STORAGE 06711 char msgfile[PATH_MAX], textfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX]; 06712 #endif 06713 if (ast_test_flag((&globalflags), VM_FWDURGAUTO)) { 06714 ast_copy_string(urgent_str, urgent ? "Urgent" : "", sizeof(urgent_str)); 06715 } 06716 06717 if (vms == NULL) return -1; 06718 dir = vms->curdir; 06719 curmsg = vms->curmsg; 06720 06721 tmptxtfile[0] = '\0'; 06722 while (!res && !valid_extensions) { 06723 int use_directory = 0; 06724 if (ast_test_flag((&globalflags), VM_DIRECFORWARD)) { 06725 int done = 0; 06726 int retries = 0; 06727 cmd=0; 06728 while ((cmd >= 0) && !done ){ 06729 if (cmd) 06730 retries = 0; 06731 switch (cmd) { 06732 case '1': 06733 use_directory = 0; 06734 done = 1; 06735 break; 06736 case '2': 06737 use_directory = 1; 06738 done=1; 06739 break; 06740 case '*': 06741 cmd = 't'; 06742 done = 1; 06743 break; 06744 default: 06745 /* Press 1 to enter an extension press 2 to use the directory */ 06746 cmd = ast_play_and_wait(chan,"vm-forward"); 06747 if (!cmd) 06748 cmd = ast_waitfordigit(chan,3000); 06749 if (!cmd) 06750 retries++; 06751 if (retries > 3) { 06752 cmd = 't'; 06753 done = 1; 06754 } 06755 06756 } 06757 } 06758 if (cmd < 0 || cmd == 't') 06759 break; 06760 } 06761 06762 if (use_directory) { 06763 /* use app_directory */ 06764 06765 char old_context[sizeof(chan->context)]; 06766 char old_exten[sizeof(chan->exten)]; 06767 int old_priority; 06768 struct ast_app* directory_app; 06769 06770 directory_app = pbx_findapp("Directory"); 06771 if (directory_app) { 06772 char vmcontext[256]; 06773 /* make backup copies */ 06774 memcpy(old_context, chan->context, sizeof(chan->context)); 06775 memcpy(old_exten, chan->exten, sizeof(chan->exten)); 06776 old_priority = chan->priority; 06777 06778 /* call the the Directory, changes the channel */ 06779 snprintf(vmcontext, sizeof(vmcontext), "%s,,v", context ? context : "default"); 06780 res = pbx_exec(chan, directory_app, vmcontext); 06781 06782 ast_copy_string(username, chan->exten, sizeof(username)); 06783 06784 /* restore the old context, exten, and priority */ 06785 memcpy(chan->context, old_context, sizeof(chan->context)); 06786 memcpy(chan->exten, old_exten, sizeof(chan->exten)); 06787 chan->priority = old_priority; 06788 } else { 06789 ast_log(AST_LOG_WARNING, "Could not find the Directory application, disabling directory_forward\n"); 06790 ast_clear_flag((&globalflags), VM_DIRECFORWARD); 06791 } 06792 } else { 06793 /* Ask for an extension */ 06794 res = ast_streamfile(chan, "vm-extension", chan->language); /* "extension" */ 06795 prompt_played++; 06796 if (res || prompt_played > 4) 06797 break; 06798 if ((res = ast_readstring(chan, username, sizeof(username) - 1, 2000, 10000, "#") < 0)) 06799 break; 06800 } 06801 06802 /* start all over if no username */ 06803 if (ast_strlen_zero(username)) 06804 continue; 06805 stringp = username; 06806 s = strsep(&stringp, "*"); 06807 /* start optimistic */ 06808 valid_extensions = 1; 06809 while (s) { 06810 if ((is_new_message == 1 || strcmp(s, sender->mailbox)) && (receiver = find_user(NULL, context, s))) { 06811 int oldmsgs; 06812 int newmsgs; 06813 int capacity; 06814 if (inboxcount(s, &newmsgs, &oldmsgs)) { 06815 ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", s); 06816 /* Shouldn't happen, but allow trying another extension if it does */ 06817 res = ast_play_and_wait(chan, "pbx-invalid"); 06818 valid_extensions = 0; 06819 break; 06820 } 06821 capacity = receiver->maxmsg - inprocess_count(receiver->mailbox, receiver->context, +1); 06822 if ((newmsgs + oldmsgs) >= capacity) { 06823 ast_log(LOG_NOTICE, "Mailbox '%s' is full with capacity of %d, prompting for another extension.\n", s, capacity); 06824 res = ast_play_and_wait(chan, "vm-mailboxfull"); 06825 valid_extensions = 0; 06826 while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list))) { 06827 inprocess_count(vmtmp->mailbox, vmtmp->context, -1); 06828 free_user(vmtmp); 06829 } 06830 inprocess_count(receiver->mailbox, receiver->context, -1); 06831 break; 06832 } 06833 AST_LIST_INSERT_HEAD(&extensions, receiver, list); 06834 } else { 06835 /* XXX Optimization for the future. When we encounter a single bad extension, 06836 * bailing out on all of the extensions may not be the way to go. We should 06837 * probably just bail on that single extension, then allow the user to enter 06838 * several more. XXX 06839 */ 06840 while ((receiver = AST_LIST_REMOVE_HEAD(&extensions, list))) { 06841 free_user(receiver); 06842 } 06843 ast_log(LOG_NOTICE, "'%s' is not a valid mailbox\n", s); 06844 /* "I am sorry, that's not a valid extension. Please try again." */ 06845 res = ast_play_and_wait(chan, "pbx-invalid"); 06846 valid_extensions = 0; 06847 break; 06848 } 06849 06850 /* play name if available, else play extension number */ 06851 snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, receiver->context, s); 06852 RETRIEVE(fn, -1, s, receiver->context); 06853 if (ast_fileexists(fn, NULL, NULL) > 0) { 06854 res = ast_stream_and_wait(chan, fn, ecodes); 06855 if (res) { 06856 DISPOSE(fn, -1); 06857 return res; 06858 } 06859 } else { 06860 res = ast_say_digit_str(chan, s, ecodes, chan->language); 06861 } 06862 DISPOSE(fn, -1); 06863 06864 s = strsep(&stringp, "*"); 06865 } 06866 /* break from the loop of reading the extensions */ 06867 if (valid_extensions) 06868 break; 06869 } 06870 /* check if we're clear to proceed */ 06871 if (AST_LIST_EMPTY(&extensions) || !valid_extensions) 06872 return res; 06873 if (is_new_message == 1) { 06874 struct leave_vm_options leave_options; 06875 char mailbox[AST_MAX_EXTENSION * 2 + 2]; 06876 snprintf(mailbox, sizeof(mailbox), "%s@%s", username, context); 06877 06878 /* Send VoiceMail */ 06879 memset(&leave_options, 0, sizeof(leave_options)); 06880 leave_options.record_gain = record_gain; 06881 cmd = leave_voicemail(chan, mailbox, &leave_options); 06882 } else { 06883 /* Forward VoiceMail */ 06884 long duration = 0; 06885 struct vm_state vmstmp; 06886 int copy_msg_result = 0; 06887 memcpy(&vmstmp, vms, sizeof(vmstmp)); 06888 06889 RETRIEVE(dir, curmsg, sender->mailbox, sender->context); 06890 06891 cmd = vm_forwardoptions(chan, sender, vmstmp.curdir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, &vmstmp, urgent_str); 06892 if (!cmd) { 06893 AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) { 06894 #ifdef IMAP_STORAGE 06895 int attach_user_voicemail; 06896 char *myserveremail = serveremail; 06897 06898 /* get destination mailbox */ 06899 dstvms = get_vm_state_by_mailbox(vmtmp->mailbox, vmtmp->context, 0); 06900 if (!dstvms) { 06901 dstvms = create_vm_state_from_user(vmtmp); 06902 } 06903 if (dstvms) { 06904 init_mailstream(dstvms, 0); 06905 if (!dstvms->mailstream) { 06906 ast_log(AST_LOG_ERROR, "IMAP mailstream for %s is NULL\n", vmtmp->mailbox); 06907 } else { 06908 copy_msg_result = STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms, urgent_str); 06909 run_externnotify(vmtmp->context, vmtmp->mailbox, urgent_str); 06910 } 06911 } else { 06912 ast_log(AST_LOG_ERROR, "Could not find state information for mailbox %s\n", vmtmp->mailbox); 06913 } 06914 if (!ast_strlen_zero(vmtmp->serveremail)) 06915 myserveremail = vmtmp->serveremail; 06916 attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH); 06917 /* NULL category for IMAP storage */ 06918 sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, dstvms->curbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vmstmp.fn, vmstmp.introfn, fmt, duration, attach_user_voicemail, chan, NULL, urgent_str); 06919 #else 06920 copy_msg_result = copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir, urgent_str); 06921 #endif 06922 saved_messages++; 06923 AST_LIST_REMOVE_CURRENT(list); 06924 inprocess_count(vmtmp->mailbox, vmtmp->context, -1); 06925 free_user(vmtmp); 06926 if (res) 06927 break; 06928 } 06929 AST_LIST_TRAVERSE_SAFE_END; 06930 if (saved_messages > 0 && !copy_msg_result) { 06931 /* give confirmation that the message was saved */ 06932 /* commented out since we can't forward batches yet 06933 if (saved_messages == 1) 06934 res = ast_play_and_wait(chan, "vm-message"); 06935 else 06936 res = ast_play_and_wait(chan, "vm-messages"); 06937 if (!res) 06938 res = ast_play_and_wait(chan, "vm-saved"); */ 06939 #ifdef IMAP_STORAGE 06940 /* If forwarded with intro, DON'T PLAY THIS MESSAGE AGAIN! */ 06941 if (ast_strlen_zero(vmstmp.introfn)) 06942 #endif 06943 res = ast_play_and_wait(chan, "vm-msgsaved"); 06944 } 06945 #ifndef IMAP_STORAGE 06946 else { 06947 /* with IMAP, mailbox full warning played by imap_check_limits */ 06948 res = ast_play_and_wait(chan, "vm-mailboxfull"); 06949 } 06950 /* Restore original message without prepended message if backup exists */ 06951 make_file(msgfile, sizeof(msgfile), dir, curmsg); 06952 strcpy(textfile, msgfile); 06953 strcpy(backup, msgfile); 06954 strcpy(backup_textfile, msgfile); 06955 strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1); 06956 strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1); 06957 strncat(backup_textfile, "-bak.txt", sizeof(backup_textfile) - strlen(backup_textfile) - 1); 06958 if (ast_fileexists(backup, NULL, NULL) > 0) { 06959 ast_filerename(backup, msgfile, NULL); 06960 rename(backup_textfile, textfile); 06961 } 06962 #endif 06963 } 06964 DISPOSE(dir, curmsg); 06965 #ifndef IMAP_STORAGE 06966 if (cmd) { /* assuming hangup, cleanup backup file */ 06967 make_file(msgfile, sizeof(msgfile), dir, curmsg); 06968 strcpy(textfile, msgfile); 06969 strcpy(backup_textfile, msgfile); 06970 strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1); 06971 strncat(backup_textfile, "-bak.txt", sizeof(backup_textfile) - strlen(backup_textfile) - 1); 06972 rename(backup_textfile, textfile); 06973 } 06974 #endif 06975 } 06976 06977 /* If anything failed above, we still have this list to free */ 06978 while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list))) { 06979 inprocess_count(vmtmp->mailbox, vmtmp->context, -1); 06980 free_user(vmtmp); 06981 } 06982 return res ? res : cmd; 06983 }
| static void free_user | ( | struct ast_vm_user * | vmu | ) | [static] |
Definition at line 1538 of file app_voicemail.c.
References ast_free, ast_test_flag, ast_vm_user::emailbody, ast_vm_user::emailsubject, and VM_ALLOCED.
Referenced by forward_message(), free_vm_users(), leave_voicemail(), and vm_execmain().
01539 { 01540 if (ast_test_flag(vmu, VM_ALLOCED)) { 01541 if (vmu->emailbody != NULL) { 01542 ast_free(vmu->emailbody); 01543 vmu->emailbody = NULL; 01544 } 01545 if (vmu->emailsubject != NULL) { 01546 ast_free(vmu->emailsubject); 01547 vmu->emailsubject = NULL; 01548 } 01549 ast_free(vmu); 01550 } 01551 }
| static void free_vm_users | ( | void | ) | [static] |
Free the users structure.
Definition at line 10712 of file app_voicemail.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_set_flag, free_user(), and VM_ALLOCED.
Referenced by load_config(), and unload_module().
10713 { 10714 struct ast_vm_user *current; 10715 AST_LIST_LOCK(&users); 10716 while ((current = AST_LIST_REMOVE_HEAD(&users, list))) { 10717 ast_set_flag(current, VM_ALLOCED); 10718 free_user(current); 10719 } 10720 AST_LIST_UNLOCK(&users); 10721 }
| static void free_vm_zones | ( | void | ) | [static] |
Free the zones structure.
Definition at line 10724 of file app_voicemail.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, and free_zone().
Referenced by load_config(), and unload_module().
10725 { 10726 struct vm_zone *zcur; 10727 AST_LIST_LOCK(&zones); 10728 while ((zcur = AST_LIST_REMOVE_HEAD(&zones, list))) 10729 free_zone(zcur); 10730 AST_LIST_UNLOCK(&zones); 10731 }
| static void free_zone | ( | struct vm_zone * | z | ) | [static] |
Definition at line 4749 of file app_voicemail.c.
References ast_free.
Referenced by free_vm_zones().
04750 { 04751 ast_free(z); 04752 }
| static int get_date | ( | char * | s, | |
| int | len | |||
| ) | [static] |
Gets the current date and time, as formatted string.
| s | The buffer to hold the output formatted date. | |
| len | the length of the buffer. Used to prevent buffer overflow in ast_strftime. |
Definition at line 4705 of file app_voicemail.c.
References ast_localtime(), ast_strftime(), and ast_tvnow().
Referenced by leave_voicemail().
04706 { 04707 struct ast_tm tm; 04708 struct timeval t = ast_tvnow(); 04709 04710 ast_localtime(&t, &tm, "UTC"); 04711 04712 return ast_strftime(s, len, "%a %b %e %r UTC %Y", &tm); 04713 }
| static int get_folder | ( | struct ast_channel * | chan, | |
| int | start | |||
| ) | [static] |
get_folder: Folder menu Plays "press 1 for INBOX messages" etc. Should possibly be internationalized
Definition at line 6333 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().
06334 { 06335 int x; 06336 int d; 06337 char fn[PATH_MAX]; 06338 d = ast_play_and_wait(chan, "vm-press"); /* "Press" */ 06339 if (d) 06340 return d; 06341 for (x = start; x< 5; x++) { /* For all folders */ 06342 if ((d = ast_say_number(chan, x, AST_DIGIT_ANY, chan->language, NULL))) 06343 return d; 06344 d = ast_play_and_wait(chan, "vm-for"); /* "for" */ 06345 if (d) 06346 return d; 06347 snprintf(fn, sizeof(fn), "vm-%s", mbox(x)); /* Folder name */ 06348 d = vm_play_folder_name(chan, fn); 06349 if (d) 06350 return d; 06351 d = ast_waitfordigit(chan, 500); 06352 if (d) 06353 return d; 06354 } 06355 d = ast_play_and_wait(chan, "vm-tocancel"); /* "or pound to cancel" */ 06356 if (d) 06357 return d; 06358 d = ast_waitfordigit(chan, 4000); 06359 return d; 06360 }
| static int get_folder2 | ( | struct ast_channel * | chan, | |
| char * | fn, | |||
| int | start | |||
| ) | [static] |
plays a prompt and waits for a keypress.
| chan | ||
| fn | the name of the voice prompt file to be played. For example, 'vm-changeto', 'vm-savefolder' | |
| start | Does not appear to be used at this time. |
Definition at line 6374 of file app_voicemail.c.
References ast_play_and_wait(), and get_folder().
Referenced by vm_execmain().
06375 { 06376 int res = 0; 06377 int loops = 0; 06378 res = ast_play_and_wait(chan, fn); /* Folder name */ 06379 while (((res < '0') || (res > '9')) && 06380 (res != '#') && (res >= 0) && 06381 loops < 4) { 06382 res = get_folder(chan, 0); 06383 loops++; 06384 } 06385 if (loops == 4) { /* give up */ 06386 return '#'; 06387 } 06388 return res; 06389 }
| static int handle_subscribe | ( | void * | datap | ) | [static] |
Definition at line 10495 of file app_voicemail.c.
References ast_calloc, ast_free, AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), mwi_sub_task::context, mwi_sub::mailbox, mwi_sub_task::mailbox, poll_subscribed_mailbox(), mwi_sub_task::uniqueid, and mwi_sub::uniqueid.
Referenced by mwi_sub_event_cb().
10496 { 10497 unsigned int len; 10498 struct mwi_sub *mwi_sub; 10499 struct mwi_sub_task *p = datap; 10500 10501 len = sizeof(*mwi_sub); 10502 if (!ast_strlen_zero(p->mailbox)) 10503 len += strlen(p->mailbox); 10504 10505 if (!ast_strlen_zero(p->context)) 10506 len += strlen(p->context) + 1; /* Allow for seperator */ 10507 10508 if (!(mwi_sub = ast_calloc(1, len))) 10509 return -1; 10510 10511 mwi_sub->uniqueid = p->uniqueid; 10512 if (!ast_strlen_zero(p->mailbox)) 10513 strcpy(mwi_sub->mailbox, p->mailbox); 10514 10515 if (!ast_strlen_zero(p->context)) { 10516 strcat(mwi_sub->mailbox, "@"); 10517 strcat(mwi_sub->mailbox, p->context); 10518 } 10519 10520 AST_RWLIST_WRLOCK(&mwi_subs); 10521 AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry); 10522 AST_RWLIST_UNLOCK(&mwi_subs); 10523 ast_free((void *) p->mailbox); 10524 ast_free((void *) p->context); 10525 ast_free(p); 10526 poll_subscribed_mailbox(mwi_sub); 10527 return 0; 10528 }
| static int handle_unsubscribe | ( | void * | datap | ) | [static] |
Definition at line 10473 of file app_voicemail.c.
References ast_free, AST_LIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, mwi_sub::entry, mwi_sub_destroy(), and mwi_sub::uniqueid.
Referenced by mwi_unsub_event_cb().
10474 { 10475 struct mwi_sub *mwi_sub; 10476 uint32_t *uniqueid = datap; 10477 10478 AST_RWLIST_WRLOCK(&mwi_subs); 10479 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&mwi_subs, mwi_sub, entry) { 10480 if (mwi_sub->uniqueid == *uniqueid) { 10481 AST_LIST_REMOVE_CURRENT(entry); 10482 break; 10483 } 10484 } 10485 AST_RWLIST_TRAVERSE_SAFE_END 10486 AST_RWLIST_UNLOCK(&mwi_subs); 10487 10488 if (mwi_sub) 10489 mwi_sub_destroy(mwi_sub); 10490 10491 ast_free(uniqueid); 10492 return 0; 10493 }
| static char* handle_voicemail_reload | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Reload voicemail configuration from the CLI.
Definition at line 10390 of file app_voicemail.c.
References ast_cli_args::argc, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, load_config(), and ast_cli_entry::usage.
10391 { 10392 switch (cmd) { 10393 case CLI_INIT: 10394 e->command = "voicemail reload"; 10395 e->usage = 10396 "Usage: voicemail reload\n" 10397 " Reload voicemail configuration\n"; 10398 return NULL; 10399 case CLI_GENERATE: 10400 return NULL; 10401 } 10402 10403 if (a->argc != 2) 10404 return CLI_SHOWUSAGE; 10405 10406 ast_cli(a->fd, "Reloading voicemail configuration...\n"); 10407 load_config(1); 10408 10409 return CLI_SUCCESS; 10410 }
| static char* handle_voicemail_show_users | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Show a list of voicemail users in the CLI.
Definition at line 10280 of file app_voicemail.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_check_realtime(), ast_cli(), AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_voicemail_show_users(), ast_vm_user::context, ast_cli_args::fd, ast_vm_user::fullname, HVSU_OUTPUT_FORMAT, inboxcount(), ast_cli_args::line, ast_vm_user::mailbox, ast_cli_args::n, ast_cli_args::pos, show_users_realtime(), ast_cli_entry::usage, ast_cli_args::word, and ast_vm_user::zonetag.
10281 { 10282 struct ast_vm_user *vmu; 10283 #define HVSU_OUTPUT_FORMAT "%-10s %-5s %-25s %-10s %6s\n" 10284 const char *context = NULL; 10285 int users_counter = 0; 10286 10287 switch (cmd) { 10288 case CLI_INIT: 10289 e->command = "voicemail show users"; 10290 e->usage = 10291 "Usage: voicemail show users [for <context>]\n" 10292 " Lists all mailboxes currently set up\n"; 10293 return NULL; 10294 case CLI_GENERATE: 10295 return complete_voicemail_show_users(a->line, a->word, a->pos, a->n); 10296 } 10297 10298 if ((a->argc < 3) || (a->argc > 5) || (a->argc == 4)) 10299 return CLI_SHOWUSAGE; 10300 if (a->argc == 5) { 10301 if (strcmp(a->argv[3],"for")) 10302 return CLI_SHOWUSAGE; 10303 context = a->argv[4]; 10304 } 10305 10306 if (ast_check_realtime("voicemail")) { 10307 if (!context) { 10308 ast_cli(a->fd, "You must specify a specific context to show users from realtime!\n"); 10309 return CLI_SHOWUSAGE; 10310 } 10311 return show_users_realtime(a->fd, context); 10312 } 10313 10314 AST_LIST_LOCK(&users); 10315 if (AST_LIST_EMPTY(&users)) { 10316 ast_cli(a->fd, "There are no voicemail users currently defined\n"); 10317 AST_LIST_UNLOCK(&users); 10318 return CLI_FAILURE; 10319 } 10320 if (a->argc == 3) 10321 ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg"); 10322 else { 10323 int count = 0; 10324 AST_LIST_TRAVERSE(&users, vmu, list) { 10325 if (!strcmp(context, vmu->context)) 10326 count++; 10327 } 10328 if (count) { 10329 ast_cli(a->fd, HVSU_OUTPUT_FORMAT, "Context", "Mbox", "User", "Zone", "NewMsg"); 10330 } else { 10331 ast_cli(a->fd, "No such voicemail context \"%s\"\n", context); 10332 AST_LIST_UNLOCK(&users); 10333 return CLI_FAILURE; 10334 } 10335 } 10336 AST_LIST_TRAVERSE(&users, vmu, list) { 10337 int newmsgs = 0, oldmsgs = 0; 10338 char count[12], tmp[256] = ""; 10339 10340 if ((a->argc == 3) || ((a->argc == 5) && !strcmp(context, vmu->context))) { 10341 snprintf(tmp, sizeof(tmp), "%s@%s", vmu->mailbox, ast_strlen_zero(vmu->context) ? "default" : vmu->context); 10342 inboxcount(tmp, &newmsgs, &oldmsgs); 10343 snprintf(count, sizeof(count), "%d", newmsgs); 10344 ast_cli(a->fd, HVSU_OUTPUT_FORMAT, vmu->context, vmu->mailbox, vmu->fullname, vmu->zonetag, count); 10345 users_counter++; 10346 } 10347 } 10348 AST_LIST_UNLOCK(&users); 10349 ast_cli(a->fd, "%d voicemail users configured.\n", users_counter); 10350 return CLI_SUCCESS; 10351 }
| static char* handle_voicemail_show_zones | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Show a list of voicemail zones in the CLI.
Definition at line 10354 of file app_voicemail.c.
References ast_cli_args::argc, ast_cli(), AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, HVSZ_OUTPUT_FORMAT, vm_zone::msg_format, vm_zone::name, vm_zone::timezone, and ast_cli_entry::usage.
10355 { 10356 struct vm_zone *zone; 10357 #define HVSZ_OUTPUT_FORMAT "%-15s %-20s %-45s\n" 10358 char *res = CLI_SUCCESS; 10359 10360 switch (cmd) { 10361 case CLI_INIT: 10362 e->command = "voicemail show zones"; 10363 e->usage = 10364 "Usage: voicemail show zones\n" 10365 " Lists zone message formats\n"; 10366 return NULL; 10367 case CLI_GENERATE: 10368 return NULL; 10369 } 10370 10371 if (a->argc != 3) 10372 return CLI_SHOWUSAGE; 10373 10374 AST_LIST_LOCK(&zones); 10375 if (!AST_LIST_EMPTY(&zones)) { 10376 ast_cli(a->fd, HVSZ_OUTPUT_FORMAT, "Zone", "Timezone", "Message Format"); 10377 AST_LIST_TRAVERSE(&zones, zone, list) { 10378 ast_cli(a->fd, HVSZ_OUTPUT_FORMAT, zone->name, zone->timezone, zone->msg_format); 10379 } 10380 } else { 10381 ast_cli(a->fd, "There are no voicemail zones currently defined\n"); 10382 res = CLI_FAILURE; 10383 } 10384 AST_LIST_UNLOCK(&zones); 10385 10386 return res; 10387 }
| static int has_voicemail | ( | const char * | mailbox, | |
| const char * | folder | |||
| ) | [static] |
Determines if the given folder has messages.
| mailbox | The @ delimited string for user. If no context is found, uses 'default' for the context. | |
| folder | the folder to look in |
Definition at line 5087 of file app_voicemail.c.
References __has_voicemail(), ast_copy_string(), ast_strlen_zero(), and strsep().
Referenced by load_module(), and vm_execmain().
05088 { 05089 char tmp[256], *tmp2 = tmp, *box, *context; 05090 ast_copy_string(tmp, mailbox, sizeof(tmp)); 05091 if (ast_strlen_zero(folder)) { 05092 folder = "INBOX"; 05093 } 05094 while ((box = strsep(&tmp2, ",&"))) { 05095 if ((context = strchr(box, '@'))) 05096 *context++ = '\0'; 05097 else 05098 context = "default"; 05099 if (__has_voicemail(context, box, folder, 1)) 05100 return 1; 05101 /* If we are checking INBOX, we should check Urgent as well */ 05102 if (!strcmp(folder, "INBOX") && __has_voicemail(context, box, "Urgent", 1)) { 05103 return 1; 05104 } 05105 } 05106 return 0; 05107 }
| static int inboxcount | ( | const char * | mailbox, | |
| int * | newmsgs, | |||
| int * | oldmsgs | |||
| ) | [static] |
Definition at line 5169 of file app_voicemail.c.
References inboxcount2().
Referenced by forward_message(), handle_voicemail_show_users(), leave_voicemail(), load_module(), and manager_list_voicemail_users().
05170 { 05171 int urgentmsgs = 0; 05172 int res = inboxcount2(mailbox, &urgentmsgs, newmsgs, oldmsgs); 05173 if (newmsgs) { 05174 *newmsgs += urgentmsgs; 05175 } 05176 return res; 05177 }
| static int inboxcount2 | ( | const char * | mailbox, | |
| int * | urgentmsgs, | |||
| int * | newmsgs, | |||
| int * | oldmsgs | |||
| ) | [static] |
Definition at line 5110 of file app_voicemail.c.
References __has_voicemail(), ast_copy_string(), ast_strlen_zero(), and strsep().
Referenced by append_mailbox(), inboxcount(), load_module(), poll_subscribed_mailbox(), and run_externnotify().
05111 { 05112 char tmp[256]; 05113 char *context; 05114 05115 /* If no mailbox, return immediately */ 05116 if (ast_strlen_zero(mailbox)) 05117 return 0; 05118 05119 if (newmsgs) 05120 *newmsgs = 0; 05121 if (oldmsgs) 05122 *oldmsgs = 0; 05123 if (urgentmsgs) 05124 *urgentmsgs = 0; 05125 05126 if (strchr(mailbox, ',')) { 05127 int tmpnew, tmpold, tmpurgent; 05128 char *mb, *cur; 05129 05130 ast_copy_string(tmp, mailbox, sizeof(tmp)); 05131 mb = tmp; 05132 while ((cur = strsep(&mb, ", "))) { 05133 if (!ast_strlen_zero(cur)) { 05134 if (inboxcount2(cur, urgentmsgs ? &tmpurgent : NULL, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL)) 05135 return -1; 05136 else { 05137 if (newmsgs) 05138 *newmsgs += tmpnew; 05139 if (oldmsgs) 05140 *oldmsgs += tmpold; 05141 if (urgentmsgs) 05142 *urgentmsgs += tmpurgent; 05143 } 05144 } 05145 } 05146 return 0; 05147 } 05148 05149 ast_copy_string(tmp, mailbox, sizeof(tmp)); 05150 05151 if ((context = strchr(tmp, '@'))) 05152 *context++ = '\0'; 05153 else 05154 context = "default"; 05155 05156 if (newmsgs) 05157 *newmsgs = __has_voicemail(context, tmp, "INBOX", 0); 05158 if (oldmsgs) 05159 *oldmsgs = __has_voicemail(context, tmp, "Old", 0); 05160 if (urgentmsgs) 05161 *urgentmsgs = __has_voicemail(context, tmp, "Urgent", 0); 05162 05163 return 0; 05164 }
| static int inbuf | ( | struct baseio * | bio, | |
| FILE * | fi | |||
| ) | [static] |
utility used by inchar(), for base_encode()
Definition at line 3932 of file app_voicemail.c.
References baseio::ateof, BASEMAXINLINE, baseio::iobuf, baseio::iocp, and baseio::iolen.
Referenced by ast_eivr_getvariable(), ast_eivr_setvariable(), inchar(), sip_addheader(), and sip_removeheader().
03933 { 03934 int l; 03935 03936 if (bio->ateof) 03937 return 0; 03938 03939 if ((l = fread(bio->iobuf,1,BASEMAXINLINE,fi)) <= 0) { 03940 if (ferror(fi)) 03941 return -1; 03942 03943 bio->ateof = 1; 03944 return 0; 03945 } 03946 03947 bio->iolen= l; 03948 bio->iocp= 0; 03949 03950 return 1; 03951 }
| static int inchar | ( | struct baseio * | bio, | |
| FILE * | fi | |||
| ) | [static] |
utility used by base_encode()
Definition at line 3956 of file app_voicemail.c.
References inbuf(), baseio::iobuf, baseio::iocp, and baseio::iolen.
Referenced by base_encode().
03957 { 03958 if (bio->iocp>=bio->iolen) { 03959 if (!inbuf(bio, fi)) 03960 return EOF; 03961 } 03962 03963 return bio->iobuf[bio->iocp++]; 03964 }
| static int inprocess_cmp_fn | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 852 of file app_voicemail.c.
References CMP_MATCH, inprocess::context, and inprocess::mailbox.
Referenced by load_module().
00853 { 00854 struct inprocess *i = obj, *j = arg; 00855 if (strcmp(i->mailbox, j->mailbox)) { 00856 return 0; 00857 } 00858 return !strcmp(i->context, j->context) ? CMP_MATCH : 0; 00859 }
| static int inprocess_count | ( | const char * | context, | |
| const char * | mailbox, | |||
| int | delta | |||
| ) | [static] |
Definition at line 861 of file app_voicemail.c.
References ao2_alloc, ao2_find, ao2_link, ao2_lock(), ao2_ref, ao2_unlock(), ast_atomic_fetchadd_int(), ast_log(), inprocess::context, inprocess::count, inprocess_container, LOG_WARNING, and inprocess::mailbox.
Referenced by copy_message(), forward_message(), and leave_voicemail().
00862 { 00863 struct inprocess *i, *arg = alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2); 00864 arg->context = arg->mailbox + strlen(mailbox) + 1; 00865 strcpy(arg->mailbox, mailbox); /* SAFE */ 00866 strcpy(arg->context, context); /* SAFE */ 00867 ao2_lock(inprocess_container); 00868 if ((i = ao2_find(inprocess_container, arg, 0))) { 00869 int ret = ast_atomic_fetchadd_int(&i->count, delta); 00870 ao2_unlock(inprocess_container); 00871 ao2_ref(i, -1); 00872 return ret; 00873 } 00874 if (delta < 0) { 00875 ast_log(LOG_WARNING, "BUG: ref count decrement on non-existing object???\n"); 00876 } 00877 if (!(i = ao2_alloc(sizeof(*i) + strlen(context) + strlen(mailbox) + 2, NULL))) { 00878 ao2_unlock(inprocess_container); 00879 return 0; 00880 } 00881 i->context = i->mailbox + strlen(mailbox) + 1; 00882 strcpy(i->mailbox, mailbox); /* SAFE */ 00883 strcpy(i->context, context); /* SAFE */ 00884 i->count = delta; 00885 ao2_link(inprocess_container, i); 00886 ao2_unlock(inprocess_container); 00887 ao2_ref(i, -1); 00888 return 0; 00889 }
| static int inprocess_hash_fn | ( | const void * | obj, | |
| const int | flags | |||
| ) | [static] |
Definition at line 846 of file app_voicemail.c.
References inprocess::mailbox.
Referenced by load_module().
| static int invent_message | ( | struct ast_channel * | chan, | |
| char * | context, | |||
| char * | ext, | |||
| int | busy, | |||
| char * | ecodes | |||
| ) | [static] |
Definition at line 4715 of file app_voicemail.c.
References ast_fileexists(), ast_log(), AST_LOG_WARNING, ast_say_digit_str(), ast_stream_and_wait(), create_dirpath(), DISPOSE, ast_channel::language, and RETRIEVE.
Referenced by leave_voicemail().
04716 { 04717 int res; 04718 char fn[PATH_MAX]; 04719 char dest[PATH_MAX]; 04720 04721 snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext); 04722 04723 if ((res = create_dirpath(dest, sizeof(dest), context, ext, ""))) { 04724 ast_log(AST_LOG_WARNING, "Failed to make directory(%s)\n", fn); 04725 return -1; 04726 } 04727 04728 RETRIEVE(fn, -1, ext, context); 04729 if (ast_fileexists(fn, NULL, NULL) > 0) { 04730 res = ast_stream_and_wait(chan, fn, ecodes); 04731 if (res) { 04732 DISPOSE(fn, -1); 04733 return res; 04734 } 04735 } else { 04736 /* Dispose just in case */ 04737 DISPOSE(fn, -1); 04738 res = ast_stream_and_wait(chan, "vm-theperson", ecodes); 04739 if (res) 04740 return res; 04741 res = ast_say_digit_str(chan, ext, ecodes, chan->language); 04742 if (res) 04743 return res; 04744 } 04745 res = ast_stream_and_wait(chan, busy ? "vm-isonphone" : "vm-isunavail", ecodes); 04746 return res; 04747 }
| static int is_valid_dtmf | ( | const char * | key | ) | [static] |
Determines if a DTMF key entered is valid.
| key | The character to be compared. expects a single character. Though is capable of handling a string, this is internally copies using ast_strdupa. |
Definition at line 1235 of file app_voicemail.c.
References ast_log(), AST_LOG_WARNING, ast_strdupa, and VALID_DTMF.
Referenced by load_config().
01236 { 01237 int i; 01238 char *local_key = ast_strdupa(key); 01239 01240 for (i = 0; i < strlen(key); ++i) { 01241 if (!strchr(VALID_DTMF, *local_key)) { 01242 ast_log(AST_LOG_WARNING, "Invalid DTMF key \"%c\" used in voicemail configuration file\n", *local_key); 01243 return 0; 01244 } 01245 local_key++; 01246 } 01247 return 1; 01248 }
| static int last_message_index | ( | struct ast_vm_user * | vmu, | |
| char * | dir | |||
| ) | [static] |
Determines the highest message number in use for a given user and mailbox folder.
| vmu | ||
| dir | the folder the mailbox folder to look for messages. Used to construct the SQL where clause. |
Definition at line 3758 of file app_voicemail.c.
References map, ast_vm_user::maxmsg, and MAXMSGLIMIT.
Referenced by copy_message(), leave_voicemail(), open_mailbox(), and save_to_folder().
03759 { 03760 int x; 03761 unsigned char map[MAXMSGLIMIT] = ""; 03762 DIR *msgdir; 03763 struct dirent *msgdirent; 03764 int msgdirint; 03765 03766 /* Reading the entire directory into a file map scales better than 03767 * doing a stat repeatedly on a predicted sequence. I suspect this 03768 * is partially due to stat(2) internally doing a readdir(2) itself to 03769 * find each file. */ 03770 if (!(msgdir = opendir(dir))) { 03771 return -1; 03772 } 03773 03774 while ((msgdirent = readdir(msgdir))) { 03775 if (sscanf(msgdirent->d_name, "msg%30d", &msgdirint) == 1 && msgdirint < MAXMSGLIMIT) 03776 map[msgdirint] = 1; 03777 } 03778 closedir(msgdir); 03779 03780 for (x = 0; x < vmu->maxmsg; x++) { 03781 if (map[x] == 0) 03782 break; 03783 } 03784 03785 return x - 1; 03786 }
| static int leave_voicemail | ( | struct ast_channel * | chan, | |
| char * | ext, | |||
| struct leave_vm_options * | options | |||
| ) | [static] |
Prompts the user and records a voicemail to a mailbox.
| chan | ||
| ext | ||
| options | OPT_BUSY_GREETING, OPT_UNAVAIL_GREETING |
Definition at line 5242 of file app_voicemail.c.
References ast_callerid_merge(), ast_canmatch_extension(), ast_channel_lock, ast_channel_unlock, ast_check_realtime(), ast_copy_string(), ast_debug, ast_destroy_realtime(), ast_exists_extension(), ast_filedelete(), ast_fileexists(), ast_filerename(), ast_free, ast_log(), AST_LOG_ERROR, AST_LOG_NOTICE, AST_LOG_WARNING, ast_mutex_lock(), ast_mutex_unlock(), ast_play_and_wait(), ast_set_flag, ast_stopstream(), ast_store_realtime(), ast_str_buffer(), ast_str_create(), ast_str_set(), ast_strdupa, ast_stream_and_wait(), ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_unlock_path(), ast_update_realtime(), ast_verbose, ast_waitstream(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, ast_vm_user::context, copy_message(), count_messages(), create_dirpath(), DISPOSE, errno, ast_vm_user::exit, leave_vm_options::exitcontext, exten, ast_channel::exten, find_user(), free_user(), get_date(), inboxcount(), inprocess_count(), INTRO, invent_message(), ast_channel::language, last_message_index(), LOG_WARNING, ast_channel::macrocontext, ast_vm_user::mailbox, make_file(), ast_vm_user::maxmsg, ast_vm_user::maxsecs, ast_channel::name, vm_state::newmessages, notify_new_message(), OPERATOR_EXIT, OPT_BUSY_GREETING, OPT_DTMFEXIT, OPT_MESSAGE_PRIORITY, OPT_MESSAGE_Urgent, 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, RENAME, RETRIEVE, S_OR, SENTINEL, STORE, strsep(), transfer, VERBOSE_PREFIX_3, vm_lock_path(), VM_OPERATOR, VOICEMAIL_DIR_MODE, and VOICEMAIL_FILE_MODE.
Referenced by advanced_options(), forward_message(), and vm_exec().
05243 { 05244 #ifdef IMAP_STORAGE 05245 int newmsgs, oldmsgs; 05246 #else 05247 char urgdir[PATH_MAX]; 05248 #endif 05249 char txtfile[PATH_MAX]; 05250 char tmptxtfile[PATH_MAX]; 05251 struct vm_state *vms = NULL; 05252 char callerid[256]; 05253 FILE *txt; 05254 char date[256]; 05255 int txtdes; 05256 int res = 0; 05257 int msgnum; 05258 int duration = 0; 05259 int ausemacro = 0; 05260 int ousemacro = 0; 05261 int ouseexten = 0; 05262 char tmpdur[16]; 05263 char priority[16]; 05264 char origtime[16]; 05265 char dir[PATH_MAX]; 05266 char tmpdir[PATH_MAX]; 05267 char fn[PATH_MAX]; 05268 char prefile[PATH_MAX] = ""; 05269 char tempfile[PATH_MAX] = ""; 05270 char ext_context[256] = ""; 05271 char fmt[80]; 05272 char *context; 05273 char ecodes[17] = "#"; 05274 struct ast_str *tmp = ast_str_create(16); 05275 char *tmpptr; 05276 struct ast_vm_user *vmu; 05277 struct ast_vm_user svm; 05278 const char *category = NULL; 05279 const char *code; 05280 const char *alldtmf = "0123456789ABCD*#"; 05281 char flag[80]; 05282 05283 ast_str_set(&tmp, 0, "%s", ext); 05284 ext = ast_str_buffer(tmp); 05285 if ((context = strchr(ext, '@'))) { 05286 *context++ = '\0'; 05287 tmpptr = strchr(context, '&'); 05288 } else { 05289 tmpptr = strchr(ext, '&'); 05290 } 05291 05292 if (tmpptr) 05293 *tmpptr++ = '\0'; 05294 05295 ast_channel_lock(chan); 05296 if ((category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY"))) { 05297 category = ast_strdupa(category); 05298 } 05299 ast_channel_unlock(chan); 05300 05301 if (ast_test_flag(options, OPT_MESSAGE_Urgent)) { 05302 ast_copy_string(flag, "Urgent", sizeof(flag)); 05303 } else if (ast_test_flag(options, OPT_MESSAGE_PRIORITY)) { 05304 ast_copy_string(flag, "PRIORITY", sizeof(flag)); 05305 } else { 05306 flag[0] = '\0'; 05307 } 05308 05309 ast_debug(3, "Before find_user\n"); 05310 if (!(vmu = find_user(&svm, context, ext))) { 05311 ast_log(AST_LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext); 05312 pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); 05313 ast_free(tmp); 05314 return res; 05315 } 05316 /* Setup pre-file if appropriate */ 05317 if (strcmp(vmu->context, "default")) 05318 snprintf(ext_context, sizeof(ext_context), "%s@%s", ext, vmu->context); 05319 else 05320 ast_copy_string(ext_context, vmu->mailbox, sizeof(ext_context)); 05321 05322 /* Set the path to the prefile. Will be one of 05323 VM_SPOOL_DIRcontext/ext/busy 05324 VM_SPOOL_DIRcontext/ext/unavail 05325 Depending on the flag set in options. 05326 */ 05327 if (ast_test_flag(options, OPT_BUSY_GREETING)) { 05328 snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, ext); 05329 } else if (ast_test_flag(options, OPT_UNAVAIL_GREETING)) { 05330 snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, ext); 05331 } 05332 /* Set the path to the tmpfile as 05333 VM_SPOOL_DIR/context/ext/temp 05334 and attempt to create the folder structure. 05335 */ 05336 snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, ext); 05337 if ((res = create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, ext, "tmp"))) { 05338 ast_log(AST_LOG_WARNING, "Failed to make directory (%s)\n", tempfile); 05339 ast_free(tmp); 05340 return -1; 05341 } 05342 RETRIEVE(tempfile, -1, vmu->mailbox, vmu->context); 05343 if (ast_fileexists(tempfile, NULL, NULL) > 0) 05344 ast_copy_string(prefile, tempfile, sizeof(prefile)); 05345 05346 DISPOSE(tempfile, -1); 05347 /* It's easier just to try to make it than to check for its existence */ 05348 #ifndef IMAP_STORAGE 05349 create_dirpath(dir, sizeof(dir), vmu->context, ext, "INBOX"); 05350 #else 05351 snprintf(dir, sizeof(dir), "%simap", VM_SPOOL_DIR); 05352 if (mkdir(dir, VOICEMAIL_DIR_MODE) && errno != EEXIST) { 05353 ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno)); 05354 } 05355 #endif 05356 05357 /* Check current or macro-calling context for special extensions */ 05358 if (ast_test_flag(vmu, VM_OPERATOR)) { 05359 if (!ast_strlen_zero(vmu->exit)) { 05360 if (ast_exists_extension(chan, vmu->exit, "o", 1, chan->cid.cid_num)) { 05361 strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1); 05362 ouseexten = 1; 05363 } 05364 } else if (ast_exists_extension(chan, chan->context, "o", 1, chan->cid.cid_num)) { 05365 strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1); 05366 ouseexten = 1; 05367 } else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "o", 1, chan->cid.cid_num)) { 05368 strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1); 05369 ousemacro = 1; 05370 } 05371 } 05372 05373 if (!ast_strlen_zero(vmu->exit)) { 05374 if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->cid.cid_num)) 05375 strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1); 05376 } else if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num)) 05377 strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1); 05378 else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) { 05379 strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1); 05380 ausemacro = 1; 05381 } 05382 05383 if (ast_test_flag(options, OPT_DTMFEXIT)) { 05384 for (code = alldtmf; *code; code++) { 05385 char e[2] = ""; 05386 e[0] = *code; 05387 if (strchr(ecodes, e[0]) == NULL && ast_canmatch_extension(chan, chan->context, e, 1, chan->cid.cid_num)) 05388 strncat(ecodes, e, sizeof(ecodes) - strlen(ecodes) - 1); 05389 } 05390 } 05391 05392 /* Play the beginning intro if desired */ 05393 if (!ast_strlen_zero(prefile)) { 05394 #ifdef ODBC_STORAGE 05395 int success = 05396 #endif 05397 RETRIEVE(prefile, -1, ext, context); 05398 if (ast_fileexists(prefile, NULL, NULL) > 0) { 05399 if (ast_streamfile(chan, prefile, chan->language) > -1) 05400 res = ast_waitstream(chan, ecodes); 05401 #ifdef ODBC_STORAGE 05402 if (success == -1) { 05403 /* We couldn't retrieve the file from the database, but we found it on the file system. Let's put it in the database. */ 05404 ast_debug(1, "Greeting not retrieved from database, but found in file storage. Inserting into database\n"); 05405 store_file(prefile, vmu->mailbox, vmu->context, -1); 05406 } 05407 #endif 05408 } else { 05409 ast_debug(1, "%s doesn't exist, doing what we can\n", prefile); 05410 res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes); 05411 } 05412 DISPOSE(prefile, -1); 05413 if (res < 0) { 05414 ast_debug(1, "Hang up during prefile playback\n"); 05415 free_user(vmu); 05416 pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); 05417 ast_free(tmp); 05418 return -1; 05419 } 05420 } 05421 if (res == '#') { 05422 /* On a '#' we skip the instructions */ 05423 ast_set_flag(options, OPT_SILENT); 05424 res = 0; 05425 } 05426 if (!res && !ast_test_flag(options, OPT_SILENT)) { 05427 res = ast_stream_and_wait(chan, INTRO, ecodes); 05428 if (res == '#') { 05429 ast_set_flag(options, OPT_SILENT); 05430 res = 0; 05431 } 05432 } 05433 if (res > 0) 05434 ast_stopstream(chan); 05435 /* Check for a '*' here in case the caller wants to escape from voicemail to something 05436 other than the operator -- an automated attendant or mailbox login for example */ 05437 if (res == '*') { 05438 chan->exten[0] = 'a'; 05439 chan->exten[1] = '\0'; 05440 if (!ast_strlen_zero(vmu->exit)) { 05441 ast_copy_string(chan->context, vmu->exit, sizeof(chan->context)); 05442 } else if (ausemacro && !ast_strlen_zero(chan->macrocontext)) { 05443 ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context)); 05444 } 05445 chan->priority = 0; 05446 free_user(vmu); 05447 pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); 05448 ast_free(tmp); 05449 return 0; 05450 } 05451 05452 /* Check for a '0' here */ 05453 if (ast_test_flag(vmu, VM_OPERATOR) && res == '0') { 05454 transfer: 05455 if (ouseexten || ousemacro) { 05456 chan->exten[0] = 'o'; 05457 chan->exten[1] = '\0'; 05458 if (!ast_strlen_zero(vmu->exit)) { 05459 ast_copy_string(chan->context, vmu->exit, sizeof(chan->context)); 05460 } else if (ousemacro && !ast_strlen_zero(chan->macrocontext)) { 05461 ast_copy_string(chan->context, chan->macrocontext, sizeof(chan->context)); 05462 } 05463 ast_play_and_wait(chan, "transfer"); 05464 chan->priority = 0; 05465 free_user(vmu); 05466 pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); 05467 } 05468 ast_free(tmp); 05469 return OPERATOR_EXIT; 05470 } 05471 05472 /* Allow all other digits to exit Voicemail and return to the dialplan */ 05473 if (ast_test_flag(options, OPT_DTMFEXIT) && res > 0) { 05474 if (!ast_strlen_zero(options->exitcontext)) 05475 ast_copy_string(chan->context, options->exitcontext, sizeof(chan->context)); 05476 free_user(vmu); 05477 pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); 05478 ast_free(tmp); 05479 return res; 05480 } 05481 05482 if (res < 0) { 05483 free_user(vmu); 05484 pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); 05485 ast_free(tmp); 05486 return -1; 05487 } 05488 /* The meat of recording the message... All the announcements and beeps have been played*/ 05489 ast_copy_string(fmt, vmfmts, sizeof(fmt)); 05490 if (!ast_strlen_zero(fmt)) { 05491 msgnum = 0; 05492 05493 #ifdef IMAP_STORAGE 05494 /* Is ext a mailbox? */ 05495 /* must open stream for this user to get info! */ 05496 res = inboxcount(ext_context, &newmsgs, &oldmsgs); 05497 if (res < 0) { 05498 ast_log(AST_LOG_NOTICE, "Can not leave voicemail, unable to count messages\n"); 05499 ast_free(tmp); 05500 return -1; 05501 } 05502 if (!(vms = get_vm_state_by_mailbox(ext, context, 0))) { 05503 /* It is possible under certain circumstances that inboxcount did not 05504 * create a vm_state when it was needed. This is a catchall which will 05505 * rarely be used. 05506 */ 05507 if (!(vms = create_vm_state_from_user(vmu))) { 05508 ast_log(AST_LOG_ERROR, "Couldn't allocate necessary space\n"); 05509 ast_free(tmp); 05510 return -1; 05511 } 05512 } 05513 vms->newmessages++; 05514 05515 /* here is a big difference! We add one to it later */ 05516 msgnum = newmsgs + oldmsgs; 05517 ast_debug(3, "Messagecount set to %d\n",msgnum); 05518 snprintf(fn, sizeof(fn), "%simap/msg%s%04d", VM_SPOOL_DIR, vmu->mailbox, msgnum); 05519 /* set variable for compatibility */ 05520 pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE"); 05521 05522 if ((res = imap_check_limits(chan, vms, vmu, msgnum))) { 05523 goto leave_vm_out; 05524 } 05525 #else 05526 if (count_messages(vmu, dir) >= vmu->maxmsg - inprocess_count(vmu->mailbox, vmu->context, +1)) { 05527 res = ast_streamfile(chan, "vm-mailboxfull", chan->language); 05528 if (!res) 05529 res = ast_waitstream(chan, ""); 05530 ast_log(AST_LOG_WARNING, "No more messages possible\n"); 05531 pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); 05532 inprocess_count(vmu->mailbox, vmu->context, -1); 05533 goto leave_vm_out; 05534 } 05535 05536 #endif 05537 snprintf(tmptxtfile, sizeof(tmptxtfile), "%s/XXXXXX", tmpdir); 05538 txtdes = mkstemp(tmptxtfile); 05539 chmod(tmptxtfile, VOICEMAIL_FILE_MODE & ~my_umask); 05540 if (txtdes < 0) { 05541 res = ast_streamfile(chan, "vm-mailboxfull", chan->language); 05542 if (!res) 05543 res = ast_waitstream(chan, ""); 05544 ast_log(AST_LOG_ERROR, "Unable to create message file: %s\n", strerror(errno)); 05545 pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); 05546 inprocess_count(vmu->mailbox, vmu->context, -1); 05547 goto leave_vm_out; 05548 } 05549 05550 /* Now play the beep once we have the message number for our next message. */ 05551 if (res >= 0) { 05552 /* Unless we're *really* silent, try to send the beep */ 05553 res = ast_stream_and_wait(chan, "beep", ""); 05554 } 05555 05556 /* Store information in real-time storage */ 05557 if (ast_check_realtime("voicemail_data")) { 05558 snprintf(priority, sizeof(priority), "%d", chan->priority); 05559 snprintf(origtime, sizeof(origtime), "%ld", (long)time(NULL)); 05560 get_date(date, sizeof(date)); 05561 ast_store_realtime("voicemail_data", "origmailbox", ext, "context", chan->context, "macrocontext", chan->macrocontext, "exten", chan->exten, "priority", priority, "callerchan", chan->name, "callerid", ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"), "origdate", date, "origtime", origtime, "category", S_OR(category,""), "filename", tmptxtfile, SENTINEL); 05562 } 05563 05564 /* Store information */ 05565 txt = fdopen(txtdes, "w+"); 05566 if (txt) { 05567 get_date(date, sizeof(date)); 05568 fprintf(txt, 05569 ";\n" 05570 "; Message Information file\n" 05571 ";\n" 05572 "[message]\n" 05573 "origmailbox=%s\n" 05574 "context=%s\n" 05575 "macrocontext=%s\n" 05576 "exten=%s\n" 05577 "priority=%d\n" 05578 "callerchan=%s\n" 05579 "callerid=%s\n" 05580 "origdate=%s\n" 05581 "origtime=%ld\n" 05582 "category=%s\n", 05583 ext, 05584 chan->context, 05585 chan->macrocontext, 05586 chan->exten, 05587 chan->priority, 05588 chan->name, 05589 ast_callerid_merge(callerid, sizeof(callerid), S_OR(chan->cid.cid_name, NULL), S_OR(chan->cid.cid_num, NULL), "Unknown"), 05590 date, (long)time(NULL), 05591 category ? category : ""); 05592 } else { 05593 ast_log(AST_LOG_WARNING, "Error opening text file for output\n"); 05594 inprocess_count(vmu->mailbox, vmu->context, -1); 05595 if (ast_check_realtime("voicemail_data")) { 05596 ast_destroy_realtime("voicemail_data", "filename", tmptxtfile, SENTINEL); 05597 } 05598 res = ast_streamfile(chan, "vm-mailboxfull", chan->language); 05599 goto leave_vm_out; 05600 } 05601 res = play_record_review(chan, NULL, tmptxtfile, vmu->maxsecs, fmt, 1, vmu, &duration, NULL, options->record_gain, vms, flag); 05602 05603 if (txt) { 05604 fprintf(txt, "flag=%s\n", flag); 05605 if (duration < vmminsecs) { 05606 fclose(txt); 05607 if (option_verbose > 2) 05608 ast_verbose( VERBOSE_PREFIX_3 "Recording was %d seconds long but needs to be at least %d - abandoning\n", duration, vmminsecs); 05609 ast_filedelete(tmptxtfile, NULL); 05610 unlink(tmptxtfile); 05611 if (ast_check_realtime("voicemail_data")) { 05612 ast_destroy_realtime("voicemail_data", "filename", tmptxtfile, SENTINEL); 05613 } 05614 inprocess_count(vmu->mailbox, vmu->context, -1); 05615 } else { 05616 fprintf(txt, "duration=%d\n", duration); 05617 fclose(txt); 05618 if (vm_lock_path(dir)) { 05619 ast_log(AST_LOG_ERROR, "Couldn't lock directory %s. Voicemail will be lost.\n", dir); 05620 /* Delete files */ 05621 ast_filedelete(tmptxtfile, NULL); 05622 unlink(tmptxtfile); 05623 inprocess_count(vmu->mailbox, vmu->context, -1); 05624 } else if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) { 05625 ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n"); 05626 unlink(tmptxtfile); 05627 ast_unlock_path(dir); 05628 inprocess_count(vmu->mailbox, vmu->context, -1); 05629 if (ast_check_realtime("voicemail_data")) { 05630 ast_destroy_realtime("voicemail_data", "filename", tmptxtfile, SENTINEL); 05631 } 05632 } else { 05633 #ifndef IMAP_STORAGE 05634 msgnum = last_message_index(vmu, dir) + 1; 05635 #endif 05636 make_file(fn, sizeof(fn), dir, msgnum); 05637 05638 /* assign a variable with the name of the voicemail file */ 05639 #ifndef IMAP_STORAGE 05640 pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", fn); 05641 #else 05642 pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE"); 05643 #endif 05644 05645 snprintf(txtfile, sizeof(txtfile), "%s.txt", fn); 05646 ast_filerename(tmptxtfile, fn, NULL); 05647 rename(tmptxtfile, txtfile); 05648 inprocess_count(vmu->mailbox, vmu->context, -1); 05649 05650 /* Properly set permissions on voicemail text descriptor file. 05651 Unfortunately mkstemp() makes this file 0600 on most unix systems. */ 05652 if (chmod(txtfile, VOICEMAIL_FILE_MODE) < 0) 05653 ast_log(AST_LOG_ERROR, "Couldn't set permissions on voicemail text file %s: %s", txtfile, strerror(errno)); 05654 05655 ast_unlock_path(dir); 05656 if (ast_check_realtime("voicemail_data")) { 05657 snprintf(tmpdur, sizeof(tmpdur), "%d", duration); 05658 ast_update_realtime("voicemail_data", "filename", tmptxtfile, "filename", fn, "duration", tmpdur, SENTINEL); 05659 } 05660 /* We must store the file first, before copying the message, because 05661 * ODBC storage does the entire copy with SQL. 05662 */ 05663 if (ast_fileexists(fn, NULL, NULL) > 0) { 05664 STORE(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, fmt, duration, vms, flag); 05665 } 05666 05667 /* Are there to be more recipients of this message? */ 05668 while (tmpptr) { 05669 struct ast_vm_user recipu, *recip; 05670 char *exten, *cntx; 05671 05672 exten = strsep(&tmpptr, "&"); 05673 cntx = strchr(exten, '@'); 05674 if (cntx) { 05675 *cntx = '\0'; 05676 cntx++; 05677 } 05678 if ((recip = find_user(&recipu, cntx, exten))) { 05679 copy_message(chan, vmu, 0, msgnum, duration, recip, fmt, dir, flag); 05680 free_user(recip); 05681 } 05682 } 05683 #ifndef IMAP_STORAGE 05684 if (!ast_strlen_zero(flag) && !strcmp(flag, "Urgent")) { /* If this is an Urgent message */ 05685 /* Move the message from INBOX to Urgent folder if this is urgent! */ 05686 char sfn[PATH_MAX]; 05687 char dfn[PATH_MAX]; 05688 int x; 05689 /* It's easier just to try to make it than to check for its existence */ 05690 create_dirpath(urgdir, sizeof(urgdir), vmu->context, ext, "Urgent"); 05691 x = last_message_index(vmu, urgdir) + 1; 05692 make_file(sfn, sizeof(sfn), dir, msgnum); 05693 make_file(dfn, sizeof(dfn), urgdir, x); 05694 ast_debug(5, "Created an Urgent message, moving file from %s to %s.\n", sfn, dfn); 05695 RENAME(dir, msgnum, vmu->mailbox, vmu->context, urgdir, x, sfn, dfn); 05696 /* Notification must happen for this new message in Urgent folder, not INBOX */ 05697 ast_copy_string(fn, dfn, sizeof(fn)); 05698 msgnum = x; 05699 } 05700 #endif 05701 /* Notification needs to happen after the copy, though. */ 05702 if (ast_fileexists(fn, NULL, NULL)) { 05703 #ifdef IMAP_STORAGE 05704 notify_new_message(chan, vmu, vms, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), flag); 05705 #else 05706 notify_new_message(chan, vmu, NULL, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), flag); 05707 #endif 05708 } 05709 05710 /* Disposal needs to happen after the optional move and copy */ 05711 if (ast_fileexists(fn, NULL, NULL)) { 05712 DISPOSE(dir, msgnum); 05713 } 05714 } 05715 } 05716 } else { 05717 inprocess_count(vmu->mailbox, vmu->context, -1); 05718 } 05719 if (res == '0') { 05720 goto transfer; 05721 } else if (res > 0 && res != 't') 05722 res = 0; 05723 05724 if (duration < vmminsecs) 05725 /* XXX We should really give a prompt too short/option start again, with leave_vm_out called only after a timeout XXX */ 05726 pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); 05727 else 05728 pbx_builtin_setvar_helper(chan, "VMSTATUS", "SUCCESS"); 05729 } else 05730 ast_log(AST_LOG_WARNING, "No format for saving voicemail?\n"); 05731 leave_vm_out: 05732 free_user(vmu); 05733 05734 #ifdef IMAP_STORAGE 05735 /* expunge message - use UID Expunge if supported on IMAP server*/ 05736 ast_debug(3, "*** Checking if we can expunge, expungeonhangup set to %d\n",expungeonhangup); 05737 if (expungeonhangup == 1) { 05738 ast_mutex_lock(&vms->lock); 05739 #ifdef HAVE_IMAP_TK2006 05740 if (LEVELUIDPLUS (vms->mailstream)) { 05741 mail_expunge_full(vms->mailstream,NIL,EX_UID); 05742 } else 05743 #endif 05744 mail_expunge(vms->mailstream); 05745 ast_mutex_unlock(&vms->lock); 05746 } 05747 #endif 05748 05749 ast_free(tmp); 05750 return res; 05751 }
| static int load_config | ( | int | reload | ) | [static] |
Definition at line 10777 of file app_voicemail.c.
References adsifdn, adsisec, adsiver, append_mailbox(), apply_options_full(), ast_category_browse(), ast_clear_flag, ast_config_destroy(), ast_config_load, ast_config_option(), ast_copy_string(), ast_debug, ast_dsp_get_threshold_from_settings(), ast_false(), ast_format_str_reduce(), ast_free, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), AST_LOG_DEBUG, AST_LOG_ERROR, AST_LOG_WARNING, ast_malloc, AST_PTHREADT_NULL, ast_set2_flag, ast_smdi_interface_find(), ast_strdup, ast_strdupa, ast_strlen_zero(), ast_true(), ast_unload_realtime(), ast_variable_browse(), ast_variable_retrieve(), ASTERISK_USERNAME, callcontext, charset, cidinternalcontexts, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, ast_vm_user::context, DEFAULT_LISTEN_CONTROL_FORWARD_KEY, DEFAULT_LISTEN_CONTROL_PAUSE_KEY, DEFAULT_LISTEN_CONTROL_RESTART_KEY, DEFAULT_LISTEN_CONTROL_REVERSE_KEY, DEFAULT_LISTEN_CONTROL_STOP_KEY, DEFAULT_POLL_FREQ, dialcontext, emailbody, emaildateformat, emailsubject, exitcontext, find_or_create(), free_vm_users(), free_vm_zones(), fromstring, globalflags, is_valid_dtmf(), ast_variable::lineno, listen_control_forward_key, listen_control_pause_key, listen_control_restart_key, listen_control_reverse_key, listen_control_stop_key, LOG_ERROR, MAX_NUM_CID_CONTEXTS, MAXMSG, MAXMSGLIMIT, MINPASSWORD, vm_zone::msg_format, vm_zone::name, ast_variable::name, ast_variable::next, pagerbody, pagerfromstring, pagersubject, populate_defaults(), PWDCHANGE_EXTERNAL, PWDCHANGE_INTERNAL, saydurationminfo, SENDMAIL, start_poll_thread(), stop_poll_thread(), strsep(), substitute_escapes(), THRESHOLD_SILENCE, vm_zone::timezone, ast_variable::value, VM_ATTACH, VM_DIRECFORWARD, VM_ENVELOPE, VM_FORCEGREET, VM_FORCENAME, VM_FWDURGAUTO, vm_invalid_password, VM_MESSAGEWRAP, vm_mismatch, VM_MOVEHEARD, vm_newpassword, VM_OPERATOR, vm_passchanged, vm_password, VM_PBXSKIP, vm_pls_try_again, vm_reenterpassword, VM_REVIEW, VM_SAYCID, VM_SAYDURATION, VM_SEARCH, VM_SKIPAFTERCMD, VM_SVMAIL, VM_TEMPGREETWARN, and VOICEMAIL_CONFIG.
Referenced by handle_voicemail_reload(), load_module(), and reload().
10778 { 10779 struct ast_vm_user *current; 10780 struct ast_config *cfg, *ucfg; 10781 char *cat; 10782 struct ast_variable *var; 10783 const char *val; 10784 char *q, *stringp, *tmp; 10785 int x; 10786 int tmpadsi[4]; 10787 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 10788 10789 ast_unload_realtime("voicemail"); 10790 ast_unload_realtime("voicemail_data"); 10791 10792 if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { 10793 if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { 10794 return 0; 10795 } else if (ucfg == CONFIG_STATUS_FILEINVALID) { 10796 ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Avoiding.\n"); 10797 ucfg = NULL; 10798 } 10799 ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); 10800 if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) == CONFIG_STATUS_FILEINVALID) { 10801 ast_config_destroy(ucfg); 10802 ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n"); 10803 return 0; 10804 } 10805 } else if (cfg == CONFIG_STATUS_FILEINVALID) { 10806 ast_log(LOG_ERROR, "Config file " VOICEMAIL_CONFIG " is in an invalid format. Aborting.\n"); 10807 return 0; 10808 } else { 10809 ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED); 10810 if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) { 10811 ast_log(LOG_ERROR, "Config file users.conf is in an invalid format. Avoiding.\n"); 10812 ucfg = NULL; 10813 } 10814 } 10815 #ifdef IMAP_STORAGE 10816 ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder)); 10817 #endif 10818 /* set audio control prompts */ 10819 strcpy(listen_control_forward_key,DEFAULT_LISTEN_CONTROL_FORWARD_KEY); 10820 strcpy(listen_control_reverse_key,DEFAULT_LISTEN_CONTROL_REVERSE_KEY); 10821 strcpy(listen_control_pause_key,DEFAULT_LISTEN_CONTROL_PAUSE_KEY); 10822 strcpy(listen_control_restart_key,DEFAULT_LISTEN_CONTROL_RESTART_KEY); 10823 strcpy(listen_control_stop_key,DEFAULT_LISTEN_CONTROL_STOP_KEY); 10824 10825 /* Free all the users structure */ 10826 free_vm_users(); 10827 10828 /* Free all the zones structure */ 10829 free_vm_zones(); 10830 10831 AST_LIST_LOCK(&users); 10832 10833 memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd)); 10834 memset(ext_pass_check_cmd, 0, sizeof(ext_pass_check_cmd)); 10835 10836 if (cfg) { 10837 /* General settings */ 10838 10839 if (!(val = ast_variable_retrieve(cfg, "general", "userscontext"))) 10840 val = "default"; 10841 ast_copy_string(userscontext, val, sizeof(userscontext)); 10842 /* Attach voice message to mail message ? */ 10843 if (!(val = ast_variable_retrieve(cfg, "general", "attach"))) 10844 val = "yes"; 10845 ast_set2_flag((&globalflags), ast_true(val), VM_ATTACH); 10846 10847 if (!(val = ast_variable_retrieve(cfg, "general", "searchcontexts"))) 10848 val = "no"; 10849 ast_set2_flag((&globalflags), ast_true(val), VM_SEARCH); 10850 10851 volgain = 0.0; 10852 if ((val = ast_variable_retrieve(cfg, "general", "volgain"))) 10853 sscanf(val, "%30lf", &volgain); 10854 10855 #ifdef ODBC_STORAGE 10856 strcpy(odbc_database, "asterisk"); 10857 if ((val = ast_variable_retrieve(cfg, "general", "odbcstorage"))) { 10858 ast_copy_string(odbc_database, val, sizeof(odbc_database)); 10859 } 10860 strcpy(odbc_table, "voicemessages"); 10861 if ((val = ast_variable_retrieve(cfg, "general", "odbctable"))) { 10862 ast_copy_string(odbc_table, val, sizeof(odbc_table)); 10863 } 10864 #endif 10865 /* Mail command */ 10866 strcpy(mailcmd, SENDMAIL); 10867 if ((val = ast_variable_retrieve(cfg, "general", "mailcmd"))) 10868 ast_copy_string(mailcmd, val, sizeof(mailcmd)); /* User setting */ 10869 10870 maxsilence = 0; 10871 if ((val = ast_variable_retrieve(cfg, "general", "maxsilence"))) { 10872 maxsilence = atoi(val); 10873 if (maxsilence > 0) 10874 maxsilence *= 1000; 10875 } 10876 10877 if (!(val = ast_variable_retrieve(cfg, "general", "maxmsg"))) { 10878 maxmsg = MAXMSG; 10879 } else { 10880 maxmsg = atoi(val); 10881 if (maxmsg <= 0) { 10882 ast_log(AST_LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", val, MAXMSG); 10883 maxmsg = MAXMSG; 10884 } else if (maxmsg > MAXMSGLIMIT) { 10885 ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val); 10886 maxmsg = MAXMSGLIMIT; 10887 } 10888 } 10889 10890 if (!(val = ast_variable_retrieve(cfg, "general", "backupdeleted"))) { 10891 maxdeletedmsg = 0; 10892 } else { 10893 if (sscanf(val, "%30d", &x) == 1) 10894 maxdeletedmsg = x; 10895 else if (ast_true(val)) 10896 maxdeletedmsg = MAXMSG; 10897 else 10898 maxdeletedmsg = 0; 10899 10900 if (maxdeletedmsg < 0) { 10901 ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox '%s'. Using default value %i\n", val, MAXMSG); 10902 maxdeletedmsg = MAXMSG; 10903 } else if (maxdeletedmsg > MAXMSGLIMIT) { 10904 ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val); 10905 maxdeletedmsg = MAXMSGLIMIT; 10906 } 10907 } 10908 10909 /* Load date format config for voicemail mail */ 10910 if ((val = ast_variable_retrieve(cfg, "general", "emaildateformat"))) { 10911 ast_copy_string(emaildateformat, val, sizeof(emaildateformat)); 10912 } 10913 10914 /* External password changing command */ 10915 if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) { 10916 ast_copy_string(ext_pass_cmd,val,sizeof(ext_pass_cmd)); 10917 pwdchange = PWDCHANGE_EXTERNAL; 10918 } else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) { 10919 ast_copy_string(ext_pass_cmd,val,sizeof(ext_pass_cmd)); 10920 pwdchange = PWDCHANGE_EXTERNAL | PWDCHANGE_INTERNAL; 10921 } 10922 10923 /* External password validation command */ 10924 if ((val = ast_variable_retrieve(cfg, "general", "externpasscheck"))) { 10925 ast_copy_string(ext_pass_check_cmd, val, sizeof(ext_pass_check_cmd)); 10926 ast_log(AST_LOG_DEBUG, "found externpasscheck: %s\n", ext_pass_check_cmd); 10927 } 10928 10929 #ifdef IMAP_STORAGE 10930 /* IMAP server address */ 10931 if ((val = ast_variable_retrieve(cfg, "general", "imapserver"))) { 10932 ast_copy_string(imapserver, val, sizeof(imapserver)); 10933 } else { 10934 ast_copy_string(imapserver,"localhost", sizeof(imapserver)); 10935 } 10936 /* IMAP server port */ 10937 if ((val = ast_variable_retrieve(cfg, "general", "imapport"))) { 10938 ast_copy_string(imapport, val, sizeof(imapport)); 10939 } else { 10940 ast_copy_string(imapport,"143", sizeof(imapport)); 10941 } 10942 /* IMAP server flags */ 10943 if ((val = ast_variable_retrieve(cfg, "general", "imapflags"))) { 10944 ast_copy_string(imapflags, val, sizeof(imapflags)); 10945 } 10946 /* IMAP server master username */ 10947 if ((val = ast_variable_retrieve(cfg, "general", "authuser"))) { 10948 ast_copy_string(authuser, val, sizeof(authuser)); 10949 } 10950 /* IMAP server master password */ 10951 if ((val = ast_variable_retrieve(cfg, "general", "authpassword"))) { 10952 ast_copy_string(authpassword, val, sizeof(authpassword)); 10953 } 10954 /* Expunge on exit */ 10955 if ((val = ast_variable_retrieve(cfg, "general", "expungeonhangup"))) { 10956 if (ast_false(val)) 10957 expungeonhangup = 0; 10958 else 10959 expungeonhangup = 1; 10960 } else { 10961 expungeonhangup = 1; 10962 } 10963 /* IMAP voicemail folder */ 10964 if ((val = ast_variable_retrieve(cfg, "general", "imapfolder"))) { 10965 ast_copy_string(imapfolder, val, sizeof(imapfolder)); 10966 } else { 10967 ast_copy_string(imapfolder,"INBOX", sizeof(imapfolder)); 10968 } 10969 if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) { 10970 ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder)); 10971 } 10972 if ((val = ast_variable_retrieve(cfg, "general", "imapgreetings"))) { 10973 imapgreetings = ast_true(val); 10974 } else { 10975 imapgreetings = 0; 10976 } 10977 if ((val = ast_variable_retrieve(cfg, "general", "greetingfolder"))) { 10978 ast_copy_string(greetingfolder, val, sizeof(greetingfolder)); 10979 } else { 10980 ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder)); 10981 } 10982 10983 /* There is some very unorthodox casting done here. This is due 10984 * to the way c-client handles the argument passed in. It expects a 10985 * void pointer and casts the pointer directly to a long without 10986 * first dereferencing it. */ 10987 if ((val = ast_variable_retrieve(cfg, "general", "imapreadtimeout"))) { 10988 mail_parameters(NIL, SET_READTIMEOUT, (void *) (atol(val))); 10989 } else { 10990 mail_parameters(NIL, SET_READTIMEOUT, (void *) 60L); 10991 } 10992 10993 if ((val = ast_variable_retrieve(cfg, "general", "imapwritetimeout"))) { 10994 mail_parameters(NIL, SET_WRITETIMEOUT, (void *) (atol(val))); 10995 } else { 10996 mail_parameters(NIL, SET_WRITETIMEOUT, (void *) 60L); 10997 } 10998 10999 if ((val = ast_variable_retrieve(cfg, "general", "imapopentimeout"))) { 11000 mail_parameters(NIL, SET_OPENTIMEOUT, (void *) (atol(val))); 11001 } else { 11002 mail_parameters(NIL, SET_OPENTIMEOUT, (void *) 60L); 11003 } 11004 11005 if ((val = ast_variable_retrieve(cfg, "general", "imapclosetimeout"))) { 11006 mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) (atol(val))); 11007 } else { 11008 mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L); 11009 } 11010 11011 /* Increment configuration version */ 11012 imapversion++; 11013 #endif 11014 /* External voicemail notify application */ 11015 if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) { 11016 ast_copy_string(externnotify, val, sizeof(externnotify)); 11017 ast_debug(1, "found externnotify: %s\n", externnotify); 11018 } else { 11019 externnotify[0] = '\0'; 11020 } 11021 11022 /* SMDI voicemail notification */ 11023 if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) { 11024 ast_debug(1, "Enabled SMDI voicemail notification\n"); 11025 if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) { 11026 smdi_iface = ast_smdi_interface_find ? ast_smdi_interface_find(val) : NULL; 11027 } else { 11028 ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n"); 11029 smdi_iface = ast_smdi_interface_find ? ast_smdi_interface_find("/dev/ttyS0") : NULL; 11030 } 11031 if (!smdi_iface) { 11032 ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n"); 11033 } 11034 } 11035 11036 /* Silence treshold */ 11037 silencethreshold = ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE); 11038 if ((val = ast_variable_retrieve(cfg, "general", "silencethreshold"))) 11039 silencethreshold = atoi(val); 11040 11041 if (!(val = ast_variable_retrieve(cfg, "general", "serveremail"))) 11042 val = ASTERISK_USERNAME; 11043 ast_copy_string(serveremail, val, sizeof(serveremail)); 11044 11045 vmmaxsecs = 0; 11046 if ((val = ast_variable_retrieve(cfg, "general", "maxsecs"))) { 11047 if (sscanf(val, "%30d", &x) == 1) { 11048 vmmaxsecs = x; 11049 } else { 11050 ast_log(AST_LOG_WARNING, "Invalid max message time length\n"); 11051 } 11052 } else if ((val = ast_variable_retrieve(cfg, "general", "maxmessage"))) { 11053 static int maxmessage_deprecate = 0; 11054 if (maxmessage_deprecate == 0) { 11055 maxmessage_deprecate = 1; 11056 ast_log(AST_LOG_WARNING, "Setting 'maxmessage' has been deprecated in favor of 'maxsecs'.\n"); 11057 } 11058 if (sscanf(val, "%30d", &x) == 1) { 11059 vmmaxsecs = x; 11060 } else { 11061 ast_log(AST_LOG_WARNING, "Invalid max message time length\n"); 11062 } 11063 } 11064 11065 vmminsecs = 0; 11066 if ((val = ast_variable_retrieve(cfg, "general", "minsecs"))) { 11067 if (sscanf(val, "%30d", &x) == 1) { 11068 vmminsecs = x; 11069 if (maxsilence / 1000 >= vmminsecs) { 11070 ast_log(AST_LOG_WARNING, "maxsilence should be less than minsecs or you may get empty messages\n"); 11071 } 11072 } else { 11073 ast_log(AST_LOG_WARNING, "Invalid min message time length\n"); 11074 } 11075 } else if ((val = ast_variable_retrieve(cfg, "general", "minmessage"))) { 11076 static int maxmessage_deprecate = 0; 11077 if (maxmessage_deprecate == 0) { 11078 maxmessage_deprecate = 1; 11079 ast_log(AST_LOG_WARNING, "Setting 'minmessage' has been deprecated in favor of 'minsecs'.\n"); 11080 } 11081 if (sscanf(val, "%30d", &x) == 1) { 11082 vmminsecs = x; 11083 if (maxsilence / 1000 >= vmminsecs) { 11084 ast_log(AST_LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n"); 11085 } 11086 } else { 11087 ast_log(AST_LOG_WARNING, "Invalid min message time length\n"); 11088 } 11089 } 11090 11091 val = ast_variable_retrieve(cfg, "general", "format"); 11092 if (!val) { 11093 val = "wav"; 11094 } else { 11095 tmp = ast_strdupa(val); 11096 val = ast_format_str_reduce(tmp); 11097 if (!val) { 11098 ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n"); 11099 val = "wav"; 11100 } 11101 } 11102 ast_copy_string(vmfmts, val, sizeof(vmfmts)); 11103 11104 skipms = 3000; 11105 if ((val = ast_variable_retrieve(cfg, "general", "maxgreet"))) { 11106 if (sscanf(val, "%30d", &x) == 1) { 11107 maxgreet = x; 11108 } else { 11109 ast_log(AST_LOG_WARNING, "Invalid max message greeting length\n"); 11110 } 11111 } 11112 11113 if ((val = ast_variable_retrieve(cfg, "general", "skipms"))) { 11114 if (sscanf(val, "%30d", &x) == 1) { 11115 skipms = x; 11116 } else { 11117 ast_log(AST_LOG_WARNING, "Invalid skipms value\n"); 11118 } 11119 } 11120 11121 maxlogins = 3; 11122 if ((val = ast_variable_retrieve(cfg, "general", "maxlogins"))) { 11123 if (sscanf(val, "%30d", &x) == 1) { 11124 maxlogins = x; 11125 } else { 11126 ast_log(AST_LOG_WARNING, "Invalid max failed login attempts\n"); 11127 } 11128 } 11129 11130 minpassword = MINPASSWORD; 11131 if ((val = ast_variable_retrieve(cfg, "general", "minpassword"))) { 11132 if (sscanf(val, "%30d", &x) == 1) { 11133 minpassword = x; 11134 } else { 11135 ast_log(AST_LOG_WARNING, "Invalid minimum password length. Default to %d\n", minpassword); 11136 } 11137 } 11138 11139 /* Force new user to record name ? */ 11140 if (!(val = ast_variable_retrieve(cfg, "general", "forcename"))) 11141 val = "no"; 11142 ast_set2_flag((&globalflags), ast_true(val), VM_FORCENAME); 11143 11144 /* Force new user to record greetings ? */ 11145 if (!(val = ast_variable_retrieve(cfg, "general", "forcegreetings"))) 11146 val = "no"; 11147 ast_set2_flag((&globalflags), ast_true(val), VM_FORCEGREET); 11148 11149 if ((val = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) { 11150 ast_debug(1, "VM_CID Internal context string: %s\n", val); 11151 stringp = ast_strdupa(val); 11152 for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){ 11153 if (!ast_strlen_zero(stringp)) { 11154 q = strsep(&stringp, ","); 11155 while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */ 11156 q++; 11157 ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x])); 11158 ast_debug(1,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]); 11159 } else { 11160 cidinternalcontexts[x][0] = '\0'; 11161 } 11162 } 11163 } 11164 if (!(val = ast_variable_retrieve(cfg, "general", "review"))){ 11165 ast_debug(1,"VM Review Option disabled globally\n"); 11166 val = "no"; 11167 } 11168 ast_set2_flag((&globalflags), ast_true(val), VM_REVIEW); 11169 11170 /* Temporary greeting reminder */ 11171 if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) { 11172 ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n"); 11173 val = "no"; 11174 } else { 11175 ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n"); 11176 } 11177 ast_set2_flag((&globalflags), ast_true(val), VM_TEMPGREETWARN); 11178 if (!(val = ast_variable_retrieve(cfg, "general", "messagewrap"))){ 11179 ast_debug(1, "VM next message wrap disabled globally\n"); 11180 val = "no"; 11181 } 11182 ast_set2_flag((&globalflags), ast_true(val), VM_MESSAGEWRAP); 11183 11184 if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){ 11185 ast_debug(1,"VM Operator break disabled globally\n"); 11186 val = "no"; 11187 } 11188 ast_set2_flag((&globalflags), ast_true(val), VM_OPERATOR); 11189 11190 if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) { 11191 ast_debug(1,"VM CID Info before msg disabled globally\n"); 11192 val = "no"; 11193 } 11194 ast_set2_flag((&globalflags), ast_true(val), VM_SAYCID); 11195 11196 if (!(val = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){ 11197 ast_debug(1,"Send Voicemail msg disabled globally\n"); 11198 val = "no"; 11199 } 11200 ast_set2_flag((&globalflags), ast_true(val), VM_SVMAIL); 11201 11202 if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) { 11203 ast_debug(1,"ENVELOPE before msg enabled globally\n"); 11204 val = "yes"; 11205 } 11206 ast_set2_flag((&globalflags), ast_true(val), VM_ENVELOPE); 11207 11208 if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) { 11209 ast_debug(1,"Move Heard enabled globally\n"); 11210 val = "yes"; 11211 } 11212 ast_set2_flag((&globalflags), ast_true(val), VM_MOVEHEARD); 11213 11214 if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) { 11215 ast_debug(1,"Autoset of Urgent flag on forwarded Urgent messages disabled globally\n"); 11216 val = "no"; 11217 } 11218 ast_set2_flag((&globalflags), ast_true(val), VM_FWDURGAUTO); 11219 11220 if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) { 11221 ast_debug(1,"Duration info before msg enabled globally\n"); 11222 val = "yes"; 11223 } 11224 ast_set2_flag((&globalflags), ast_true(val), VM_SAYDURATION); 11225 11226 saydurationminfo = 2; 11227 if ((val = ast_variable_retrieve(cfg, "general", "saydurationm"))) { 11228 if (sscanf(val, "%30d", &x) == 1) { 11229 saydurationminfo = x; 11230 } else { 11231 ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n"); 11232 } 11233 } 11234 11235 if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) { 11236 ast_debug(1,"We are not going to skip to the next msg after save/delete\n"); 11237 val = "no"; 11238 } 11239 ast_set2_flag((&globalflags), ast_true(val), VM_SKIPAFTERCMD); 11240 11241 if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) { 11242 ast_copy_string(dialcontext, val, sizeof(dialcontext)); 11243 ast_debug(1, "found dialout context: %s\n", dialcontext); 11244 } else { 11245 dialcontext[0] = '\0'; 11246 } 11247 11248 if ((val = ast_variable_retrieve(cfg, "general", "callback"))) { 11249 ast_copy_string(callcontext, val, sizeof(callcontext)); 11250 ast_debug(1, "found callback context: %s\n", callcontext); 11251 } else { 11252 callcontext[0] = '\0'; 11253 } 11254 11255 if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) { 11256 ast_copy_string(exitcontext, val, sizeof(exitcontext)); 11257 ast_debug(1, "found operator context: %s\n", exitcontext); 11258 } else { 11259 exitcontext[0] = '\0'; 11260 } 11261 11262 /* load password sounds configuration */ 11263 if ((val = ast_variable_retrieve(cfg, "general", "vm-password"))) 11264 ast_copy_string(vm_password, val, sizeof(vm_password)); 11265 if ((val = ast_variable_retrieve(cfg, "general", "vm-newpassword"))) 11266 ast_copy_string(vm_newpassword, val, sizeof(vm_newpassword)); 11267 if ((val = ast_variable_retrieve(cfg, "general", "vm-invalid-password"))) 11268 ast_copy_string(vm_invalid_password, val, sizeof(vm_invalid_password)); 11269 if ((val = ast_variable_retrieve(cfg, "general", "vm-passchanged"))) 11270 ast_copy_string(vm_passchanged, val, sizeof(vm_passchanged)); 11271 if ((val = ast_variable_retrieve(cfg, "general", "vm-reenterpassword"))) 11272 ast_copy_string(vm_reenterpassword, val, sizeof(vm_reenterpassword)); 11273 if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch"))) 11274 ast_copy_string(vm_mismatch, val, sizeof(vm_mismatch)); 11275 if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) { 11276 ast_copy_string(vm_pls_try_again, val, sizeof(vm_pls_try_again)); 11277 } 11278 /* load configurable audio prompts */ 11279 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val)) 11280 ast_copy_string(listen_control_forward_key, val, sizeof(listen_control_forward_key)); 11281 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val)) 11282 ast_copy_string(listen_control_reverse_key, val, sizeof(listen_control_reverse_key)); 11283 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val)) 11284 ast_copy_string(listen_control_pause_key, val, sizeof(listen_control_pause_key)); 11285 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val)) 11286 ast_copy_string(listen_control_restart_key, val, sizeof(listen_control_restart_key)); 11287 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val)) 11288 ast_copy_string(listen_control_stop_key, val, sizeof(listen_control_stop_key)); 11289 11290 if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory"))) 11291 val = "no"; 11292 ast_set2_flag((&globalflags), ast_true(val), VM_DIRECFORWARD); 11293 11294 poll_freq = DEFAULT_POLL_FREQ; 11295 if ((val = ast_variable_retrieve(cfg, "general", "pollfreq"))) { 11296 if (sscanf(val, "%30u", &poll_freq) != 1) { 11297 poll_freq = DEFAULT_POLL_FREQ; 11298 ast_log(AST_LOG_ERROR, "'%s' is not a valid value for the pollfreq option!\n", val); 11299 } 11300 } 11301 11302 poll_mailboxes = 0; 11303 if ((val = ast_variable_retrieve(cfg, "general", "pollmailboxes"))) 11304 poll_mailboxes = ast_true(val); 11305 11306 if (ucfg) { 11307 for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) { 11308 if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail"))) 11309 continue; 11310 if ((current = find_or_create(userscontext, cat))) { 11311 populate_defaults(current); 11312 apply_options_full(current, ast_variable_browse(ucfg, cat)); 11313 ast_copy_string(current->context, userscontext, sizeof(current->context)); 11314 } 11315 } 11316 ast_config_destroy(ucfg); 11317 } 11318 cat = ast_category_browse(cfg, NULL); 11319 while (cat) { 11320 if (strcasecmp(cat, "general")) { 11321 var = ast_variable_browse(cfg, cat); 11322 if (strcasecmp(cat, "zonemessages")) { 11323 /* Process mailboxes in this context */ 11324 while (var) { 11325 append_mailbox(cat, var->name, var->value); 11326 var = var->next; 11327 } 11328 } else { 11329 /* Timezones in this context */ 11330 while (var) { 11331 struct vm_zone *z; 11332 if ((z = ast_malloc(sizeof(*z)))) { 11333 char *msg_format, *tzone; 11334 msg_format = ast_strdupa(var->value); 11335 tzone = strsep(&msg_format, "|,"); 11336 if (msg_format) { 11337 ast_copy_string(z->name, var->name, sizeof(z->name)); 11338 ast_copy_string(z->timezone, tzone, sizeof(z->timezone)); 11339 ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format)); 11340 AST_LIST_LOCK(&zones); 11341 AST_LIST_INSERT_HEAD(&zones, z, list); 11342 AST_LIST_UNLOCK(&zones); 11343 } else { 11344 ast_log(AST_LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno); 11345 ast_free(z); 11346 } 11347 } else { 11348 AST_LIST_UNLOCK(&users); 11349 ast_config_destroy(cfg); 11350 return -1; 11351 } 11352 var = var->next; 11353 } 11354 } 11355 } 11356 cat = ast_category_browse(cfg, cat); 11357 } 11358 memset(fromstring, 0, sizeof(fromstring)); 11359 memset(pagerfromstring, 0, sizeof(pagerfromstring)); 11360 strcpy(charset, "ISO-8859-1"); 11361 if (emailbody) { 11362 ast_free(emailbody); 11363 emailbody = NULL; 11364 } 11365 if (emailsubject) { 11366 ast_free(emailsubject); 11367 emailsubject = NULL; 11368 } 11369 if (pagerbody) { 11370 ast_free(pagerbody); 11371 pagerbody = NULL; 11372 } 11373 if (pagersubject) { 11374 ast_free(pagersubject); 11375 pagersubject = NULL; 11376 } 11377 if ((val = ast_variable_retrieve(cfg, "general", "pbxskip"))) 11378 ast_set2_flag((&globalflags), ast_true(val), VM_PBXSKIP); 11379 if ((val = ast_variable_retrieve(cfg, "general", "fromstring"))) 11380 ast_copy_string(fromstring, val, sizeof(fromstring)); 11381 if ((val = ast_variable_retrieve(cfg, "general", "pagerfromstring"))) 11382 ast_copy_string(pagerfromstring, val, sizeof(pagerfromstring)); 11383 if ((val = ast_variable_retrieve(cfg, "general", "charset"))) 11384 ast_copy_string(charset, val, sizeof(charset)); 11385 if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) { 11386 sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]); 11387 for (x = 0; x < 4; x++) { 11388 memcpy(&adsifdn[x], &tmpadsi[x], 1); 11389 } 11390 } 11391 if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) { 11392 sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]); 11393 for (x = 0; x < 4; x++) { 11394 memcpy(&adsisec[x], &tmpadsi[x], 1); 11395 } 11396 } 11397 if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) { 11398 if (atoi(val)) { 11399 adsiver = atoi(val); 11400 } 11401 } 11402 if ((val = ast_variable_retrieve(cfg, "general", "tz"))) { 11403 ast_copy_string(zonetag, val, sizeof(zonetag)); 11404 } 11405 if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) { 11406 emailsubject = ast_strdup(val); 11407 } 11408 if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) { 11409 emailbody = ast_strdup(substitute_escapes(val)); 11410 } 11411 if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) { 11412 pagersubject = ast_strdup(val); 11413 } 11414 if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) { 11415 pagerbody = ast_strdup(substitute_escapes(val)); 11416 } 11417 AST_LIST_UNLOCK(&users); 11418 ast_config_destroy(cfg); 11419 11420 if (poll_mailboxes && poll_thread == AST_PTHREADT_NULL) 11421 start_poll_thread(); 11422 if (!poll_mailboxes && poll_thread != AST_PTHREADT_NULL) 11423 stop_poll_thread();; 11424 11425 return 0; 11426 } else { 11427 AST_LIST_UNLOCK(&users); 11428 ast_log(AST_LOG_WARNING, "Failed to load configuration file.\n"); 11429 if (ucfg) 11430 ast_config_destroy(ucfg); 11431 return 0; 11432 } 11433 }
| static int load_module | ( | void | ) | [static] |
Definition at line 11480 of file app_voicemail.c.
References ao2_container_alloc, ARRAY_LEN, ast_cli_register_multiple(), ast_config_AST_SPOOL_DIR, ast_custom_function_register, ast_install_vm_functions(), ast_log(), AST_LOG_WARNING, ast_manager_register, AST_MODULE_LOAD_DECLINE, ast_realtime_require_field(), ast_register_application_xml, ast_taskprocessor_get(), cli_voicemail, EVENT_FLAG_CALL, EVENT_FLAG_REPORTING, has_voicemail(), inboxcount(), inboxcount2(), inprocess_cmp_fn(), inprocess_container, inprocess_hash_fn(), load_config(), mailbox_exists_acf, manager_list_voicemail_users(), messagecount(), mwi_subscription_tps, RQ_CHAR, RQ_UINTEGER3, sayname(), SENTINEL, vm_box_exists(), vm_exec(), vm_execmain(), and vmauthenticate().
11481 { 11482 int res; 11483 my_umask = umask(0); 11484 umask(my_umask); 11485 11486 if (!(inprocess_container = ao2_container_alloc(573, inprocess_hash_fn, inprocess_cmp_fn))) { 11487 return AST_MODULE_LOAD_DECLINE; 11488 } 11489 11490 /* compute the location of the voicemail spool directory */ 11491 snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR); 11492 11493 if (!(mwi_subscription_tps = ast_taskprocessor_get("app_voicemail", 0))) { 11494 ast_log(AST_LOG_WARNING, "failed to reference mwi subscription taskprocessor. MWI will not work\n"); 11495 } 11496 11497 if ((res = load_config(0))) 11498 return res; 11499 11500 res = ast_register_application_xml(app, vm_exec); 11501 res |= ast_register_application_xml(app2, vm_execmain); 11502 res |= ast_register_application_xml(app3, vm_box_exists); 11503 res |= ast_register_application_xml(app4, vmauthenticate); 11504 res |= ast_custom_function_register(&mailbox_exists_acf); 11505 res |= ast_manager_register("VoicemailUsersList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_list_voicemail_users, "List All Voicemail User Information"); 11506 if (res) 11507 return res; 11508 11509 ast_cli_register_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail)); 11510 11511 ast_install_vm_functions(has_voicemail, inboxcount, inboxcount2, messagecount, sayname); 11512 ast_realtime_require_field("voicemail", "uniqueid", RQ_UINTEGER3, 11, "password", RQ_CHAR, 10, SENTINEL); 11513 ast_realtime_require_field("voicemail_data", "filename", RQ_CHAR, 30, "duration", RQ_UINTEGER3, 5, SENTINEL); 11514 11515 return res; 11516 }
| static int make_dir | ( | char * | dest, | |
| int | len, | |||
| const char * | context, | |||
| const char * | ext, | |||
| const char * | folder | |||
| ) | [static] |
Creates a file system path expression for a folder within the voicemail data folder and the appropriate context.
| dest | The variable to hold the output generated path expression. This buffer should be of size PATH_MAX. | |
| len | The length of the path string that was written out. |
Definition at line 1458 of file app_voicemail.c.
Referenced by copy_message(), create_dirpath(), make_email_file(), manager_list_voicemail_users(), notify_new_message(), and prep_email_sub_vars().
01459 { 01460 return snprintf(dest, len, "%s%s/%s/%s", VM_SPOOL_DIR, context, ext, folder); 01461 }
| static void make_email_file | ( | FILE * | p, | |
| char * | srcemail, | |||
| struct ast_vm_user * | vmu, | |||
| int | msgnum, | |||
| char * | context, | |||
| char * | mailbox, | |||
| const char * | fromfolder, | |||
| char * | cidnum, | |||
| char * | cidname, | |||
| char * | attach, | |||
| char * | attach2, | |||
| char * | format, | |||
| int | duration, | |||
| int | attach_user_voicemail, | |||
| struct ast_channel * | chan, | |||
| const char * | category, | |||
| int | imap, | |||
| const char * | flag | |||
| ) | [static] |
Creates the email file to be sent to indicate a new voicemail exists for a user.
| p | The output file to generate the email contents into. | |
| srcemail | The email address to send the email to, presumably the email address for the owner of the mailbox. | |
| vmu | The voicemail user who is sending the voicemail. | |
| msgnum | The message index in the mailbox folder. | |
| context | ||
| mailbox | The voicemail box to read the voicemail to be notified in this email. | |
| cidnum | The caller ID number. | |
| cidname | The caller ID name. | |
| attach | the name of the sound file to be attached to the email, if attach_user_voicemail == 1. | |
| format | The message sound file format. i.e. .wav | |
| duration | The time of the message content, in seconds. | |
| attach_user_voicemail | if 1, the sound file is attached to the email. | |
| chan | ||
| category | ||
| imap | if == 1, indicates the target folder for the email notification to be sent to will be an IMAP mailstore. This causes additional mailbox headers to be set, which would facilitate searching for the email in the destination IMAP folder. |
Definition at line 4243 of file app_voicemail.c.
References add_email_attachment(), ast_channel_alloc, ast_channel_free(), ast_config_destroy(), ast_config_load, ast_copy_string(), ast_debug, ast_localtime(), ast_log(), AST_LOG_WARNING, ast_random(), AST_STATE_DOWN, ast_strdupa, ast_strftime(), ast_strlen_zero(), ast_test_flag, ast_variable_retrieve(), charset, check_mime(), CONFIG_FLAG_NOCACHE, ast_vm_user::context, ast_vm_user::email, ast_vm_user::emailbody, emailbody, emaildateformat, ast_vm_user::emailsubject, emailsubject, encode_mime_str(), ENDL, fromstring, ast_vm_user::fullname, globalflags, ast_vm_user::mailbox, make_dir(), make_file(), MAXHOSTNAMELEN, ast_channel::name, ast_channel::next, pbx_substitute_variables_helper(), prep_email_sub_vars(), ast_channel::priority, quote(), strip_control_and_high(), VM_PBXSKIP, and vmu_tm().
Referenced by sendmail().
04244 { 04245 char date[256]; 04246 char host[MAXHOSTNAMELEN] = ""; 04247 char who[256]; 04248 char bound[256]; 04249 char dur[256]; 04250 struct ast_tm tm; 04251 char enc_cidnum[256] = "", enc_cidname[256] = ""; 04252 char *passdata = NULL, *passdata2; 04253 size_t len_passdata = 0, len_passdata2, tmplen; 04254 char *greeting_attachment; 04255 char filename[256]; 04256 04257 04258 /* One alloca for multiple fields */ 04259 len_passdata2 = strlen(vmu->fullname); 04260 if (emailsubject && (tmplen = strlen(emailsubject)) > len_passdata2) { 04261 len_passdata2 = tmplen; 04262 } 04263 if ((tmplen = strlen(fromstring)) > len_passdata2) { 04264 len_passdata2 = tmplen; 04265 } 04266 len_passdata2 = len_passdata2 * 3 + 200; 04267 passdata2 = alloca(len_passdata2); 04268 04269 if (cidnum) { 04270 strip_control_and_high(cidnum, enc_cidnum, sizeof(enc_cidnum)); 04271 } 04272 if (cidname) { 04273 strip_control_and_high(cidname, enc_cidname, sizeof(enc_cidname)); 04274 } 04275 gethostname(host, sizeof(host) - 1); 04276 04277 if (strchr(srcemail, '@')) 04278 ast_copy_string(who, srcemail, sizeof(who)); 04279 else 04280 snprintf(who, sizeof(who), "%s@%s", srcemail, host); 04281 04282 greeting_attachment = strrchr(ast_strdupa(attach), '/'); 04283 if (greeting_attachment) 04284 *greeting_attachment++ = '\0'; 04285 04286 snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60); 04287 ast_strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm)); 04288 fprintf(p, "Date: %s" ENDL, date); 04289 04290 /* Set date format for voicemail mail */ 04291 ast_strftime(date, sizeof(date), emaildateformat, &tm); 04292 04293 if (!ast_strlen_zero(fromstring)) { 04294 struct ast_channel *ast; 04295 if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { 04296 char *ptr; 04297 memset(passdata2, 0, len_passdata2); 04298 prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, enc_cidnum, enc_cidname, dur, date, passdata2, len_passdata2, category, flag); 04299 pbx_substitute_variables_helper(ast, fromstring, passdata2, len_passdata2); 04300 len_passdata = strlen(passdata2) * 3 + 300; 04301 passdata = alloca(len_passdata); 04302 if (check_mime(passdata2)) { 04303 int first_line = 1; 04304 encode_mime_str(passdata2, passdata, len_passdata, strlen("From: "), strlen(who) + 3); 04305 while ((ptr = strchr(passdata, ' '))) { 04306 *ptr = '\0'; 04307 fprintf(p, "%s %s" ENDL, first_line ? "From:" : "", passdata); 04308 first_line = 0; 04309 passdata = ptr + 1; 04310 } 04311 fprintf(p, "%s %s <%s>" ENDL, first_line ? "From:" : "", passdata, who); 04312 } else { 04313 fprintf(p, "From: %s <%s>" ENDL, quote(passdata2, passdata, len_passdata), who); 04314 } 04315 ast_channel_free(ast); 04316 } else { 04317 ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); 04318 } 04319 } else { 04320 fprintf(p, "From: Asterisk PBX <%s>" ENDL, who); 04321 } 04322 04323 if (check_mime(vmu->fullname)) { 04324 int first_line = 1; 04325 char *ptr; 04326 encode_mime_str(vmu->fullname, passdata2, len_passdata2, strlen("To: "), strlen(vmu->email) + 3); 04327 while ((ptr = strchr(passdata2, ' '))) { 04328 *ptr = '\0'; 04329 fprintf(p, "%s %s" ENDL, first_line ? "To:" : "", passdata2); 04330 first_line = 0; 04331 passdata2 = ptr + 1; 04332 } 04333 fprintf(p, "%s %s <%s>" ENDL, first_line ? "To:" : "", passdata2, vmu->email); 04334 } else { 04335 fprintf(p, "To: %s <%s>" ENDL, quote(vmu->fullname, passdata2, len_passdata2), vmu->email); 04336 } 04337 if (!ast_strlen_zero(emailsubject) || !ast_strlen_zero(vmu->emailsubject)) { 04338 char *e_subj = !ast_strlen_zero(vmu->emailsubject) ? vmu->emailsubject : emailsubject; 04339 struct ast_channel *ast; 04340 if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { 04341 int vmlen = strlen(e_subj) * 3 + 200; 04342 /* Only allocate more space if the previous was not large enough */ 04343 if (vmlen > len_passdata) { 04344 passdata = alloca(vmlen); 04345 len_passdata = vmlen; 04346 } 04347 04348 memset(passdata, 0, len_passdata); 04349 prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, passdata, len_passdata, category, flag); 04350 pbx_substitute_variables_helper(ast, e_subj, passdata, len_passdata); 04351 if (check_mime(passdata)) { 04352 int first_line = 1; 04353 char *ptr; 04354 encode_mime_str(passdata, passdata2, len_passdata2, strlen("Subject: "), 0); 04355 while ((ptr = strchr(passdata2, ' '))) { 04356 *ptr = '\0'; 04357 fprintf(p, "%s %s" ENDL, first_line ? "Subject:" : "", passdata2); 04358 first_line = 0; 04359 passdata2 = ptr + 1; 04360 } 04361 fprintf(p, "%s %s" ENDL, first_line ? "Subject:" : "", passdata2); 04362 } else { 04363 fprintf(p, "Subject: %s" ENDL, passdata); 04364 } 04365 ast_channel_free(ast); 04366 } else { 04367 ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); 04368 } 04369 } else if (ast_test_flag((&globalflags), VM_PBXSKIP)) { 04370 if (ast_strlen_zero(flag)) { 04371 fprintf(p, "Subject: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox); 04372 } else { 04373 fprintf(p, "Subject: New %s message %d in mailbox %s" ENDL, flag, msgnum + 1, mailbox); 04374 } 04375 } else { 04376 if (ast_strlen_zero(flag)) { 04377 fprintf(p, "Subject: [PBX]: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox); 04378 } else { 04379 fprintf(p, "Subject: [PBX]: New %s message %d in mailbox %s" ENDL, flag, msgnum + 1, mailbox); 04380 } 04381 } 04382 04383 fprintf(p, "Message-ID: <Asterisk-%d-%d-%s-%d@%s>" ENDL, msgnum + 1, (unsigned int)ast_random(), mailbox, (int)getpid(), host); 04384 if (imap) { 04385 /* additional information needed for IMAP searching */ 04386 fprintf(p, "X-Asterisk-VM-Message-Num: %d" ENDL, msgnum + 1); 04387 /* fprintf(p, "X-Asterisk-VM-Orig-Mailbox: %s" ENDL, ext); */ 04388 fprintf(p, "X-Asterisk-VM-Server-Name: %s" ENDL, fromstring); 04389 fprintf(p, "X-Asterisk-VM-Context: %s" ENDL, context); 04390 #ifdef IMAP_STORAGE 04391 fprintf(p, "X-Asterisk-VM-Extension: %s" ENDL, (!ast_strlen_zero(vmu->imapvmshareid) ? vmu->imapvmshareid : mailbox)); 04392 #else 04393 fprintf(p, "X-Asterisk-VM-Extension: %s" ENDL, mailbox); 04394 #endif 04395 /* flag added for Urgent */ 04396 fprintf(p, "X-Asterisk-VM-Flag: %s" ENDL, flag); 04397 fprintf(p, "X-Asterisk-VM-Priority: %d" ENDL, chan->priority); 04398 fprintf(p, "X-Asterisk-VM-Caller-channel: %s" ENDL, chan->name); 04399 fprintf(p, "X-Asterisk-VM-Caller-ID-Num: %s" ENDL, enc_cidnum); 04400 fprintf(p, "X-Asterisk-VM-Caller-ID-Name: %s" ENDL, enc_cidname); 04401 fprintf(p, "X-Asterisk-VM-Duration: %d" ENDL, duration); 04402 if (!ast_strlen_zero(category)) { 04403 fprintf(p, "X-Asterisk-VM-Category: %s" ENDL, category); 04404 } else { 04405 fprintf(p, "X-Asterisk-VM-Category: " ENDL); 04406 } 04407 fprintf(p, "X-Asterisk-VM-Message-Type: %s" ENDL, msgnum > -1 ? "Message" : greeting_attachment); 04408 fprintf(p, "X-Asterisk-VM-Orig-date: %s" ENDL, date); 04409 fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long)time(NULL)); 04410 } 04411 if (!ast_strlen_zero(cidnum)) { 04412 fprintf(p, "X-Asterisk-CallerID: %s" ENDL, enc_cidnum); 04413 } 04414 if (!ast_strlen_zero(cidname)) { 04415 fprintf(p, "X-Asterisk-CallerIDName: %s" ENDL, enc_cidname); 04416 } 04417 fprintf(p, "MIME-Version: 1.0" ENDL); 04418 if (attach_user_voicemail) { 04419 /* Something unique. */ 04420 snprintf(bound, sizeof(bound), "----voicemail_%d%s%d%d", msgnum + 1, mailbox, (int)getpid(), (unsigned int)ast_random()); 04421 04422 fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"" ENDL, bound); 04423 fprintf(p, ENDL ENDL "This is a multi-part message in MIME format." ENDL ENDL); 04424 fprintf(p, "--%s" ENDL, bound); 04425 } 04426 fprintf(p, "Content-Type: text/plain; charset=%s" ENDL "Content-Transfer-Encoding: 8bit" ENDL ENDL, charset); 04427 if (emailbody || vmu->emailbody) { 04428 char* e_body = vmu->emailbody ? vmu->emailbody : emailbody; 04429 struct ast_channel *ast; 04430 if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { 04431 char *passdata; 04432 int vmlen = strlen(e_body) * 3 + 200; 04433 passdata = alloca(vmlen); 04434 memset(passdata, 0, vmlen); 04435 prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, passdata, vmlen, category, flag); 04436 pbx_substitute_variables_helper(ast, e_body, passdata, vmlen); 04437 #ifdef IMAP_STORAGE 04438 { 04439 /* Convert body to native line terminators for IMAP backend */ 04440 char *line = passdata, *next; 04441 do { 04442 /* Terminate line before outputting it to the file */ 04443 if ((next = strchr(line, '\n'))) { 04444 *next++ = '\0'; 04445 } 04446 fprintf(p, "%s" ENDL, line); 04447 line = next; 04448 } while (!ast_strlen_zero(line)); 04449 } 04450 #else 04451 fprintf(p, "%s" ENDL, passdata); 04452 #endif 04453 ast_channel_free(ast); 04454 } else 04455 ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); 04456 } else if (msgnum > -1) { 04457 if (strcmp(vmu->mailbox, mailbox)) { 04458 /* Forwarded type */ 04459 struct ast_config *msg_cfg; 04460 const char *v; 04461 int inttime; 04462 char fromdir[256], fromfile[256], origdate[80] = "", origcallerid[80] = ""; 04463 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE }; 04464 /* Retrieve info from VM attribute file */ 04465 make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, fromfolder); 04466 make_file(fromfile, sizeof(fromfile), fromdir, msgnum); 04467 if (strlen(fromfile) < sizeof(fromfile) - 5) { 04468 strcat(fromfile, ".txt"); 04469 } 04470 if ((msg_cfg = ast_config_load(fromfile, config_flags))) { 04471 if ((v = ast_variable_retrieve(msg_cfg, "message", "callerid"))) { 04472 ast_copy_string(origcallerid, v, sizeof(origcallerid)); 04473 } 04474 04475 /* You might be tempted to do origdate, except that a) it's in the wrong 04476 * format, and b) it's missing for IMAP recordings. */ 04477 if ((v = ast_variable_retrieve(msg_cfg, "message", "origtime")) && sscanf(v, "%30d", &inttime) == 1) { 04478 struct timeval tv = { inttime, }; 04479 struct ast_tm tm; 04480 ast_localtime(&tv, &tm, NULL); 04481 ast_strftime(origdate, sizeof(origdate), emaildateformat, &tm); 04482 } 04483 fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just forwarded" 04484 " a %s long message (number %d)" ENDL "in mailbox %s from %s, on %s" ENDL 04485 "(originally sent by %s on %s)" ENDL "so you might want to check it when you get a" 04486 " chance. Thanks!" ENDL ENDL "\t\t\t\t--Asterisk" ENDL ENDL, vmu->fullname, dur, 04487 msgnum + 1, mailbox, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), 04488 date, origcallerid, origdate); 04489 ast_config_destroy(msg_cfg); 04490 } else { 04491 goto plain_message; 04492 } 04493 } else { 04494 plain_message: 04495 fprintf(p, "Dear %s:" ENDL ENDL "\tJust wanted to let you know you were just left a " 04496 "%s long message (number %d)" ENDL "in mailbox %s from %s, on %s so you might" ENDL 04497 "want to check it when you get a chance. Thanks!" ENDL ENDL "\t\t\t\t--Asterisk" 04498 ENDL ENDL, vmu->fullname, dur, msgnum + 1, mailbox, 04499 (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date); 04500 } 04501 } else { 04502 fprintf(p, "This message is to let you know that your greeting was changed on %s." ENDL 04503 "Please do not delete this message, lest your greeting vanish with it." ENDL ENDL, date); 04504 } 04505 04506 if (imap || attach_user_voicemail) { 04507 if (!ast_strlen_zero(attach2)) { 04508 snprintf(filename, sizeof(filename), "msg%04d.%s", msgnum, format); 04509 ast_debug(5, "creating second attachment filename %s\n", filename); 04510 add_email_attachment(p, vmu, format, attach, greeting_attachment, mailbox, bound, filename, 0, msgnum); 04511 snprintf(filename, sizeof(filename), "msgintro%04d.%s", msgnum, format); 04512 ast_debug(5, "creating attachment filename %s\n", filename); 04513 add_email_attachment(p, vmu, format, attach2, greeting_attachment, mailbox, bound, filename, 1, msgnum); 04514 } else { 04515 snprintf(filename, sizeof(filename), "msg%04d.%s", msgnum, format); 04516 ast_debug(5, "creating attachment filename %s, no second attachment.\n", filename); 04517 add_email_attachment(p, vmu, format, attach, greeting_attachment, mailbox, bound, filename, 1, msgnum); 04518 } 04519 } 04520 }
| static int make_file | ( | char * | dest, | |
| const int | len, | |||
| const char * | dir, | |||
| const int | num | |||
| ) | [static] |
Creates a file system path expression for a folder within the voicemail data folder and the appropriate context.
| dest | The variable to hold the output generated path expression. This buffer should be of size PATH_MAX. | |
| len | The length of the path string that was written out. |
Definition at line 1473 of file app_voicemail.c.
Referenced by advanced_options(), close_mailbox(), copy_message(), forward_message(), leave_voicemail(), make_email_file(), notify_new_message(), play_message(), prep_email_sub_vars(), save_to_folder(), vm_execmain(), and vm_forwardoptions().
| static int manager_list_voicemail_users | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Manager list voicemail users command.
Definition at line 10611 of file app_voicemail.c.
References AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), ast_test_flag, astman_append(), astman_get_header(), astman_send_ack(), ast_vm_user::attachfmt, ast_vm_user::callback, ast_vm_user::context, count_messages(), ast_vm_user::dialout, ast_vm_user::email, ast_vm_user::exit, ast_vm_user::fullname, inboxcount(), ast_vm_user::language, ast_vm_user::mailbox, ast_vm_user::mailcmd, make_dir(), ast_vm_user::maxmsg, ast_vm_user::maxsecs, ast_vm_user::pager, RESULT_SUCCESS, ast_vm_user::saydurationm, ast_vm_user::serveremail, ast_vm_user::uniqueid, VM_ATTACH, VM_DELETE, VM_ENVELOPE, VM_OPERATOR, VM_REVIEW, VM_SAYCID, ast_vm_user::volgain, and ast_vm_user::zonetag.
Referenced by load_module().
10612 { 10613 struct ast_vm_user *vmu = NULL; 10614 const char *id = astman_get_header(m, "ActionID"); 10615 char actionid[128] = ""; 10616 10617 if (!ast_strlen_zero(id)) 10618 snprintf(actionid, sizeof(actionid), "ActionID: %s\r\n", id); 10619 10620 AST_LIST_LOCK(&users); 10621 10622 if (AST_LIST_EMPTY(&users)) { 10623 astman_send_ack(s, m, "There are no voicemail users currently defined."); 10624 AST_LIST_UNLOCK(&users); 10625 return RESULT_SUCCESS; 10626 } 10627 10628 astman_send_ack(s, m, "Voicemail user list will follow"); 10629 10630 AST_LIST_TRAVERSE(&users, vmu, list) { 10631 char dirname[256]; 10632 10633 #ifdef IMAP_STORAGE 10634 int new, old; 10635 inboxcount(vmu->mailbox, &new, &old); 10636 #endif 10637 10638 make_dir(dirname, sizeof(dirname), vmu->context, vmu->mailbox, "INBOX"); 10639 astman_append(s, 10640 "%s" 10641 "Event: VoicemailUserEntry\r\n" 10642 "VMContext: %s\r\n" 10643 "VoiceMailbox: %s\r\n" 10644 "Fullname: %s\r\n" 10645 "Email: %s\r\n" 10646 "Pager: %s\r\n" 10647 "ServerEmail: %s\r\n" 10648 "MailCommand: %s\r\n" 10649 "Language: %s\r\n" 10650 "TimeZone: %s\r\n" 10651 "Callback: %s\r\n" 10652 "Dialout: %s\r\n" 10653 "UniqueID: %s\r\n" 10654 "ExitContext: %s\r\n" 10655 "SayDurationMinimum: %d\r\n" 10656 "SayEnvelope: %s\r\n" 10657 "SayCID: %s\r\n" 10658 "AttachMessage: %s\r\n" 10659 "AttachmentFormat: %s\r\n" 10660 "DeleteMessage: %s\r\n" 10661 "VolumeGain: %.2f\r\n" 10662 "CanReview: %s\r\n" 10663 "CallOperator: %s\r\n" 10664 "MaxMessageCount: %d\r\n" 10665 "MaxMessageLength: %d\r\n" 10666 "NewMessageCount: %d\r\n" 10667 #ifdef IMAP_STORAGE 10668 "OldMessageCount: %d\r\n" 10669 "IMAPUser: %s\r\n" 10670 #endif 10671 "\r\n", 10672 actionid, 10673 vmu->context, 10674 vmu->mailbox, 10675 vmu->fullname, 10676 vmu->email, 10677 vmu->pager, 10678 vmu->serveremail, 10679 vmu->mailcmd, 10680 vmu->language, 10681 vmu->zonetag, 10682 vmu->callback, 10683 vmu->dialout, 10684 vmu->uniqueid, 10685 vmu->exit, 10686 vmu->saydurationm, 10687 ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No", 10688 ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No", 10689 ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No", 10690 vmu->attachfmt, 10691 ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No", 10692 vmu->volgain, 10693 ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No", 10694 ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No", 10695 vmu->maxmsg, 10696 vmu->maxsecs, 10697 #ifdef IMAP_STORAGE 10698 new, old, vmu->imapuser 10699 #else 10700 count_messages(vmu, dirname) 10701 #endif 10702 ); 10703 } 10704 astman_append(s, "Event: VoicemailUserEntryComplete\r\n%s\r\n", actionid); 10705 10706 AST_LIST_UNLOCK(&users); 10707 10708 return RESULT_SUCCESS; 10709 }
| static void* mb_poll_thread | ( | void * | data | ) | [static] |
Definition at line 10445 of file app_voicemail.c.
References ast_cond_timedwait(), ast_mutex_lock(), ast_mutex_unlock(), ast_samp2tv(), ast_tvadd(), ast_tvnow(), poll_lock, and poll_subscribed_mailboxes().
Referenced by start_poll_thread().
10446 { 10447 while (poll_thread_run) { 10448 struct timespec ts = { 0, }; 10449 struct timeval wait; 10450 10451 wait = ast_tvadd(ast_tvnow(), ast_samp2tv(poll_freq, 1)); 10452 ts.tv_sec = wait.tv_sec; 10453 ts.tv_nsec = wait.tv_usec * 1000; 10454 10455 ast_mutex_lock(&poll_lock); 10456 ast_cond_timedwait(&poll_cond, &poll_lock, &ts); 10457 ast_mutex_unlock(&poll_lock); 10458 10459 if (!poll_thread_run) 10460 break; 10461 10462 poll_subscribed_mailboxes(); 10463 } 10464 10465 return NULL; 10466 }
| static const char* mbox | ( | int | id | ) | [static] |
Definition at line 1515 of file app_voicemail.c.
References ARRAY_LEN.
Referenced by acf_mailbox_exists(), add_peer_mailboxes(), adsi_load_vmail(), build_gateway(), copy_message(), get_folder(), has_voicemail(), notify_new_message(), open_mailbox(), save_to_folder(), vm_box_exists(), and vm_execmain().
01516 { 01517 static const char *msgs[] = { 01518 #ifdef IMAP_STORAGE 01519 imapfolder, 01520 #else 01521 "INBOX", 01522 #endif 01523 "Old", 01524 "Work", 01525 "Family", 01526 "Friends", 01527 "Cust1", 01528 "Cust2", 01529 "Cust3", 01530 "Cust4", 01531 "Cust5", 01532 "Deleted", 01533 "Urgent" 01534 }; 01535 return (id >= 0 && id < ARRAY_LEN(msgs)) ? msgs[id] : "Unknown"; 01536 }
| static int messagecount | ( | const char * | context, | |
| const char * | mailbox, | |||
| const char * | folder | |||
| ) | [static] |
Definition at line 5036 of file app_voicemail.c.
References __has_voicemail().
Referenced by load_module().
05037 { 05038 return __has_voicemail(context, mailbox, folder, 0) + (folder && strcmp(folder, "INBOX") ? 0 : __has_voicemail(context, mailbox, "Urgent", 0)); 05039 }
| static void mwi_sub_destroy | ( | struct mwi_sub * | mwi_sub | ) | [static] |
Definition at line 10468 of file app_voicemail.c.
References ast_free.
Referenced by handle_unsubscribe().
10469 { 10470 ast_free(mwi_sub); 10471 }
| static void mwi_sub_event_cb | ( | const struct ast_event * | event, | |
| void * | userdata | |||
| ) | [static] |
Definition at line 10546 of file app_voicemail.c.
References ast_calloc, ast_event_get_ie_str(), ast_event_get_ie_uint(), ast_event_get_type(), AST_EVENT_IE_CONTEXT, AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_UNIQUEID, AST_EVENT_MWI, AST_EVENT_SUB, ast_free, ast_log(), ast_strdup, ast_taskprocessor_push(), mwi_sub_task::context, handle_subscribe(), LOG_ERROR, mwi_sub_task::mailbox, mwi_subscription_tps, and mwi_sub_task::uniqueid.
Referenced by start_poll_thread().
10547 { 10548 struct mwi_sub_task *mwist; 10549 10550 if (ast_event_get_type(event) != AST_EVENT_SUB) 10551 return; 10552 10553 if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI) 10554 return; 10555 10556 if ((mwist = ast_calloc(1, (sizeof(*mwist)))) == NULL) { 10557 ast_log(LOG_ERROR, "could not allocate a mwi_sub_task\n"); 10558 return; 10559 } 10560 mwist->mailbox = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX)); 10561 mwist->context = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT)); 10562 mwist->uniqueid = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID); 10563 10564 if (ast_taskprocessor_push(mwi_subscription_tps, handle_subscribe, mwist) < 0) { 10565 ast_free(mwist); 10566 } 10567 }
| static void mwi_unsub_event_cb | ( | const struct ast_event * | event, | |
| void * | userdata | |||
| ) | [static] |
Definition at line 10530 of file app_voicemail.c.
References ast_calloc, ast_event_get_ie_uint(), ast_event_get_type(), AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_UNIQUEID, AST_EVENT_MWI, AST_EVENT_UNSUB, ast_free, ast_taskprocessor_push(), handle_unsubscribe(), mwi_subscription_tps, and mwi_sub_task::uniqueid.
Referenced by start_poll_thread().
10531 { 10532 uint32_t u, *uniqueid = ast_calloc(1, sizeof(*uniqueid)); 10533 if (ast_event_get_type(event) != AST_EVENT_UNSUB) 10534 return; 10535 10536 if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI) 10537 return; 10538 10539 u = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID); 10540 *uniqueid = u; 10541 if (ast_taskprocessor_push(mwi_subscription_tps, handle_unsubscribe, uniqueid) < 0) { 10542 ast_free(uniqueid); 10543 } 10544 }
| static int notify_new_message | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| struct vm_state * | vms, | |||
| int | msgnum, | |||
| long | duration, | |||
| char * | fmt, | |||
| char * | cidnum, | |||
| char * | cidname, | |||
| const char * | flag | |||
| ) | [static] |
Sends email notification that a user has a new voicemail waiting for them.
| chan | ||
| vmu | ||
| vms | ||
| msgnum | ||
| duration | ||
| fmt | ||
| cidnum | The Caller ID phone number value. | |
| cidname | The Caller ID name value. |
Definition at line 6587 of file app_voicemail.c.
References ast_app_has_voicemail(), ast_app_inboxcount2(), ast_channel_lock, ast_channel_unlock, ast_log(), AST_LOG_WARNING, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_vm_user::attachfmt, ast_vm_user::context, vm_state::curmsg, DELETE, DISPOSE, ast_vm_user::email, EVENT_FLAG_CALL, ast_vm_user::mailbox, make_dir(), make_file(), manager_event, mbox(), vm_state::newmessages, ast_vm_user::pager, pbx_builtin_getvar_helper(), queue_mwi_event(), RETRIEVE, run_externnotify(), sendmail(), sendpage(), ast_vm_user::serveremail, strsep(), VM_ATTACH, vm_delete(), and VM_DELETE.
Referenced by copy_message(), and leave_voicemail().
06588 { 06589 char todir[PATH_MAX], fn[PATH_MAX], ext_context[PATH_MAX], *stringp; 06590 int newmsgs = 0, oldmsgs = 0, urgentmsgs = 0; 06591 const char *category; 06592 char *myserveremail = serveremail; 06593 06594 ast_channel_lock(chan); 06595 if ((category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY"))) { 06596 category = ast_strdupa(category); 06597 } 06598 ast_channel_unlock(chan); 06599 06600 #ifndef IMAP_STORAGE 06601 make_dir(todir, sizeof(todir), vmu->context, vmu->mailbox, !ast_strlen_zero(flag) && !strcmp(flag, "Urgent") ? "Urgent" : "INBOX"); 06602 #else 06603 snprintf(todir, sizeof(todir), "%simap", VM_SPOOL_DIR); 06604 #endif 06605 make_file(fn, sizeof(fn), todir, msgnum); 06606 snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context); 06607 06608 if (!ast_strlen_zero(vmu->attachfmt)) { 06609 if (strstr(fmt, vmu->attachfmt)) 06610 fmt = vmu->attachfmt; 06611 else 06612 ast_log(AST_LOG_WARNING, "Attachment format '%s' is not one of the recorded formats '%s'. Falling back to default format for '%s@%s'.\n", vmu->attachfmt, fmt, vmu->mailbox, vmu->context); 06613 } 06614 06615 /* Attach only the first format */ 06616 fmt = ast_strdupa(fmt); 06617 stringp = fmt; 06618 strsep(&stringp, "|"); 06619 06620 if (!ast_strlen_zero(vmu->serveremail)) 06621 myserveremail = vmu->serveremail; 06622 06623 if (!ast_strlen_zero(vmu->email)) { 06624 int attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH); 06625 06626 if (attach_user_voicemail) 06627 RETRIEVE(todir, msgnum, vmu->mailbox, vmu->context); 06628 06629 /* XXX possible imap issue, should category be NULL XXX */ 06630 sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, mbox(0), cidnum, cidname, fn, NULL, fmt, duration, attach_user_voicemail, chan, category, flag); 06631 06632 if (attach_user_voicemail) 06633 DISPOSE(todir, msgnum); 06634 } 06635 06636 if (!ast_strlen_zero(vmu->pager)) { 06637 sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, mbox(0), cidnum, cidname, duration, vmu, category, flag); 06638 } 06639 06640 if (ast_test_flag(vmu, VM_DELETE)) 06641 DELETE(todir, msgnum, fn, vmu); 06642 06643 /* Leave voicemail for someone */ 06644 if (ast_app_has_voicemail(ext_context, NULL)) 06645 ast_app_inboxcount2(ext_context, &urgentmsgs, &newmsgs, &oldmsgs); 06646 06647 queue_mwi_event(ext_context, urgentmsgs, newmsgs, oldmsgs); 06648 06649 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); 06650 run_externnotify(vmu->context, vmu->mailbox, flag); 06651 06652 #ifdef IMAP_STORAGE 06653 vm_delete(fn); /* Delete the file, but not the IMAP message */ 06654 if (ast_test_flag(vmu, VM_DELETE)) { /* Delete the IMAP message if delete = yes */ 06655 vm_imap_delete(NULL, vms->curmsg, vmu); 06656 vms->newmessages--; /* Fix new message count */ 06657 } 06658 #endif 06659 06660 return 0; 06661 }
| static int ochar | ( | struct baseio * | bio, | |
| int | c, | |||
| FILE * | so | |||
| ) | [static] |
utility used by base_encode()
Definition at line 3969 of file app_voicemail.c.
References BASELINELEN, ENDL, and baseio::linelength.
Referenced by base_encode().
03970 { 03971 if (bio->linelength >= BASELINELEN) { 03972 if (fputs(ENDL, so) == EOF) { 03973 return -1; 03974 } 03975 03976 bio->linelength= 0; 03977 } 03978 03979 if (putc(((unsigned char) c), so) == EOF) { 03980 return -1; 03981 } 03982 03983 bio->linelength++; 03984 03985 return 1; 03986 }
| static int open_mailbox | ( | struct vm_state * | vms, | |
| struct ast_vm_user * | vmu, | |||
| int | box | |||
| ) | [static] |
Definition at line 7399 of file app_voicemail.c.
References ast_copy_string(), ast_log(), AST_LOG_ERROR, ast_unlock_path(), ast_vm_user::context, count_messages(), create_dirpath(), vm_state::curbox, vm_state::curdir, ERROR_LOCK_PATH, last_message_index(), vm_state::lastmsg, LOG_NOTICE, ast_vm_user::maxmsg, mbox(), vm_state::username, vm_allocate_dh(), vm_lock_path(), and vm_state::vmbox.
Referenced by vm_execmain().
07400 { 07401 int count_msg, last_msg; 07402 07403 ast_copy_string(vms->curbox, mbox(box), sizeof(vms->curbox)); 07404 07405 /* Rename the member vmbox HERE so that we don't try to return before 07406 * we know what's going on. 07407 */ 07408 snprintf(vms->vmbox, sizeof(vms->vmbox), "vm-%s", vms->curbox); 07409 07410 /* Faster to make the directory than to check if it exists. */ 07411 create_dirpath(vms->curdir, sizeof(vms->curdir), vmu->context, vms->username, vms->curbox); 07412 07413 /* traverses directory using readdir (or select query for ODBC) */ 07414 count_msg = count_messages(vmu, vms->curdir); 07415 if (count_msg < 0) { 07416 return count_msg; 07417 } else { 07418 vms->lastmsg = count_msg - 1; 07419 } 07420 07421 if (vm_allocate_dh(vms, vmu, count_msg)) { 07422 return -1; 07423 } 07424 07425 /* 07426 The following test is needed in case sequencing gets messed up. 07427 There appears to be more than one way to mess up sequence, so 07428 we will not try to find all of the root causes--just fix it when 07429 detected. 07430 */ 07431 07432 if (vm_lock_path(vms->curdir)) { 07433 ast_log(AST_LOG_ERROR, "Could not open mailbox %s: mailbox is locked\n", vms->curdir); 07434 return ERROR_LOCK_PATH; 07435 } 07436 07437 /* for local storage, checks directory for messages up to maxmsg limit */ 07438 last_msg = last_message_index(vmu, vms->curdir); 07439 ast_unlock_path(vms->curdir); 07440 07441 if (last_msg < -1) { 07442 return last_msg; 07443 } else if (vms->lastmsg != last_msg) { 07444 ast_log(LOG_NOTICE, "Mailbox: %s, expected %d but found %d message(s) in box with max threshold of %d.\n", vms->curdir, last_msg + 1, vms->lastmsg + 1, vmu->maxmsg); 07445 } 07446 07447 return 0; 07448 }
| static int play_message | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 7199 of file app_voicemail.c.
References adsi_message(), ast_config_destroy(), ast_config_load, AST_DIGIT_ANY, ast_fileexists(), ast_log(), AST_LOG_WARNING, ast_say_number(), ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_variable_retrieve(), CONFIG_FLAG_NOCACHE, CONFIG_STATUS_FILEINVALID, ast_vm_user::context, vm_state::curdir, vm_state::curmsg, DISPOSE, vm_state::fn, vm_state::heard, ast_channel::language, vm_state::lastmsg, LOG_WARNING, ast_vm_user::mailbox, 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_he(), vm_browse_messages_it(), vm_browse_messages_pt(), vm_browse_messages_zh(), and vm_execmain().
07200 { 07201 int res = 0; 07202 char filename[256], *cid; 07203 const char *origtime, *context, *category, *duration, *flag; 07204 struct ast_config *msg_cfg; 07205 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE }; 07206 07207 vms->starting = 0; 07208 make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg); 07209 adsi_message(chan, vms); 07210 if (!vms->curmsg) 07211 res = wait_file2(chan, vms, "vm-first"); /* "First" */ 07212 else if (vms->curmsg == vms->lastmsg) 07213 res = wait_file2(chan, vms, "vm-last"); /* "last" */ 07214 07215 snprintf(filename, sizeof(filename), "%s.txt", vms->fn); 07216 RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context); 07217 msg_cfg = ast_config_load(filename, config_flags); 07218 if (!msg_cfg || msg_cfg == CONFIG_STATUS_FILEINVALID) { 07219 ast_log(LOG_WARNING, "No message attribute file?!! (%s)\n", filename); 07220 return 0; 07221 } 07222 flag = ast_variable_retrieve(msg_cfg, "message", "flag"); 07223 07224 /* Play the word urgent if we are listening to urgent messages */ 07225 if (!ast_strlen_zero(flag) && !strcmp(flag, "Urgent")) { 07226 res = wait_file2(chan, vms, "vm-Urgent"); /* "urgent" */ 07227 } 07228 07229 if (!res) { 07230 /* POLISH syntax */ 07231 if (!strncasecmp(chan->language, "pl", 2)) { 07232 if (vms->curmsg && (vms->curmsg != vms->lastmsg)) { 07233 int ten, one; 07234 char nextmsg[256]; 07235 ten = (vms->curmsg + 1) / 10; 07236 one = (vms->curmsg + 1) % 10; 07237 07238 if (vms->curmsg < 20) { 07239 snprintf(nextmsg, sizeof(nextmsg), "digits/n-%d", vms->curmsg + 1); 07240 res = wait_file2(chan, vms, nextmsg); 07241 } else { 07242 snprintf(nextmsg, sizeof(nextmsg), "digits/n-%d", ten * 10); 07243 res = wait_file2(chan, vms, nextmsg); 07244 if (one > 0) { 07245 if (!res) { 07246 snprintf(nextmsg, sizeof(nextmsg), "digits/n-%d", one); 07247 res = wait_file2(chan, vms, nextmsg); 07248 } 07249 } 07250 } 07251 } 07252 if (!res) 07253 res = wait_file2(chan, vms, "vm-message"); 07254 /* HEBREW syntax */ 07255 } else if (!strncasecmp(chan->language, "he", 2)) { 07256 if (!vms->curmsg) { 07257 res = wait_file2(chan, vms, "vm-message"); 07258 res = wait_file2(chan, vms, "vm-first"); 07259 } else if (vms->curmsg == vms->lastmsg) { 07260 res = wait_file2(chan, vms, "vm-message"); 07261 res = wait_file2(chan, vms, "vm-last"); 07262 } else { 07263 res = wait_file2(chan, vms, "vm-message"); 07264 res = wait_file2(chan, vms, "vm-number"); 07265 res = ast_say_number(chan, vms->curmsg + 1, AST_DIGIT_ANY, chan->language, "f"); 07266 } 07267 } else { 07268 if (!strncasecmp(chan->language, "se", 2)) { /* SWEDISH syntax */ 07269 res = wait_file2(chan, vms, "vm-meddelandet"); /* "message" */ 07270 } else { /* DEFAULT syntax */ 07271 res = wait_file2(chan, vms, "vm-message"); 07272 } 07273 if (vms->curmsg && (vms->curmsg != vms->lastmsg)) { 07274 if (!res) { 07275 res = ast_say_number(chan, vms->curmsg + 1, AST_DIGIT_ANY, chan->language, NULL); 07276 } 07277 } 07278 } 07279 } 07280 07281 if (!msg_cfg) { 07282 ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename); 07283 return 0; 07284 } 07285 07286 if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) { 07287 ast_log(AST_LOG_WARNING, "No origtime?!\n"); 07288 DISPOSE(vms->curdir, vms->curmsg); 07289 ast_config_destroy(msg_cfg); 07290 return 0; 07291 } 07292 07293 cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid")); 07294 duration = ast_variable_retrieve(msg_cfg, "message", "duration"); 07295 category = ast_variable_retrieve(msg_cfg, "message", "category"); 07296 07297 context = ast_variable_retrieve(msg_cfg, "message", "context"); 07298 if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */ 07299 context = ast_variable_retrieve(msg_cfg, "message","macrocontext"); 07300 if (!res) { 07301 res = play_message_category(chan, category); 07302 } 07303 if ((!res) && (ast_test_flag(vmu, VM_ENVELOPE))) 07304 res = play_message_datetime(chan, vmu, origtime, filename); 07305 if ((!res) && (ast_test_flag(vmu, VM_SAYCID))) 07306 res = play_message_callerid(chan, vms, cid, context, 0); 07307 if ((!res) && (ast_test_flag(vmu, VM_SAYDURATION))) 07308 res = play_message_duration(chan, vms, duration, vmu->saydurationm); 07309 /* Allow pressing '1' to skip envelope / callerid */ 07310 if (res == '1') 07311 res = 0; 07312 ast_config_destroy(msg_cfg); 07313 07314 if (!res) { 07315 make_file(vms->fn, sizeof(vms->fn), vms->curdir, vms->curmsg); 07316 vms->heard[vms->curmsg] = 1; 07317 #ifdef IMAP_STORAGE 07318 /*IMAP storage stores any prepended message from a forward 07319 * as a separate file from the rest of the message 07320 */ 07321 if (!ast_strlen_zero(vms->introfn) && ast_fileexists(vms->introfn, NULL, NULL) > 0) { 07322 wait_file(chan, vms, vms->introfn); 07323 } 07324 #endif 07325 if ((res = wait_file(chan, vms, vms->fn)) < 0) { 07326 ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn); 07327 res = 0; 07328 } 07329 } 07330 DISPOSE(vms->curdir, vms->curmsg); 07331 return res; 07332 }
| static int play_message_callerid | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| char * | cid, | |||
| const char * | context, | |||
| int | callback | |||
| ) | [static] |
Definition at line 7085 of file app_voicemail.c.
References ast_callerid_parse(), ast_debug, AST_DIGIT_ANY, ast_fileexists(), ast_say_digit_str(), ast_stream_and_wait(), ast_strlen_zero(), ast_verb, cidinternalcontexts, ast_channel::language, MAX_NUM_CID_CONTEXTS, and wait_file2().
Referenced by advanced_options(), and play_message().
07086 { 07087 int res = 0; 07088 int i; 07089 char *callerid, *name; 07090 char prefile[PATH_MAX] = ""; 07091 07092 07093 /* If voicemail cid is not enabled, or we didn't get cid or context from 07094 * the attribute file, leave now. 07095 * 07096 * TODO Still need to change this so that if this function is called by the 07097 * message envelope (and someone is explicitly requesting to hear the CID), 07098 * it does not check to see if CID is enabled in the config file. 07099 */ 07100 if ((cid == NULL)||(context == NULL)) 07101 return res; 07102 07103 /* Strip off caller ID number from name */ 07104 ast_debug(1, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context); 07105 ast_callerid_parse(cid, &name, &callerid); 07106 if ((!ast_strlen_zero(callerid)) && strcmp(callerid, "Unknown")) { 07107 /* Check for internal contexts and only */ 07108 /* say extension when the call didn't come from an internal context in the list */ 07109 for (i = 0 ; i < MAX_NUM_CID_CONTEXTS ; i++){ 07110 ast_debug(1, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]); 07111 if ((strcmp(cidinternalcontexts[i], context) == 0)) 07112 break; 07113 } 07114 if (i != MAX_NUM_CID_CONTEXTS){ /* internal context? */ 07115 if (!res) { 07116 snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, context, callerid); 07117 if (!ast_strlen_zero(prefile)) { 07118 /* See if we can find a recorded name for this person instead of their extension number */ 07119 if (ast_fileexists(prefile, NULL, NULL) > 0) { 07120 ast_verb(3, "Playing envelope info: CID number '%s' matches mailbox number, playing recorded name\n", callerid); 07121 if (!callback) 07122 res = wait_file2(chan, vms, "vm-from"); 07123 res = ast_stream_and_wait(chan, prefile, ""); 07124 } else { 07125 ast_verb(3, "Playing envelope info: message from '%s'\n", callerid); 07126 /* Say "from extension" as one saying to sound smoother */ 07127 if (!callback) 07128 res = wait_file2(chan, vms, "vm-from-extension"); 07129 res = ast_say_digit_str(chan, callerid, "", chan->language); 07130 } 07131 } 07132 } 07133 } else if (!res) { 07134 ast_debug(1, "VM-CID: Numeric caller id: (%s)\n", callerid); 07135 /* Since this is all nicely figured out, why not say "from phone number" in this case? */ 07136 if (!callback) 07137 res = wait_file2(chan, vms, "vm-from-phonenumber"); 07138 res = ast_say_digit_str(chan, callerid, AST_DIGIT_ANY, chan->language); 07139 } 07140 } else { 07141 /* Number unknown */ 07142 ast_debug(1, "VM-CID: From an unknown number\n"); 07143 /* Say "from an unknown caller" as one phrase - it is already recorded by "the voice" anyhow */ 07144 res = wait_file2(chan, vms, "vm-unknown-caller"); 07145 } 07146 return res; 07147 }
| static int play_message_category | ( | struct ast_channel * | chan, | |
| const char * | category | |||
| ) | [static] |
Definition at line 6998 of file app_voicemail.c.
References ast_log(), AST_LOG_WARNING, ast_play_and_wait(), and ast_strlen_zero().
Referenced by play_message().
06999 { 07000 int res = 0; 07001 07002 if (!ast_strlen_zero(category)) 07003 res = ast_play_and_wait(chan, category); 07004 07005 if (res) { 07006 ast_log(AST_LOG_WARNING, "No sound file for category '%s' was found.\n", category); 07007 res = 0; 07008 } 07009 07010 return res; 07011 }
| static int play_message_datetime | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| const char * | origtime, | |||
| const char * | filename | |||
| ) | [static] |
Definition at line 7013 of file app_voicemail.c.
References AST_DIGIT_ANY, ast_get_time_t(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_localtime(), ast_log(), AST_LOG_WARNING, ast_say_date_with_format, ast_strlen_zero(), ast_tvnow(), ast_channel::language, vm_zone::msg_format, vm_zone::name, pbx_builtin_setvar_helper(), vm_zone::timezone, and ast_vm_user::zonetag.
Referenced by advanced_options(), and play_message().
07014 { 07015 int res = 0; 07016 struct vm_zone *the_zone = NULL; 07017 time_t t; 07018 07019 if (ast_get_time_t(origtime, &t, 0, NULL)) { 07020 ast_log(AST_LOG_WARNING, "Couldn't find origtime in %s\n", filename); 07021 return 0; 07022 } 07023 07024 /* Does this user have a timezone specified? */ 07025 if (!ast_strlen_zero(vmu->zonetag)) { 07026 /* Find the zone in the list */ 07027 struct vm_zone *z; 07028 AST_LIST_LOCK(&zones); 07029 AST_LIST_TRAVERSE(&zones, z, list) { 07030 if (!strcmp(z->name, vmu->zonetag)) { 07031 the_zone = z; 07032 break; 07033 } 07034 } 07035 AST_LIST_UNLOCK(&zones); 07036 } 07037 07038 /* No internal variable parsing for now, so we'll comment it out for the time being */ 07039 #if 0 07040 /* Set the DIFF_* variables */ 07041 ast_localtime(&t, &time_now, NULL); 07042 tv_now = ast_tvnow(); 07043 ast_localtime(&tv_now, &time_then, NULL); 07044 07045 /* Day difference */ 07046 if (time_now.tm_year == time_then.tm_year) 07047 snprintf(temp,sizeof(temp),"%d",time_now.tm_yday); 07048 else 07049 snprintf(temp,sizeof(temp),"%d",(time_now.tm_year - time_then.tm_year) * 365 + (time_now.tm_yday - time_then.tm_yday)); 07050 pbx_builtin_setvar_helper(chan, "DIFF_DAY", temp); 07051 07052 /* Can't think of how other diffs might be helpful, but I'm sure somebody will think of something. */ 07053 #endif 07054 if (the_zone) { 07055 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, the_zone->msg_format, the_zone->timezone); 07056 } else if (!strncasecmp(chan->language, "de", 2)) { /* GERMAN syntax */ 07057 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q 'digits/at' HM", NULL); 07058 } else if (!strncasecmp(chan->language, "gr", 2)) { /* GREEK syntax */ 07059 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q H 'digits/kai' M ", NULL); 07060 } else if (!strncasecmp(chan->language, "it", 2)) { /* ITALIAN syntax */ 07061 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); 07062 } else if (!strncasecmp(chan->language, "nl", 2)) { /* DUTCH syntax */ 07063 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/nl-om' HM", NULL); 07064 } else if (!strncasecmp(chan->language, "no", 2)) { /* NORWEGIAN syntax */ 07065 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q 'digits/at' HM", NULL); 07066 } else if (!strncasecmp(chan->language, "pl", 2)) { /* POLISH syntax */ 07067 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q HM", NULL); 07068 } else if (!strncasecmp(chan->language, "pt_BR", 5)) { /* Brazillian PORTUGUESE syntax */ 07069 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Ad 'digits/pt-de' B 'digits/pt-de' Y 'digits/pt-as' HM ", NULL); 07070 } else if (!strncasecmp(chan->language, "se", 2)) { /* SWEDISH syntax */ 07071 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' dB 'digits/at' k 'and' M", NULL); 07072 } else if (!strncasecmp(chan->language, "zh", 2)) { /* CHINESE (Taiwan) syntax */ 07073 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "qR 'vm-received'", NULL); 07074 } else { 07075 res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL); 07076 } 07077 #if 0 07078 pbx_builtin_setvar_helper(chan, "DIFF_DAY", NULL); 07079 #endif 07080 return res; 07081 }
| static int play_message_duration | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| const char * | duration, | |||
| int | minduration | |||
| ) | [static] |
Definition at line 7149 of file app_voicemail.c.
References ast_debug, AST_DIGIT_ANY, ast_play_and_wait(), ast_say_number(), ast_channel::language, num, say_and_wait(), and wait_file2().
Referenced by play_message().
07150 { 07151 int res = 0; 07152 int durationm; 07153 int durations; 07154 /* Verify that we have a duration for the message */ 07155 if (duration == NULL) 07156 return res; 07157 07158 /* Convert from seconds to minutes */ 07159 durations=atoi(duration); 07160 durationm=(durations / 60); 07161 07162 ast_debug(1, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm); 07163 07164 if ((!res) && (durationm >= minduration)) { 07165 res = wait_file2(chan, vms, "vm-duration"); 07166 07167 /* POLISH syntax */ 07168 if (!strncasecmp(chan->language, "pl", 2)) { 07169 div_t num = div(durationm, 10); 07170 07171 if (durationm == 1) { 07172 res = ast_play_and_wait(chan, "digits/1z"); 07173 res = res ? res : ast_play_and_wait(chan, "vm-minute-ta"); 07174 } else if (num.rem > 1 && num.rem < 5 && num.quot != 1) { 07175 if (num.rem == 2) { 07176 if (!num.quot) { 07177 res = ast_play_and_wait(chan, "digits/2-ie"); 07178 } else { 07179 res = say_and_wait(chan, durationm - 2 , chan->language); 07180 res = res ? res : ast_play_and_wait(chan, "digits/2-ie"); 07181 } 07182 } else { 07183 res = say_and_wait(chan, durationm, chan->language); 07184 } 07185 res = res ? res : ast_play_and_wait(chan, "vm-minute-ty"); 07186 } else { 07187 res = say_and_wait(chan, durationm, chan->language); 07188 res = res ? res : ast_play_and_wait(chan, "vm-minute-t"); 07189 } 07190 /* DEFAULT syntax */ 07191 } else { 07192 res = ast_say_number(chan, durationm, AST_DIGIT_ANY, chan->language, NULL); 07193 res = wait_file2(chan, vms, "vm-minutes"); 07194 } 07195 } 07196 return res; 07197 }
| static 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, | |||
| struct vm_state * | vms, | |||
| char * | flag | |||
| ) | [static] |
Definition at line 11778 of file app_voicemail.c.
References acceptdtmf, ast_channel_setoption(), ast_copy_string(), AST_DIGIT_ANY, ast_filedelete(), ast_filerename(), ast_log(), AST_LOG_WARNING, AST_OPTION_RXGAIN, ast_play_and_record_full(), ast_play_and_wait(), ast_stream_and_wait(), ast_strlen_zero(), ast_test_flag, ast_verb, ast_verbose, ast_waitfordigit(), ast_vm_user::context, DELETE, DISPOSE, INTRO, ast_vm_user::mailbox, STORE, VERBOSE_PREFIX_3, vm_exec(), VM_OPERATOR, and VM_REVIEW.
Referenced by leave_voicemail(), vm_forwardoptions(), vm_newuser(), vm_options(), and vm_tempgreeting().
11781 { 11782 /* Record message & let caller review or re-record it, or set options if applicable */ 11783 int res = 0; 11784 int cmd = 0; 11785 int max_attempts = 3; 11786 int attempts = 0; 11787 int recorded = 0; 11788 int msg_exists = 0; 11789 signed char zero_gain = 0; 11790 char tempfile[PATH_MAX]; 11791 char *acceptdtmf = "#"; 11792 char *canceldtmf = ""; 11793 int canceleddtmf = 0; 11794 11795 /* Note that urgent and private are for flagging messages as such in the future */ 11796 11797 /* barf if no pointer passed to store duration in */ 11798 if (duration == NULL) { 11799 ast_log(AST_LOG_WARNING, "Error play_record_review called without duration pointer\n"); 11800 return -1; 11801 } 11802 11803 if (!outsidecaller) 11804 snprintf(tempfile, sizeof(tempfile), "%s.tmp", recordfile); 11805 else 11806 ast_copy_string(tempfile, recordfile, sizeof(tempfile)); 11807 11808 cmd = '3'; /* Want to start by recording */ 11809 11810 while ((cmd >= 0) && (cmd != 't')) { 11811 switch (cmd) { 11812 case '1': 11813 if (!msg_exists) { 11814 /* In this case, 1 is to record a message */ 11815 cmd = '3'; 11816 break; 11817 } else { 11818 /* Otherwise 1 is to save the existing message */ 11819 ast_verb(3, "Saving message as is\n"); 11820 if (!outsidecaller) 11821 ast_filerename(tempfile, recordfile, NULL); 11822 ast_stream_and_wait(chan, "vm-msgsaved", ""); 11823 if (!outsidecaller) { 11824 /* Saves to IMAP server only if imapgreeting=yes */ 11825 STORE(recordfile, vmu->mailbox, vmu->context, -1, chan, vmu, fmt, *duration, vms, flag); 11826 DISPOSE(recordfile, -1); 11827 } 11828 cmd = 't'; 11829 return res; 11830 } 11831 case '2': 11832 /* Review */ 11833 ast_verb(3, "Reviewing the message\n"); 11834 cmd = ast_stream_and_wait(chan, tempfile, AST_DIGIT_ANY); 11835 break; 11836 case '3': 11837 msg_exists = 0; 11838 /* Record */ 11839 if (recorded == 1) 11840 ast_verb(3, "Re-recording the message\n"); 11841 else 11842 ast_verb(3, "Recording the message\n"); 11843 11844 if (recorded && outsidecaller) { 11845 cmd = ast_play_and_wait(chan, INTRO); 11846 cmd = ast_play_and_wait(chan, "beep"); 11847 } 11848 recorded = 1; 11849 /* 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 */ 11850 if (record_gain) 11851 ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0); 11852 if (ast_test_flag(vmu, VM_OPERATOR)) 11853 canceldtmf = "0"; 11854 cmd = ast_play_and_record_full(chan, playfile, tempfile, maxtime, fmt, duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf); 11855 if (strchr(canceldtmf, cmd)) { 11856 /* need this flag here to distinguish between pressing '0' during message recording or after */ 11857 canceleddtmf = 1; 11858 } 11859 if (record_gain) 11860 ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0); 11861 if (cmd == -1) { 11862 /* User has hung up, no options to give */ 11863 if (!outsidecaller) { 11864 /* user was recording a greeting and they hung up, so let's delete the recording. */ 11865 ast_filedelete(tempfile, NULL); 11866 } 11867 return cmd; 11868 } 11869 if (cmd == '0') { 11870 break; 11871 } else if (cmd == '*') { 11872 break; 11873 #if 0 11874 } else if (vmu->review && (*duration < 5)) { 11875 /* Message is too short */ 11876 ast_verb(3, "Message too short\n"); 11877 cmd = ast_play_and_wait(chan, "vm-tooshort"); 11878 cmd = ast_filedelete(tempfile, NULL); 11879 break; 11880 } else if (vmu->review && (cmd == 2 && *duration < (maxsilence + 3))) { 11881 /* Message is all silence */ 11882 ast_verb(3, "Nothing recorded\n"); 11883 cmd = ast_filedelete(tempfile, NULL); 11884 cmd = ast_play_and_wait(chan, "vm-nothingrecorded"); 11885 if (!cmd) 11886 cmd = ast_play_and_wait(chan, "vm-speakup"); 11887 break; 11888 #endif 11889 } else { 11890 /* If all is well, a message exists */ 11891 msg_exists = 1; 11892 cmd = 0; 11893 } 11894 break; 11895 case '4': 11896 if (outsidecaller) { /* only mark vm messages */ 11897 /* Mark Urgent */ 11898 if ((flag && ast_strlen_zero(flag)) || (!ast_strlen_zero(flag) && strcmp(flag, "Urgent"))) { 11899 ast_verbose(VERBOSE_PREFIX_3 "marking message as Urgent\n"); 11900 res = ast_play_and_wait(chan, "vm-marked-urgent"); 11901 strcpy(flag, "Urgent"); 11902 } else if (flag) { 11903 ast_verbose(VERBOSE_PREFIX_3 "UNmarking message as Urgent\n"); 11904 res = ast_play_and_wait(chan, "vm-urgent-removed"); 11905 strcpy(flag, ""); 11906 } else { 11907 ast_play_and_wait(chan, "vm-sorry"); 11908 } 11909 cmd = 0; 11910 } else { 11911 cmd = ast_play_and_wait(chan, "vm-sorry"); 11912 } 11913 break; 11914 case '5': 11915 case '6': 11916 case '7': 11917 case '8': 11918 case '9': 11919 case '*': 11920 case '#': 11921 cmd = ast_play_and_wait(chan, "vm-sorry"); 11922 break; 11923 #if 0 11924 /* XXX Commented out for the moment because of the dangers of deleting 11925 a message while recording (can put the message numbers out of sync) */ 11926 case '*': 11927 /* Cancel recording, delete message, offer to take another message*/ 11928 cmd = ast_play_and_wait(chan, "vm-deleted"); 11929 cmd = ast_filedelete(tempfile, NULL); 11930 if (outsidecaller) { 11931 res = vm_exec(chan, NULL); 11932 return res; 11933 } 11934 else 11935 return 1; 11936 #endif 11937 case '0': 11938 if (!ast_test_flag(vmu, VM_OPERATOR) || (!canceleddtmf && !outsidecaller)) { 11939 cmd = ast_play_and_wait(chan, "vm-sorry"); 11940 break; 11941 } 11942 if (msg_exists || recorded) { 11943 cmd = ast_play_and_wait(chan, "vm-saveoper"); 11944 if (!cmd) 11945 cmd = ast_waitfordigit(chan, 3000); 11946 if (cmd == '1') { 11947 ast_filerename(tempfile, recordfile, NULL); 11948 ast_play_and_wait(chan, "vm-msgsaved"); 11949 cmd = '0'; 11950 } else if (cmd == '4') { 11951 if (flag) { 11952 ast_play_and_wait(chan, "vm-marked-urgent"); 11953 strcpy(flag, "Urgent"); 11954 } 11955 ast_play_and_wait(chan, "vm-msgsaved"); 11956 cmd = '0'; 11957 } else { 11958 ast_play_and_wait(chan, "vm-deleted"); 11959 DELETE(tempfile, -1, tempfile, vmu); 11960 cmd = '0'; 11961 } 11962 } 11963 return cmd; 11964 default: 11965 /* If the caller is an ouside caller, and the review option is enabled, 11966 allow them to review the message, but let the owner of the box review 11967 their OGM's */ 11968 if (outsidecaller && !ast_test_flag(vmu, VM_REVIEW)) 11969 return cmd; 11970 if (msg_exists) { 11971 cmd = ast_play_and_wait(chan, "vm-review"); 11972 if (!cmd && outsidecaller) { 11973 if ((flag && ast_strlen_zero(flag)) || (!ast_strlen_zero(flag) && strcmp(flag, "Urgent"))) { 11974 cmd = ast_play_and_wait(chan, "vm-review-urgent"); 11975 } else if (flag) { 11976 cmd = ast_play_and_wait(chan, "vm-review-nonurgent"); 11977 } 11978 } 11979 } else { 11980 cmd = ast_play_and_wait(chan, "vm-torerecord"); 11981 if (!cmd) 11982 cmd = ast_waitfordigit(chan, 600); 11983 } 11984 11985 if (!cmd && outsidecaller && ast_test_flag(vmu, VM_OPERATOR)) { 11986 cmd = ast_play_and_wait(chan, "vm-reachoper"); 11987 if (!cmd) 11988 cmd = ast_waitfordigit(chan, 600); 11989 } 11990 #if 0 11991 if (!cmd) 11992 cmd = ast_play_and_wait(chan, "vm-tocancelmsg"); 11993 #endif 11994 if (!cmd) 11995 cmd = ast_waitfordigit(chan, 6000); 11996 if (!cmd) { 11997 attempts++; 11998 } 11999 if (attempts > max_attempts) { 12000 cmd = 't'; 12001 } 12002 } 12003 } 12004 if (!outsidecaller && (cmd == -1 || cmd == 't')) { 12005 /* Hang up or timeout, so delete the recording. */ 12006 ast_filedelete(tempfile, NULL); 12007 } 12008 12009 if (cmd != 't' && outsidecaller) 12010 ast_play_and_wait(chan, "vm-goodbye"); 12011 12012 return cmd; 12013 }
| static void poll_subscribed_mailbox | ( | struct mwi_sub * | mwi_sub | ) | [static] |
Definition at line 10418 of file app_voicemail.c.
References inboxcount2(), mwi_sub::mailbox, mwi_sub::old_new, mwi_sub::old_old, mwi_sub::old_urgent, and queue_mwi_event().
Referenced by handle_subscribe(), and poll_subscribed_mailboxes().
10419 { 10420 int new = 0, old = 0, urgent = 0; 10421 10422 inboxcount2(mwi_sub->mailbox, &urgent, &new, &old); 10423 10424 if (urgent != mwi_sub->old_urgent || new != mwi_sub->old_new || old != mwi_sub->old_old) { 10425 mwi_sub->old_urgent = urgent; 10426 mwi_sub->old_new = new; 10427 mwi_sub->old_old = old; 10428 queue_mwi_event(mwi_sub->mailbox, urgent, new, old); 10429 } 10430 }
| static void poll_subscribed_mailboxes | ( | void | ) | [static] |
Definition at line 10432 of file app_voicemail.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strlen_zero(), mwi_sub::entry, mwi_sub::mailbox, and poll_subscribed_mailbox().
Referenced by mb_poll_thread().
10433 { 10434 struct mwi_sub *mwi_sub; 10435 10436 AST_RWLIST_RDLOCK(&mwi_subs); 10437 AST_RWLIST_TRAVERSE(&mwi_subs, mwi_sub, entry) { 10438 if (!ast_strlen_zero(mwi_sub->mailbox)) { 10439 poll_subscribed_mailbox(mwi_sub); 10440 } 10441 } 10442 AST_RWLIST_UNLOCK(&mwi_subs); 10443 }
| static void populate_defaults | ( | struct ast_vm_user * | vmu | ) | [static] |
Sets default voicemail system options to a voicemail user.
This applies select global settings to a newly created (dynamic) instance of a voicemail user.
Definition at line 930 of file app_voicemail.c.
References ast_copy_flags, ast_copy_string(), AST_FLAGS_ALL, ast_vm_user::callback, callcontext, dialcontext, ast_vm_user::dialout, ast_vm_user::emailbody, ast_vm_user::emailsubject, ast_vm_user::exit, exitcontext, globalflags, ast_vm_user::maxdeletedmsg, ast_vm_user::maxmsg, ast_vm_user::maxsecs, ast_vm_user::saydurationm, saydurationminfo, ast_vm_user::volgain, and ast_vm_user::zonetag.
Referenced by append_mailbox(), find_user_realtime(), and load_config().
00931 { 00932 ast_copy_flags(vmu, (&globalflags), AST_FLAGS_ALL); 00933 if (saydurationminfo) 00934 vmu->saydurationm = saydurationminfo; 00935 ast_copy_string(vmu->callback, callcontext, sizeof(vmu->callback)); 00936 ast_copy_string(vmu->dialout, dialcontext, sizeof(vmu->dialout)); 00937 ast_copy_string(vmu->exit, exitcontext, sizeof(vmu->exit)); 00938 ast_copy_string(vmu->zonetag, zonetag, sizeof(vmu->zonetag)); 00939 if (vmmaxsecs) 00940 vmu->maxsecs = vmmaxsecs; 00941 if (maxmsg) 00942 vmu->maxmsg = maxmsg; 00943 if (maxdeletedmsg) 00944 vmu->maxdeletedmsg = maxdeletedmsg; 00945 vmu->volgain = volgain; 00946 vmu->emailsubject = NULL; 00947 vmu->emailbody = NULL; 00948 }
| static void prep_email_sub_vars | ( | struct ast_channel * | ast, | |
| struct ast_vm_user * | vmu, | |||
| int | msgnum, | |||
| char * | context, | |||
| char * | mailbox, | |||
| const char * | fromfolder, | |||
| char * | cidnum, | |||
| char * | cidname, | |||
| char * | dur, | |||
| char * | date, | |||
| char * | passdata, | |||
| size_t | passdatasize, | |||
| const char * | category, | |||
| const char * | flag | |||
| ) | [static] |
Definition at line 4057 of file app_voicemail.c.
References ast_callerid_merge(), ast_callerid_split(), ast_config_destroy(), ast_config_load, ast_localtime(), ast_log(), ast_strdupa, ast_strftime(), ast_strlen_zero(), ast_variable_retrieve(), CONFIG_FLAG_NOCACHE, ast_vm_user::context, emaildateformat, ast_vm_user::fullname, LOG_DEBUG, ast_vm_user::mailbox, make_dir(), make_file(), option_debug, and pbx_builtin_setvar_helper().
Referenced by make_email_file(), and sendpage().
04058 { 04059 char callerid[256]; 04060 char fromdir[256], fromfile[256]; 04061 struct ast_config *msg_cfg; 04062 const char *origcallerid, *origtime; 04063 char origcidname[80], origcidnum[80], origdate[80]; 04064 int inttime; 04065 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE }; 04066 04067 /* Prepare variables for substitution in email body and subject */ 04068 pbx_builtin_setvar_helper(ast, "VM_NAME", vmu->fullname); 04069 pbx_builtin_setvar_helper(ast, "VM_DUR", dur); 04070 snprintf(passdata, passdatasize, "%d", msgnum); 04071 pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata); 04072 pbx_builtin_setvar_helper(ast, "VM_CONTEXT", context); 04073 pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox); 04074 pbx_builtin_setvar_helper(ast, "VM_CALLERID", (!ast_strlen_zero(cidname) || !ast_strlen_zero(cidnum)) ? 04075 ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, NULL) : "an unknown caller"); 04076 pbx_builtin_setvar_helper(ast, "VM_CIDNAME", (!ast_strlen_zero(cidname) ? cidname : "an unknown caller")); 04077 pbx_builtin_setvar_helper(ast, "VM_CIDNUM", (!ast_strlen_zero(cidnum) ? cidnum : "an unknown caller")); 04078 pbx_builtin_setvar_helper(ast, "VM_DATE", date); 04079 pbx_builtin_setvar_helper(ast, "VM_CATEGORY", category ? ast_strdupa(category) : "no category"); 04080 pbx_builtin_setvar_helper(ast, "VM_FLAG", flag); 04081 04082 /* Retrieve info from VM attribute file */ 04083 make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, fromfolder); 04084 make_file(fromfile, sizeof(fromfile), fromdir, msgnum - 1); 04085 if (strlen(fromfile) < sizeof(fromfile) - 5) { 04086 strcat(fromfile, ".txt"); 04087 } 04088 if (!(msg_cfg = ast_config_load(fromfile, config_flags))) { 04089 if (option_debug > 0) { 04090 ast_log(LOG_DEBUG, "Config load for message text file '%s' failed\n", fromfile); 04091 } 04092 return; 04093 } 04094 04095 if ((origcallerid = ast_variable_retrieve(msg_cfg, "message", "callerid"))) { 04096 pbx_builtin_setvar_helper(ast, "ORIG_VM_CALLERID", origcallerid); 04097 ast_callerid_split(origcallerid, origcidname, sizeof(origcidname), origcidnum, sizeof(origcidnum)); 04098 pbx_builtin_setvar_helper(ast, "ORIG_VM_CIDNAME", origcidname); 04099 pbx_builtin_setvar_helper(ast, "ORIG_VM_CIDNUM", origcidnum); 04100 } 04101 04102 if ((origtime = ast_variable_retrieve(msg_cfg, "message", "origtime")) && sscanf(origtime, "%30d", &inttime) == 1) { 04103 struct timeval tv = { inttime, }; 04104 struct ast_tm tm; 04105 ast_localtime(&tv, &tm, NULL); 04106 ast_strftime(origdate, sizeof(origdate), emaildateformat, &tm); 04107 pbx_builtin_setvar_helper(ast, "ORIG_VM_DATE", origdate); 04108 } 04109 ast_config_destroy(msg_cfg); 04110 }
| static void queue_mwi_event | ( | const char * | box, | |
| int | urgent, | |||
| int | new, | |||
| int | old | |||
| ) | [static] |
Definition at line 6551 of file app_voicemail.c.
References AST_EVENT_IE_CONTEXT, AST_EVENT_IE_END, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI, ast_event_new(), ast_event_queue_and_cache(), ast_strdupa, ast_strlen_zero(), and strsep().
Referenced by append_mailbox(), notify_new_message(), poll_subscribed_mailbox(), and vm_execmain().
06552 { 06553 struct ast_event *event; 06554 char *mailbox, *context; 06555 06556 /* Strip off @default */ 06557 context = mailbox = ast_strdupa(box); 06558 strsep(&context, "@"); 06559 if (ast_strlen_zero(context)) 06560 context = "default"; 06561 06562 if (!(event = ast_event_new(AST_EVENT_MWI, 06563 AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, 06564 AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context, 06565 AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, (new+urgent), 06566 AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old, 06567 AST_EVENT_IE_END))) { 06568 return; 06569 } 06570 06571 ast_event_queue_and_cache(event); 06572 }
| static char* quote | ( | const char * | from, | |
| char * | to, | |||
| size_t | len | |||
| ) | [static] |
Wraps a character sequence in double quotes, escaping occurences of quotes within the string.
| from | The string to work with. | |
| to | The string to write the modified quoted string. This buffer should be sufficiently larger than the from string, so as to allow it to be expanded by the surrounding quotes and escaping of internal quotes. |
Definition at line 4119 of file app_voicemail.c.
Referenced by __ast_app_separate_args(), make_email_file(), and parse_options().
04120 { 04121 char *ptr = to; 04122 *ptr++ = '"'; 04123 for (; ptr < to + len - 1; from++) { 04124 if (*from == '"') 04125 *ptr++ = '\\'; 04126 else if (*from == '\0') 04127 break; 04128 *ptr++ = *from; 04129 } 04130 if (ptr < to + len - 1) 04131 *ptr++ = '"'; 04132 *ptr = '\0'; 04133 return to; 04134 }
| static int reload | ( | void | ) | [static] |
Definition at line 11449 of file app_voicemail.c.
References load_config().
11450 { 11451 return load_config(1); 11452 }
| static void rename_file | ( | char * | sfn, | |
| char * | dfn | |||
| ) | [static] |
Renames a message in a mailbox folder.
| sfn | The path to the mailbox information and data file to be renamed. | |
| dfn | The path for where the message data and information files will be renamed to. |
Definition at line 3734 of file app_voicemail.c.
References ast_check_realtime(), ast_filerename(), ast_update_realtime(), and SENTINEL.
03735 { 03736 char stxt[PATH_MAX]; 03737 char dtxt[PATH_MAX]; 03738 ast_filerename(sfn,dfn,NULL); 03739 snprintf(stxt, sizeof(stxt), "%s.txt", sfn); 03740 snprintf(dtxt, sizeof(dtxt), "%s.txt", dfn); 03741 if (ast_check_realtime("voicemail_data")) { 03742 ast_update_realtime("voicemail_data", "filename", sfn, "filename", dfn, SENTINEL); 03743 } 03744 rename(stxt, dtxt); 03745 }
| static int reset_user_pw | ( | const char * | context, | |
| const char * | mailbox, | |||
| const char * | newpass | |||
| ) | [static] |
Resets a user password to a specified password.
| context | ||
| mailbox | ||
| newpass | This does the actual change password work, called by the vm_change_password() function. |
Definition at line 1340 of file app_voicemail.c.
References ast_copy_string(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_vm_user::context, ast_vm_user::mailbox, and ast_vm_user::password.
Referenced by vm_change_password(), and vm_change_password_shell().
01341 { 01342 /* This function could be made to generate one from a database, too */ 01343 struct ast_vm_user *cur; 01344 int res = -1; 01345 AST_LIST_LOCK(&users); 01346 AST_LIST_TRAVERSE(&users, cur, list) { 01347 if ((!context || !strcasecmp(context, cur->context)) && 01348 (!strcasecmp(mailbox, cur->mailbox))) 01349 break; 01350 } 01351 if (cur) { 01352 ast_copy_string(cur->password, newpass, sizeof(cur->password)); 01353 res = 0; 01354 } 01355 AST_LIST_UNLOCK(&users); 01356 return res; 01357 }
| static void run_externnotify | ( | char * | context, | |
| char * | extension, | |||
| const char * | flag | |||
| ) | [static] |
Definition at line 5179 of file app_voicemail.c.
References ast_app_has_voicemail(), ast_copy_string(), ast_debug, ast_log(), AST_LOG_ERROR, AST_LOG_WARNING, ast_safe_system(), ast_smdi_mwi_message_destroy(), ast_smdi_mwi_message_wait_station(), ast_smdi_mwi_set(), ast_smdi_mwi_unset(), ast_strlen_zero(), ASTOBJ_UNREF, ast_smdi_mwi_message::cause, ast_smdi_mwi_message::fwd_st, inboxcount2(), and SMDI_MWI_WAIT_TIMEOUT.
Referenced by forward_message(), notify_new_message(), and vm_execmain().
05180 { 05181 char arguments[255]; 05182 char ext_context[256] = ""; 05183 int newvoicemails = 0, oldvoicemails = 0, urgentvoicemails = 0; 05184 struct ast_smdi_mwi_message *mwi_msg; 05185 05186 if (!ast_strlen_zero(context)) 05187 snprintf(ext_context, sizeof(ext_context), "%s@%s", extension, context); 05188 else 05189 ast_copy_string(ext_context, extension, sizeof(ext_context)); 05190 05191 if (smdi_iface) { 05192 if (ast_app_has_voicemail(ext_context, NULL)) 05193 ast_smdi_mwi_set(smdi_iface, extension); 05194 else 05195 ast_smdi_mwi_unset(smdi_iface, extension); 05196 05197 if ((mwi_msg = ast_smdi_mwi_message_wait_station(smdi_iface, SMDI_MWI_WAIT_TIMEOUT, extension))) { 05198 ast_log(AST_LOG_ERROR, "Error executing SMDI MWI change for %s\n", extension); 05199 if (!strncmp(mwi_msg->cause, "INV", 3)) 05200 ast_log(AST_LOG_ERROR, "Invalid MWI extension: %s\n", mwi_msg->fwd_st); 05201 else if (!strncmp(mwi_msg->cause, "BLK", 3)) 05202 ast_log(AST_LOG_WARNING, "MWI light was already on or off for %s\n", mwi_msg->fwd_st); 05203 ast_log(AST_LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause); 05204 ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy); 05205 } else { 05206 ast_debug(1, "Successfully executed SMDI MWI change for %s\n", extension); 05207 } 05208 } 05209 05210 if (!ast_strlen_zero(externnotify)) { 05211 if (inboxcount2(ext_context, &urgentvoicemails, &newvoicemails, &oldvoicemails)) { 05212 ast_log(AST_LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension); 05213 } else { 05214 snprintf(arguments, sizeof(arguments), "%s %s %s %d %d %d &", externnotify, context, extension, newvoicemails, oldvoicemails, urgentvoicemails); 05215 ast_debug(1, "Executing %s\n", arguments); 05216 ast_safe_system(arguments); 05217 } 05218 } 05219 }
| static int save_to_folder | ( | struct ast_vm_user * | vmu, | |
| struct vm_state * | vms, | |||
| int | msg, | |||
| int | box | |||
| ) | [static] |
Definition at line 5760 of file app_voicemail.c.
References ast_debug, ast_log(), AST_LOG_NOTICE, ast_mutex_lock(), ast_mutex_unlock(), ast_unlock_path(), ast_vm_user::context, COPY, create_dirpath(), vm_state::curbox, vm_state::curdir, ERROR_LOCK_PATH, EXISTS, last_message_index(), ast_vm_user::mailbox, make_file(), ast_vm_user::maxdeletedmsg, ast_vm_user::maxmsg, mbox(), NEW_FOLDER, OLD_FOLDER, RENAME, vm_state::username, and vm_lock_path().
Referenced by close_mailbox(), and vm_execmain().
05761 { 05762 #ifdef IMAP_STORAGE 05763 /* we must use mbox(x) folder names, and copy the message there */ 05764 /* simple. huh? */ 05765 char sequence[10]; 05766 char mailbox[256]; 05767 int res; 05768 05769 /* get the real IMAP message number for this message */ 05770 snprintf(sequence, sizeof(sequence), "%ld", vms->msgArray[msg]); 05771 05772 ast_debug(3, "Copying sequence %s to mailbox %s\n", sequence, mbox(box)); 05773 ast_mutex_lock(&vms->lock); 05774 /* if save to Old folder, put in INBOX as read */ 05775 if (box == OLD_FOLDER) { 05776 mail_setflag(vms->mailstream, sequence, "\\Seen"); 05777 mail_clearflag(vms->mailstream, sequence, "\\Unseen"); 05778 } else if (box == NEW_FOLDER) { 05779 mail_setflag(vms->mailstream, sequence, "\\Unseen"); 05780 mail_clearflag(vms->mailstream, sequence, "\\Seen"); 05781 } 05782 if (!strcasecmp(mbox(NEW_FOLDER), vms->curbox) && (box == NEW_FOLDER || box == OLD_FOLDER)) { 05783 ast_mutex_unlock(&vms->lock); 05784 return 0; 05785 } 05786 /* Create the folder if it don't exist */ 05787 imap_mailbox_name(mailbox, sizeof(mailbox), vms, box, 1); /* Get the full mailbox name */ 05788 ast_debug(5, "Checking if folder exists: %s\n",mailbox); 05789 if (mail_create(vms->mailstream, mailbox) == NIL) 05790 ast_debug(5, "Folder exists.\n"); 05791 else 05792 ast_log(AST_LOG_NOTICE, "Folder %s created!\n",mbox(box)); 05793 res = !mail_copy(vms->mailstream, sequence, (char *)mbox(box)); 05794 ast_mutex_unlock(&vms->lock); 05795 return res; 05796 #else 05797 char *dir = vms->curdir; 05798 char *username = vms->username; 05799 char *context = vmu->context; 05800 char sfn[PATH_MAX]; 05801 char dfn[PATH_MAX]; 05802 char ddir[PATH_MAX]; 05803 const char *dbox = mbox(box); 05804 int x, i; 05805 create_dirpath(ddir, sizeof(ddir), context, username, dbox); 05806 05807 if (vm_lock_path(ddir)) 05808 return ERROR_LOCK_PATH; 05809 05810 x = last_message_index(vmu, ddir) + 1; 05811 05812 if (box == 10 && x >= vmu->maxdeletedmsg) { /* "Deleted" folder*/ 05813 x--; 05814 for (i = 1; i <= x; i++) { 05815 /* Push files down a "slot". The oldest file (msg0000) will be deleted. */ 05816 make_file(sfn, sizeof(sfn), ddir, i); 05817 make_file(dfn, sizeof(dfn), ddir, i - 1); 05818 if (EXISTS(ddir, i, sfn, NULL)) { 05819 RENAME(ddir, i, vmu->mailbox, vmu->context, ddir, i - 1, sfn, dfn); 05820 } else 05821 break; 05822 } 05823 } else { 05824 if (x >= vmu->maxmsg) { 05825 ast_unlock_path(ddir); 05826 return -1; 05827 } 05828 } 05829 make_file(sfn, sizeof(sfn), dir, msg); 05830 make_file(dfn, sizeof(dfn), ddir, x); 05831 if (strcmp(sfn, dfn)) { 05832 COPY(dir, msg, ddir, x, username, context, sfn, dfn); 05833 } 05834 ast_unlock_path(ddir); 05835 #endif 05836 return 0; 05837 }
| static int say_and_wait | ( | struct ast_channel * | chan, | |
| int | num, | |||
| const char * | language | |||
| ) | [static] |
Definition at line 5753 of file app_voicemail.c.
References AST_DIGIT_ANY, and ast_say_number().
Referenced by play_message_duration(), vm_execmain(), vm_intro_cs(), vm_intro_de(), vm_intro_en(), vm_intro_es(), vm_intro_fr(), vm_intro_it(), vm_intro_nl(), vm_intro_no(), vm_intro_pl(), vm_intro_se(), and vm_intro_zh().
05754 { 05755 int d; 05756 d = ast_say_number(chan, num, AST_DIGIT_ANY, language, NULL); 05757 return d; 05758 }
| static int sayname | ( | struct ast_channel * | chan, | |
| const char * | mailbox, | |||
| const char * | context | |||
| ) | [static] |
Definition at line 11435 of file app_voicemail.c.
References ast_debug, AST_DIGIT_ANY, ast_fileexists(), ast_stream_and_wait(), DISPOSE, and RETRIEVE.
Referenced by load_module().
11436 { 11437 int res = -1; 11438 char dir[PATH_MAX]; 11439 snprintf(dir, sizeof(dir), "%s%s/%s/greet", VM_SPOOL_DIR, context, mailbox); 11440 ast_debug(2, "About to try retrieving name file %s\n", dir); 11441 RETRIEVE(dir, -1, mailbox, context); 11442 if (ast_fileexists(dir, NULL, NULL)) { 11443 res = ast_stream_and_wait(chan, dir, AST_DIGIT_ANY); 11444 } 11445 DISPOSE(dir, -1); 11446 return res; 11447 }
| static int sendmail | ( | char * | srcemail, | |
| struct ast_vm_user * | vmu, | |||
| int | msgnum, | |||
| char * | context, | |||
| char * | mailbox, | |||
| const char * | fromfolder, | |||
| char * | cidnum, | |||
| char * | cidname, | |||
| char * | attach, | |||
| char * | attach2, | |||
| char * | format, | |||
| int | duration, | |||
| int | attach_user_voicemail, | |||
| struct ast_channel * | chan, | |||
| const char * | category, | |||
| const char * | flag | |||
| ) | [static] |
Definition at line 4575 of file app_voicemail.c.
References ast_debug, ast_log(), AST_LOG_WARNING, ast_safe_system(), ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_vm_user::email, globalflags, ast_vm_user::mailbox, make_email_file(), strsep(), VM_ATTACH, and vm_mkftemp().
Referenced by forward_message(), and notify_new_message().
04576 { 04577 FILE *p=NULL; 04578 char tmp[80] = "/tmp/astmail-XXXXXX"; 04579 char tmp2[256]; 04580 char *stringp; 04581 04582 if (vmu && ast_strlen_zero(vmu->email)) { 04583 ast_log(AST_LOG_WARNING, "E-mail address missing for mailbox [%s]. E-mail will not be sent.\n", vmu->mailbox); 04584 return(0); 04585 } 04586 04587 /* Mail only the first format */ 04588 format = ast_strdupa(format); 04589 stringp = format; 04590 strsep(&stringp, "|"); 04591 04592 if (!strcmp(format, "wav49")) 04593 format = "WAV"; 04594 ast_debug(3, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH)); 04595 /* Make a temporary file instead of piping directly to sendmail, in case the mail 04596 command hangs */ 04597 if ((p = vm_mkftemp(tmp)) == NULL) { 04598 ast_log(AST_LOG_WARNING, "Unable to launch '%s' (can't create temporary file)\n", mailcmd); 04599 return -1; 04600 } else { 04601 make_email_file(p, srcemail, vmu, msgnum, context, mailbox, fromfolder, cidnum, cidname, attach, attach2, format, duration, attach_user_voicemail, chan, category, 0, flag); 04602 fclose(p); 04603 snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); 04604 ast_safe_system(tmp2); 04605 ast_debug(1, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd); 04606 } 04607 return 0; 04608 }
| static int sendpage | ( | char * | srcemail, | |
| char * | pager, | |||
| int | msgnum, | |||
| char * | context, | |||
| char * | mailbox, | |||
| const char * | fromfolder, | |||
| char * | cidnum, | |||
| char * | cidname, | |||
| int | duration, | |||
| struct ast_vm_user * | vmu, | |||
| const char * | category, | |||
| const char * | flag | |||
| ) | [static] |
Definition at line 4610 of file app_voicemail.c.
References ast_channel_alloc, ast_channel_free(), ast_copy_string(), ast_debug, ast_log(), AST_LOG_WARNING, ast_safe_system(), AST_STATE_DOWN, ast_strftime(), ast_strlen_zero(), fromstring, MAXHOSTNAMELEN, pagerbody, pagerfromstring, pagersubject, pbx_substitute_variables_helper(), prep_email_sub_vars(), vm_mkftemp(), and vmu_tm().
Referenced by notify_new_message().
04611 { 04612 char date[256]; 04613 char host[MAXHOSTNAMELEN] = ""; 04614 char who[256]; 04615 char dur[PATH_MAX]; 04616 char tmp[80] = "/tmp/astmail-XXXXXX"; 04617 char tmp2[PATH_MAX]; 04618 struct ast_tm tm; 04619 FILE *p; 04620 04621 if ((p = vm_mkftemp(tmp)) == NULL) { 04622 ast_log(AST_LOG_WARNING, "Unable to launch '%s' (can't create temporary file)\n", mailcmd); 04623 return -1; 04624 } 04625 gethostname(host, sizeof(host)-1); 04626 if (strchr(srcemail, '@')) 04627 ast_copy_string(who, srcemail, sizeof(who)); 04628 else 04629 snprintf(who, sizeof(who), "%s@%s", srcemail, host); 04630 snprintf(dur, sizeof(dur), "%d:%02d", duration / 60, duration % 60); 04631 ast_strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", vmu_tm(vmu, &tm)); 04632 fprintf(p, "Date: %s\n", date); 04633 04634 if (*pagerfromstring) { 04635 struct ast_channel *ast; 04636 if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { 04637 char *passdata; 04638 int vmlen = strlen(fromstring)*3 + 200; 04639 passdata = alloca(vmlen); 04640 memset(passdata, 0, vmlen); 04641 prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, passdata, vmlen, category, flag); 04642 pbx_substitute_variables_helper(ast, pagerfromstring, passdata, vmlen); 04643 fprintf(p, "From: %s <%s>\n", passdata, who); 04644 ast_channel_free(ast); 04645 } else 04646 ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); 04647 } else 04648 fprintf(p, "From: Asterisk PBX <%s>\n", who); 04649 fprintf(p, "To: %s\n", pager); 04650 if (pagersubject) { 04651 struct ast_channel *ast; 04652 if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { 04653 char *passdata; 04654 int vmlen = strlen(pagersubject) * 3 + 200; 04655 passdata = alloca(vmlen); 04656 memset(passdata, 0, vmlen); 04657 prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, passdata, vmlen, category, flag); 04658 pbx_substitute_variables_helper(ast, pagersubject, passdata, vmlen); 04659 fprintf(p, "Subject: %s\n\n", passdata); 04660 ast_channel_free(ast); 04661 } else 04662 ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); 04663 } else { 04664 if (ast_strlen_zero(flag)) { 04665 fprintf(p, "Subject: New VM\n\n"); 04666 } else { 04667 fprintf(p, "Subject: New %s VM\n\n", flag); 04668 } 04669 } 04670 04671 ast_strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm); 04672 if (pagerbody) { 04673 struct ast_channel *ast; 04674 if ((ast = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", 0, "Substitution/voicemail"))) { 04675 char *passdata; 04676 int vmlen = strlen(pagerbody) * 3 + 200; 04677 passdata = alloca(vmlen); 04678 memset(passdata, 0, vmlen); 04679 prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, passdata, vmlen, category, flag); 04680 pbx_substitute_variables_helper(ast, pagerbody, passdata, vmlen); 04681 fprintf(p, "%s\n", passdata); 04682 ast_channel_free(ast); 04683 } else 04684 ast_log(AST_LOG_WARNING, "Cannot allocate the channel for variables substitution\n"); 04685 } else { 04686 fprintf(p, "New %s long %s msg in box %s\n" 04687 "from %s, on %s", dur, flag, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date); 04688 } 04689 fclose(p); 04690 snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); 04691 ast_safe_system(tmp2); 04692 ast_debug(1, "Sent page to %s with command '%s'\n", pager, mailcmd); 04693 return 0; 04694 }
| static char* show_users_realtime | ( | int | fd, | |
| const char * | context | |||
| ) | [static] |
Definition at line 10216 of file app_voicemail.c.
References ast_category_browse(), ast_cli(), ast_config_destroy(), ast_load_realtime_multientry(), ast_variable_browse(), CLI_FAILURE, CLI_SUCCESS, ast_variable::name, ast_variable::next, SENTINEL, and ast_variable::value.
Referenced by handle_voicemail_show_users().
10217 { 10218 struct ast_config *cfg; 10219 const char *cat = NULL; 10220 10221 if (!(cfg = ast_load_realtime_multientry("voicemail", 10222 "context", context, SENTINEL))) { 10223 return CLI_FAILURE; 10224 } 10225 10226 ast_cli(fd, 10227 "\n" 10228 "=============================================================\n" 10229 "=== Configured Voicemail Users ==============================\n" 10230 "=============================================================\n" 10231 "===\n"); 10232 10233 while ((cat = ast_category_browse(cfg, cat))) { 10234 struct ast_variable *var = NULL; 10235 ast_cli(fd, 10236 "=== Mailbox ...\n" 10237 "===\n"); 10238 for (var = ast_variable_browse(cfg, cat); var; var = var->next) 10239 ast_cli(fd, "=== ==> %s: %s\n", var->name, var->value); 10240 ast_cli(fd, 10241 "===\n" 10242 "=== ---------------------------------------------------------\n" 10243 "===\n"); 10244 } 10245 10246 ast_cli(fd, 10247 "=============================================================\n" 10248 "\n"); 10249 10250 ast_config_destroy(cfg); 10251 10252 return CLI_SUCCESS; 10253 }
| static void start_poll_thread | ( | void | ) | [static] |
Definition at line 10569 of file app_voicemail.c.
References AST_EVENT_IE_END, AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI, ast_event_report_subs(), AST_EVENT_SUB, ast_event_subscribe(), AST_EVENT_UNSUB, ast_pthread_create, mb_poll_thread(), mwi_sub_event_cb(), and mwi_unsub_event_cb().
Referenced by load_config().
10570 { 10571 mwi_sub_sub = ast_event_subscribe(AST_EVENT_SUB, mwi_sub_event_cb, NULL, 10572 AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI, 10573 AST_EVENT_IE_END); 10574 10575 mwi_unsub_sub = ast_event_subscribe(AST_EVENT_UNSUB, mwi_unsub_event_cb, NULL, 10576 AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, AST_EVENT_MWI, 10577 AST_EVENT_IE_END); 10578 10579 if (mwi_sub_sub) 10580 ast_event_report_subs(mwi_sub_sub); 10581 10582 poll_thread_run = 1; 10583 10584 ast_pthread_create(&poll_thread, NULL, mb_poll_thread, NULL); 10585 }
| static void stop_poll_thread | ( | void | ) | [static] |
Definition at line 10587 of file app_voicemail.c.
References ast_cond_signal(), ast_event_unsubscribe(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, and poll_lock.
Referenced by load_config(), and unload_module().
10588 { 10589 poll_thread_run = 0; 10590 10591 if (mwi_sub_sub) { 10592 ast_event_unsubscribe(mwi_sub_sub); 10593 mwi_sub_sub = NULL; 10594 } 10595 10596 if (mwi_unsub_sub) { 10597 ast_event_unsubscribe(mwi_unsub_sub); 10598 mwi_unsub_sub = NULL; 10599 } 10600 10601 ast_mutex_lock(&poll_lock); 10602 ast_cond_signal(&poll_cond); 10603 ast_mutex_unlock(&poll_lock); 10604 10605 pthread_join(poll_thread, NULL); 10606 10607 poll_thread = AST_PTHREADT_NULL; 10608 }
| static char* strip_control_and_high | ( | const char * | input, | |
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Strips control and non 7-bit clean characters from input string.
Definition at line 901 of file app_voicemail.c.
Referenced by make_email_file().
00902 { 00903 char *bufptr = buf; 00904 for (; *input; input++) { 00905 if (*input < 32) { 00906 continue; 00907 } 00908 *bufptr++ = *input; 00909 if (bufptr == buf + buflen - 1) { 00910 break; 00911 } 00912 } 00913 *bufptr = '\0'; 00914 return buf; 00915 }
| static const char* substitute_escapes | ( | const char * | value | ) | [static] |
Definition at line 10733 of file app_voicemail.c.
References ast_log(), AST_LOG_NOTICE, ast_str_append(), ast_str_buffer(), ast_str_reset(), and ast_str_thread_get().
Referenced by load_config().
10734 { 10735 char *current; 10736 10737 /* Add 16 for fudge factor */ 10738 struct ast_str *str = ast_str_thread_get(&ast_str_thread_global_buf, strlen(value) + 16); 10739 10740 ast_str_reset(str); 10741 10742 /* Substitute strings \r, \n, and \t into the appropriate characters */ 10743 for (current = (char *) value; *current; current++) { 10744 if (*current == '\\') { 10745 current++; 10746 if (!*current) { 10747 ast_log(AST_LOG_NOTICE, "Incomplete escape at end of value.\n"); 10748 break; 10749 } 10750 switch (*current) { 10751 case 'r': 10752 ast_str_append(&str, 0, "\r"); 10753 break; 10754 case 'n': 10755 #ifdef IMAP_STORAGE 10756 if (!str->used || str->str[str->used - 1] != '\r') { 10757 ast_str_append(&str, 0, "\r"); 10758 } 10759 #endif 10760 ast_str_append(&str, 0, "\n"); 10761 break; 10762 case 't': 10763 ast_str_append(&str, 0, "\t"); 10764 break; 10765 default: 10766 ast_log(AST_LOG_NOTICE, "Substitution routine does not support this character: \\%c\n", *current); 10767 break; 10768 } 10769 } else { 10770 ast_str_append(&str, 0, "%c", *current); 10771 } 10772 } 10773 10774 return ast_str_buffer(str); 10775 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 11454 of file app_voicemail.c.
References ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_custom_function_unregister(), ast_manager_unregister(), AST_PTHREADT_NULL, ast_taskprocessor_unreference(), ast_uninstall_vm_functions(), ast_unload_realtime(), ast_unregister_application(), cli_voicemail, free_vm_users(), free_vm_zones(), inprocess_container, mailbox_exists_acf, mwi_subscription_tps, and stop_poll_thread().
11455 { 11456 int res; 11457 11458 res = ast_unregister_application(app); 11459 res |= ast_unregister_application(app2); 11460 res |= ast_unregister_application(app3); 11461 res |= ast_unregister_application(app4); 11462 res |= ast_custom_function_unregister(&mailbox_exists_acf); 11463 res |= ast_manager_unregister("VoicemailUsersList"); 11464 ast_cli_unregister_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail)); 11465 ast_uninstall_vm_functions(); 11466 ao2_ref(inprocess_container, -1); 11467 11468 if (poll_thread != AST_PTHREADT_NULL) 11469 stop_poll_thread(); 11470 11471 mwi_subscription_tps = ast_taskprocessor_unreference(mwi_subscription_tps); 11472 ast_unload_realtime("voicemail"); 11473 ast_unload_realtime("voicemail_data"); 11474 11475 free_vm_users(); 11476 free_vm_zones(); 11477 return res; 11478 }
| static int vm_allocate_dh | ( | struct vm_state * | vms, | |
| struct ast_vm_user * | vmu, | |||
| int | count_msg | |||
| ) | [static] |
Definition at line 1553 of file app_voicemail.c.
References ast_calloc, ast_realloc, vm_state::deleted, vm_state::dh_arraysize, vm_state::heard, and ast_vm_user::maxmsg.
Referenced by open_mailbox().
01553 { 01554 01555 int arraysize = (vmu->maxmsg > count_msg ? vmu->maxmsg : count_msg); 01556 if (!vms->dh_arraysize) { 01557 /* initial allocation */ 01558 if (!(vms->deleted = ast_calloc(arraysize, sizeof(int)))) { 01559 return -1; 01560 } 01561 if (!(vms->heard = ast_calloc(arraysize, sizeof(int)))) { 01562 return -1; 01563 } 01564 vms->dh_arraysize = arraysize; 01565 } else if (vms->dh_arraysize < arraysize) { 01566 if (!(vms->deleted = ast_realloc(vms->deleted, arraysize * sizeof(int)))) { 01567 return -1; 01568 } 01569 if (!(vms->heard = ast_realloc(vms->heard, arraysize * sizeof(int)))) { 01570 return -1; 01571 } 01572 memset(vms->deleted, 0, arraysize * sizeof(int)); 01573 memset(vms->heard, 0, arraysize * sizeof(int)); 01574 vms->dh_arraysize = arraysize; 01575 } 01576 01577 return 0; 01578 }
| static 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 | max_logins, | |||
| int | silent | |||
| ) | [static] |
Definition at line 9165 of file app_voicemail.c.
References adsi_begin(), adsi_login(), adsi_password(), ast_copy_string(), ast_debug, ast_log(), AST_LOG_WARNING, AST_MAX_EXTENSION, ast_play_and_wait(), ast_readstring(), ast_stopstream(), ast_streamfile(), ast_strlen_zero(), ast_verb, ast_waitstream(), ast_channel::cid, ast_callerid::cid_num, find_user(), ast_channel::language, ast_vm_user::password, and vm_password.
Referenced by vm_execmain(), and vmauthenticate().
09168 { 09169 int useadsi=0, valid=0, logretries=0; 09170 char password[AST_MAX_EXTENSION]="", *passptr; 09171 struct ast_vm_user vmus, *vmu = NULL; 09172 09173 /* If ADSI is supported, setup login screen */ 09174 adsi_begin(chan, &useadsi); 09175 if (!skipuser && useadsi) 09176 adsi_login(chan); 09177 if (!silent && !skipuser && ast_streamfile(chan, "vm-login", chan->language)) { 09178 ast_log(AST_LOG_WARNING, "Couldn't stream login file\n"); 09179 return -1; 09180 } 09181 09182 /* Authenticate them and get their mailbox/password */ 09183 09184 while (!valid && (logretries < max_logins)) { 09185 /* Prompt for, and read in the username */ 09186 if (!skipuser && ast_readstring(chan, mailbox, mailbox_size - 1, 2000, 10000, "#") < 0) { 09187 ast_log(AST_LOG_WARNING, "Couldn't read username\n"); 09188 return -1; 09189 } 09190 if (ast_strlen_zero(mailbox)) { 09191 if (chan->cid.cid_num) { 09192 ast_copy_string(mailbox, chan->cid.cid_num, mailbox_size); 09193 } else { 09194 ast_verb(3,"Username not entered\n"); 09195 return -1; 09196 } 09197 } 09198 if (useadsi) 09199 adsi_password(chan); 09200 09201 if (!ast_strlen_zero(prefix)) { 09202 char fullusername[80] = ""; 09203 ast_copy_string(fullusername, prefix, sizeof(fullusername)); 09204 strncat(fullusername, mailbox, sizeof(fullusername) - 1 - strlen(fullusername)); 09205 ast_copy_string(mailbox, fullusername, mailbox_size); 09206 } 09207 09208 ast_debug(1, "Before find user for mailbox %s\n",mailbox); 09209 vmu = find_user(&vmus, context, mailbox); 09210 if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) { 09211 /* saved password is blank, so don't bother asking */ 09212 password[0] = '\0'; 09213 } else { 09214 if (ast_streamfile(chan, vm_password, chan->language)) { 09215 ast_log(AST_LOG_WARNING, "Unable to stream password file\n"); 09216 return -1; 09217 } 09218 if (ast_readstring(chan, password, sizeof(password) - 1, 2000, 10000, "#") < 0) { 09219 ast_log(AST_LOG_WARNING, "Unable to read password\n"); 09220 return -1; 09221 } 09222 } 09223 09224 if (vmu) { 09225 passptr = vmu->password; 09226 if (passptr[0] == '-') passptr++; 09227 } 09228 if (vmu && !strcmp(passptr, password)) 09229 valid++; 09230 else { 09231 ast_verb(3, "Incorrect password '%s' for user '%s' (context = %s)\n", password, mailbox, context ? context : "default"); 09232 if (!ast_strlen_zero(prefix)) 09233 mailbox[0] = '\0'; 09234 } 09235 logretries++; 09236 if (!valid) { 09237 if (skipuser || logretries >= max_logins) { 09238 if (ast_streamfile(chan, "vm-incorrect", chan->language)) { 09239 ast_log(AST_LOG_WARNING, "Unable to stream incorrect message\n"); 09240 return -1; 09241 } 09242 } else { 09243 if (useadsi) 09244 adsi_login(chan); 09245 if (ast_streamfile(chan, "vm-incorrect-mailbox", chan->language)) { 09246 ast_log(AST_LOG_WARNING, "Unable to stream incorrect mailbox message\n"); 09247 return -1; 09248 } 09249 } 09250 if (ast_waitstream(chan, "")) /* Channel is hung up */ 09251 return -1; 09252 } 09253 } 09254 if (!valid && (logretries >= max_logins)) { 09255 ast_stopstream(chan); 09256 ast_play_and_wait(chan, "vm-goodbye"); 09257 return -1; 09258 } 09259 if (vmu && !skipuser) { 09260 memcpy(res_vmu, vmu, sizeof(struct ast_vm_user)); 09261 } 09262 return 0; 09263 }
| static int vm_box_exists | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 10116 of file app_voicemail.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_LOG_ERROR, AST_LOG_WARNING, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), find_user(), mbox(), and pbx_builtin_setvar_helper().
Referenced by load_module().
10117 { 10118 struct ast_vm_user svm; 10119 char *context, *box; 10120 AST_DECLARE_APP_ARGS(args, 10121 AST_APP_ARG(mbox); 10122 AST_APP_ARG(options); 10123 ); 10124 static int dep_warning = 0; 10125 10126 if (ast_strlen_zero(data)) { 10127 ast_log(AST_LOG_ERROR, "MailboxExists requires an argument: (vmbox[@context][|options])\n"); 10128 return -1; 10129 } 10130 10131 if (!dep_warning) { 10132 dep_warning = 1; 10133 ast_log(AST_LOG_WARNING, "MailboxExists is deprecated. Please use ${MAILBOX_EXISTS(%s)} instead.\n", (char *)data); 10134 } 10135 10136 box = ast_strdupa(data); 10137 10138 AST_STANDARD_APP_ARGS(args, box); 10139 10140 if (args.options) { 10141 } 10142 10143 if ((context = strchr(args.mbox, '@'))) { 10144 *context = '\0'; 10145 context++; 10146 } 10147 10148 if (find_user(&svm, context, args.mbox)) { 10149 pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "SUCCESS"); 10150 } else 10151 pbx_builtin_setvar_helper(chan, "VMBOXEXISTSSTATUS", "FAILED"); 10152 10153 return 0; 10154 }
| static int vm_browse_messages | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Top level method to invoke the language variant vm_browse_messages_XX function.
| chan | The channel for the current user. We read the language property from this. | |
| vms | passed into the language-specific vm_browse_messages function. | |
| vmu | passed into the language-specific vm_browse_messages function. |
Definition at line 9146 of file app_voicemail.c.
References ast_channel::language, vm_browse_messages_en(), vm_browse_messages_es(), vm_browse_messages_gr(), vm_browse_messages_he(), vm_browse_messages_it(), vm_browse_messages_pt(), and vm_browse_messages_zh().
Referenced by vm_execmain().
09147 { 09148 if (!strncasecmp(chan->language, "es", 2)) { /* SPANISH */ 09149 return vm_browse_messages_es(chan, vms, vmu); 09150 } else if (!strncasecmp(chan->language, "gr", 2)) { /* GREEK */ 09151 return vm_browse_messages_gr(chan, vms, vmu); 09152 } else if (!strncasecmp(chan->language, "he", 2)) { /* HEBREW */ 09153 return vm_browse_messages_he(chan, vms, vmu); 09154 } else if (!strncasecmp(chan->language, "it", 2)) { /* ITALIAN */ 09155 return vm_browse_messages_it(chan, vms, vmu); 09156 } else if (!strncasecmp(chan->language, "pt", 2)) { /* PORTUGUESE */ 09157 return vm_browse_messages_pt(chan, vms, vmu); 09158 } else if (!strncasecmp(chan->language, "zh", 2)) { 09159 return vm_browse_messages_zh(chan, vms, vmu); /* CHINESE (Taiwan) */ 09160 } else { /* Default to English syntax */ 09161 return vm_browse_messages_en(chan, vms, vmu); 09162 } 09163 }
| static int vm_browse_messages_en | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Default English syntax for 'You have N messages' greeting.
| chan | ||
| vms | ||
| vmu |
Definition at line 9009 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().
09010 { 09011 int cmd=0; 09012 09013 if (vms->lastmsg > -1) { 09014 cmd = play_message(chan, vmu, vms); 09015 } else { 09016 cmd = ast_play_and_wait(chan, "vm-youhave"); 09017 if (!cmd) 09018 cmd = ast_play_and_wait(chan, "vm-no"); 09019 if (!cmd) { 09020 snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox); 09021 cmd = ast_play_and_wait(chan, vms->fn); 09022 } 09023 if (!cmd) 09024 cmd = ast_play_and_wait(chan, "vm-messages"); 09025 } 09026 return cmd; 09027 }
| static int vm_browse_messages_es | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Spanish syntax for 'You have N messages' greeting.
| chan | ||
| vms | ||
| vmu |
Definition at line 9063 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().
09064 { 09065 int cmd=0; 09066 09067 if (vms->lastmsg > -1) { 09068 cmd = play_message(chan, vmu, vms); 09069 } else { 09070 cmd = ast_play_and_wait(chan, "vm-youhaveno"); 09071 if (!cmd) 09072 cmd = ast_play_and_wait(chan, "vm-messages"); 09073 if (!cmd) { 09074 snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox); 09075 cmd = ast_play_and_wait(chan, vms->fn); 09076 } 09077 } 09078 return cmd; 09079 }
| static int vm_browse_messages_gr | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Greek syntax for 'You have N messages' greeting.
| chan | ||
| vms | ||
| vmu |
Definition at line 8957 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().
08958 { 08959 int cmd=0; 08960 08961 if (vms->lastmsg > -1) { 08962 cmd = play_message(chan, vmu, vms); 08963 } else { 08964 cmd = ast_play_and_wait(chan, "vm-youhaveno"); 08965 if (!strcasecmp(vms->vmbox, "vm-INBOX") ||!strcasecmp(vms->vmbox, "vm-Old")){ 08966 if (!cmd) { 08967 snprintf(vms->fn, sizeof(vms->fn), "vm-%ss", vms->curbox); 08968 cmd = ast_play_and_wait(chan, vms->fn); 08969 } 08970 if (!cmd) 08971 cmd = ast_play_and_wait(chan, "vm-messages"); 08972 } else { 08973 if (!cmd) 08974 cmd = ast_play_and_wait(chan, "vm-messages"); 08975 if (!cmd) { 08976 snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox); 08977 cmd = ast_play_and_wait(chan, vms->fn); 08978 } 08979 } 08980 } 08981 return cmd; 08982 }
| static int vm_browse_messages_he | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Definition at line 8985 of file app_voicemail.c.
References ast_play_and_wait(), vm_state::fn, vm_state::lastmsg, and play_message().
Referenced by vm_browse_messages().
08986 { 08987 int cmd = 0; 08988 08989 if (vms->lastmsg > -1) { 08990 cmd = play_message(chan, vmu, vms); 08991 } else { 08992 if (!strcasecmp(vms->fn, "INBOX")) { 08993 cmd = ast_play_and_wait(chan, "vm-nonewmessages"); 08994 } else { 08995 cmd = ast_play_and_wait(chan, "vm-nomessages"); 08996 } 08997 } 08998 return cmd; 08999 }
| static int vm_browse_messages_it | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Italian syntax for 'You have N messages' greeting.
| chan | ||
| vms | ||
| vmu |
Definition at line 9037 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().
09038 { 09039 int cmd=0; 09040 09041 if (vms->lastmsg > -1) { 09042 cmd = play_message(chan, vmu, vms); 09043 } else { 09044 cmd = ast_play_and_wait(chan, "vm-no"); 09045 if (!cmd) 09046 cmd = ast_play_and_wait(chan, "vm-message"); 09047 if (!cmd) { 09048 snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox); 09049 cmd = ast_play_and_wait(chan, vms->fn); 09050 } 09051 } 09052 return cmd; 09053 }
| static int vm_browse_messages_pt | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Portuguese syntax for 'You have N messages' greeting.
| chan | ||
| vms | ||
| vmu |
Definition at line 9089 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().
09090 { 09091 int cmd=0; 09092 09093 if (vms->lastmsg > -1) { 09094 cmd = play_message(chan, vmu, vms); 09095 } else { 09096 cmd = ast_play_and_wait(chan, "vm-no"); 09097 if (!cmd) { 09098 snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox); 09099 cmd = ast_play_and_wait(chan, vms->fn); 09100 } 09101 if (!cmd) 09102 cmd = ast_play_and_wait(chan, "vm-messages"); 09103 } 09104 return cmd; 09105 }
| static int vm_browse_messages_zh | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| struct ast_vm_user * | vmu | |||
| ) | [static] |
Chinese (Taiwan)syntax for 'You have N messages' greeting.
| chan | ||
| vms | ||
| vmu |
Definition at line 9115 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().
09116 { 09117 int cmd=0; 09118 09119 if (vms->lastmsg > -1) { 09120 cmd = play_message(chan, vmu, vms); 09121 } else { 09122 cmd = ast_play_and_wait(chan, "vm-you"); 09123 if (!cmd) 09124 cmd = ast_play_and_wait(chan, "vm-haveno"); 09125 if (!cmd) 09126 cmd = ast_play_and_wait(chan, "vm-messages"); 09127 if (!cmd) { 09128 snprintf(vms->fn, sizeof(vms->fn), "vm-%s", vms->curbox); 09129 cmd = ast_play_and_wait(chan, vms->fn); 09130 } 09131 } 09132 return cmd; 09133 }
| static void vm_change_password | ( | struct ast_vm_user * | vmu, | |
| const char * | newpassword | |||
| ) | [static] |
The handler for the change password option.
| vmu | The voicemail user to work with. | |
| newpassword | The new password (that has been gathered from the appropriate prompting). This is called when a new user logs in for the first time and the option to force them to change their password is set. It is also called when the user wants to change their password from menu option '5' on the mailbox options menu. |
Definition at line 1366 of file app_voicemail.c.
References ast_category_browse(), ast_category_get(), ast_config_load, ast_config_text_file_save(), ast_copy_string(), ast_debug, ast_log(), AST_LOG_WARNING, ast_variable_append(), ast_variable_new(), ast_variable_retrieve(), ast_variable_update(), change_password_realtime(), CONFIG_FLAG_WITHCOMMENTS, CONFIG_STATUS_FILEINVALID, ast_vm_user::context, ast_vm_user::mailbox, ast_vm_user::password, reset_user_pw(), var, and VOICEMAIL_CONFIG.
Referenced by vm_newuser(), and vm_options().
01367 { 01368 struct ast_config *cfg=NULL; 01369 struct ast_variable *var=NULL; 01370 struct ast_category *cat=NULL; 01371 char *category=NULL, *value=NULL, *new=NULL; 01372 const char *tmp=NULL; 01373 struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS }; 01374 if (!change_password_realtime(vmu, newpassword)) 01375 return; 01376 01377 /* check voicemail.conf */ 01378 if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) { 01379 while ((category = ast_category_browse(cfg, category))) { 01380 if (!strcasecmp(category, vmu->context)) { 01381 if (!(tmp = ast_variable_retrieve(cfg, category, vmu->mailbox))) { 01382 ast_log(AST_LOG_WARNING, "We could not find the mailbox.\n"); 01383 break; 01384 } 01385 value = strstr(tmp,","); 01386 if (!value) { 01387 new = alloca(strlen(newpassword)+1); 01388 sprintf(new, "%s", newpassword); 01389 } else { 01390 new = alloca((strlen(value)+strlen(newpassword)+1)); 01391 sprintf(new,"%s%s", newpassword, value); 01392 } 01393 if (!(cat = ast_category_get(cfg, category))) { 01394 ast_log(AST_LOG_WARNING, "Failed to get category structure.\n"); 01395 break; 01396 } 01397 ast_variable_update(cat, vmu->mailbox, new, NULL, 0); 01398 } 01399 } 01400 /* save the results */ 01401 reset_user_pw(vmu->context, vmu->mailbox, newpassword); 01402 ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); 01403 ast_config_text_file_save(VOICEMAIL_CONFIG, cfg, "AppVoicemail"); 01404 } 01405 category = NULL; 01406 var = NULL; 01407 /* check users.conf and update the password stored for the mailbox*/ 01408 /* if no vmsecret entry exists create one. */ 01409 if ((cfg = ast_config_load("users.conf", config_flags)) && cfg != CONFIG_STATUS_FILEINVALID) { 01410 ast_debug(4, "we are looking for %s\n", vmu->mailbox); 01411 while ((category = ast_category_browse(cfg, category))) { 01412 ast_debug(4, "users.conf: %s\n", category); 01413 if (!strcasecmp(category, vmu->mailbox)) { 01414 if (!(tmp = ast_variable_retrieve(cfg, category, "vmsecret"))) { 01415 ast_debug(3, "looks like we need to make vmsecret!\n"); 01416 var = ast_variable_new("vmsecret", newpassword, ""); 01417 } 01418 new = alloca(strlen(newpassword)+1); 01419 sprintf(new, "%s", newpassword); 01420 if (!(cat = ast_category_get(cfg, category))) { 01421 ast_debug(4, "failed to get category!\n"); 01422 break; 01423 } 01424 if (!var) 01425 ast_variable_update(cat, "vmsecret", new, NULL, 0); 01426 else 01427 ast_variable_append(cat, var); 01428 } 01429 } 01430 /* save the results and clean things up */ 01431 reset_user_pw(vmu->context, vmu->mailbox, newpassword); 01432 ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); 01433 ast_config_text_file_save("users.conf", cfg, "AppVoicemail"); 01434 } 01435 }
| static void vm_change_password_shell | ( | struct ast_vm_user * | vmu, | |
| char * | newpassword | |||
| ) | [static] |
Definition at line 1437 of file app_voicemail.c.
References ast_copy_string(), ast_safe_system(), buf, ast_vm_user::context, ast_vm_user::mailbox, ast_vm_user::password, and reset_user_pw().
Referenced by vm_newuser(), and vm_options().
01438 { 01439 char buf[255]; 01440 snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->mailbox,newpassword); 01441 if (!ast_safe_system(buf)) { 01442 ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); 01443 /* Reset the password in memory, too */ 01444 reset_user_pw(vmu->context, vmu->mailbox, newpassword); 01445 } 01446 }
| static char* vm_check_password_shell | ( | char * | command, | |
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 1059 of file app_voicemail.c.
References AST_APP_ARG, ast_close_fds_above_n(), AST_DECLARE_APP_ARGS, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_safe_fork(), ast_strdupa, errno, and LOG_WARNING.
Referenced by check_password().
01060 { 01061 int fds[2], pid = 0; 01062 01063 memset(buf, 0, len); 01064 01065 if (pipe(fds)) { 01066 snprintf(buf, len, "FAILURE: Pipe failed: %s", strerror(errno)); 01067 } else { 01068 /* good to go*/ 01069 pid = ast_safe_fork(0); 01070 01071 if (pid < 0) { 01072 /* ok maybe not */ 01073 close(fds[0]); 01074 close(fds[1]); 01075 snprintf(buf, len, "FAILURE: Fork failed"); 01076 } else if (pid) { 01077 /* parent */ 01078 close(fds[1]); 01079 if (read(fds[0], buf, len) < 0) { 01080 ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno)); 01081 } 01082 close(fds[0]); 01083 } else { 01084 /* child */ 01085 AST_DECLARE_APP_ARGS(arg, 01086 AST_APP_ARG(v)[20]; 01087 ); 01088 char *mycmd = ast_strdupa(command); 01089 01090 close(fds[0]); 01091 dup2(fds[1], STDOUT_FILENO); 01092 close(fds[1]); 01093 ast_close_fds_above_n(STDOUT_FILENO); 01094 01095 AST_NONSTANDARD_APP_ARGS(arg, mycmd, ' '); 01096 01097 execv(arg.v[0], arg.v); 01098 printf("FAILURE: %s", strerror(errno)); 01099 _exit(0); 01100 } 01101 } 01102 return buf; 01103 }
| static int vm_delete | ( | char * | file | ) | [static] |
Removes the voicemail sound and information file.
| file | The path to the sound file. This will be the the folder and message index, without the extension. |
Definition at line 3911 of file app_voicemail.c.
References ast_check_realtime(), ast_destroy_realtime(), ast_filedelete(), and SENTINEL.
Referenced by copy_message(), and notify_new_message().
03912 { 03913 char *txt; 03914 int txtsize = 0; 03915 03916 txtsize = (strlen(file) + 5)*sizeof(char); 03917 txt = alloca(txtsize); 03918 /* Sprintf here would safe because we alloca'd exactly the right length, 03919 * but trying to eliminate all sprintf's anyhow 03920 */ 03921 if (ast_check_realtime("voicemail_data")) { 03922 ast_destroy_realtime("voicemail_data", "filename", file, SENTINEL); 03923 } 03924 snprintf(txt, txtsize, "%s.txt", file); 03925 unlink(txt); 03926 return ast_filedelete(file, NULL); 03927 }
| static int vm_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 9976 of file app_voicemail.c.
References ast_channel::_state, ast_answer(), AST_APP_ARG, ast_app_getdata(), ast_app_parse_options(), ast_copy_flags, AST_DECLARE_APP_ARGS, ast_log(), AST_LOG_ERROR, AST_LOG_WARNING, ast_play_and_wait(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), ast_test_flag, ERROR_LOCK_PATH, leave_vm_options::exitcontext, leave_voicemail(), OPERATOR_EXIT, OPT_ARG_ARRAY_SIZE, OPT_ARG_DTMFEXIT, OPT_ARG_RECORDGAIN, OPT_BUSY_GREETING, OPT_DTMFEXIT, OPT_MESSAGE_PRIORITY, OPT_MESSAGE_Urgent, OPT_RECORDGAIN, OPT_SILENT, OPT_UNAVAIL_GREETING, pbx_builtin_setvar_helper(), leave_vm_options::record_gain, and vm_app_options.
Referenced by load_module(), and play_record_review().
09977 { 09978 int res = 0; 09979 char *tmp; 09980 struct leave_vm_options leave_options; 09981 struct ast_flags flags = { 0 }; 09982 char *opts[OPT_ARG_ARRAY_SIZE]; 09983 AST_DECLARE_APP_ARGS(args, 09984 AST_APP_ARG(argv0); 09985 AST_APP_ARG(argv1); 09986 ); 09987 09988 memset(&leave_options, 0, sizeof(leave_options)); 09989 09990 if (chan->_state != AST_STATE_UP) 09991 ast_answer(chan); 09992 09993 if (!ast_strlen_zero(data)) { 09994 tmp = ast_strdupa(data); 09995 AST_STANDARD_APP_ARGS(args, tmp); 09996 if (args.argc == 2) { 09997 if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1)) 09998 return -1; 09999 ast_copy_flags(&leave_options, &flags, OPT_SILENT | OPT_BUSY_GREETING | OPT_UNAVAIL_GREETING | OPT_MESSAGE_Urgent | OPT_MESSAGE_PRIORITY | OPT_DTMFEXIT); 10000 if (ast_test_flag(&flags, OPT_RECORDGAIN)) { 10001 int gain; 10002 10003 if (sscanf(opts[OPT_ARG_RECORDGAIN], "%30d", &gain) != 1) { 10004 ast_log(AST_LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]); 10005 return -1; 10006 } else { 10007 leave_options.record_gain = (signed char) gain; 10008 } 10009 } 10010 if (ast_test_flag(&flags, OPT_DTMFEXIT)) { 10011 if (!ast_strlen_zero(opts[OPT_ARG_DTMFEXIT])) 10012 leave_options.exitcontext = opts[OPT_ARG_DTMFEXIT]; 10013 } 10014 } 10015 } else { 10016 char temp[256]; 10017 res = ast_app_getdata(chan, "vm-whichbox", temp, sizeof(temp) - 1, 0); 10018 if (res < 0) 10019 return res; 10020 if (ast_strlen_zero(temp)) 10021 return 0; 10022 args.argv0 = ast_strdupa(temp); 10023 } 10024 10025 res = leave_voicemail(chan, args.argv0, &leave_options); 10026 if (res == 't') { 10027 ast_play_and_wait(chan, "vm-goodbye"); 10028 res = 0; 10029 } 10030 10031 if (res == OPERATOR_EXIT) { 10032 res = 0; 10033 } 10034 10035 if (res == ERROR_LOCK_PATH) { 10036 ast_log(AST_LOG_ERROR, "Could not leave voicemail. The path is already locked.\n"); 10037 pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); 10038 res = 0; 10039 } 10040 10041 return res; 10042 }
| static int vm_execmain | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 9265 of file app_voicemail.c.
References ast_channel::_state, adsi_begin(), adsi_delete(), adsi_folders(), adsi_goodbye(), adsi_message(), adsi_status(), adsi_status2(), advanced_options(), ast_adsi_unload_session, ast_answer(), AST_APP_ARG, ast_app_inboxcount2(), ast_app_parse_options(), ast_calloc, ast_copy_string(), ast_debug, AST_DECLARE_APP_ARGS, ast_free, ast_log(), AST_LOG_ERROR, AST_LOG_WARNING, ast_mutex_lock(), ast_mutex_unlock(), ast_play_and_wait(), ast_set_flag, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_string_field_set, ast_strlen_zero(), ast_test_flag, ast_verb, ast_waitfordigit(), ast_vm_user::callback, close_mailbox(), ast_vm_user::context, vm_state::context, vm_state::curdir, vm_state::curmsg, vm_state::deleted, dialout(), ast_vm_user::dialout, ERROR_LOCK_PATH, EVENT_FLAG_CALL, find_user(), vm_state::fn, forward_message(), free_user(), get_folder2(), globalflags, has_voicemail(), vm_state::heard, ast_channel::language, language, ast_vm_user::language, vm_state::lastmsg, ast_vm_user::mailbox, make_file(), manager_event, ast_vm_user::maxmsg, mbox(), NEW_FOLDER, vm_state::newmessages, OLD_FOLDER, vm_state::oldmessages, open_mailbox(), OPERATOR_EXIT, OPT_ARG_ARRAY_SIZE, OPT_ARG_PLAYFOLDER, OPT_ARG_RECORDGAIN, OPT_AUTOPLAY, OPT_PREPEND_MAILBOX, OPT_RECORDGAIN, OPT_SILENT, parse(), ast_vm_user::password, play_message(), queue_mwi_event(), vm_state::repeats, run_externnotify(), save_to_folder(), say_and_wait(), vm_state::starting, vm_state::urgentmessages, vm_state::username, vm_app_options, vm_authenticate(), vm_browse_messages(), VM_FORCEGREET, VM_FORCENAME, vm_instructions(), vm_intro(), VM_MESSAGEWRAP, vm_newuser(), vm_options(), vm_play_folder_name(), VM_SKIPAFTERCMD, VM_SVMAIL, and vm_state::vmbox.
Referenced by load_module().
09266 { 09267 /* XXX This is, admittedly, some pretty horrendous code. For some 09268 reason it just seemed a lot easier to do with GOTO's. I feel 09269 like I'm back in my GWBASIC days. XXX */ 09270 int res=-1; 09271 int cmd=0; 09272 int valid = 0; 09273 char prefixstr[80] =""; 09274 char ext_context[256]=""; 09275 int box; 09276 int useadsi = 0; 09277 int skipuser = 0; 09278 struct vm_state vms; 09279 struct ast_vm_user *vmu = NULL, vmus; 09280 char *context=NULL; 09281 int silentexit = 0; 09282 struct ast_flags flags = { 0 }; 09283 signed char record_gain = 0; 09284 int play_auto = 0; 09285 int play_folder = 0; 09286 int in_urgent = 0; 09287 #ifdef IMAP_STORAGE 09288 int deleted = 0; 09289 #endif 09290 09291 /* Add the vm_state to the active list and keep it active */ 09292 memset(&vms, 0, sizeof(vms)); 09293 09294 vms.lastmsg = -1; 09295 09296 memset(&vmus, 0, sizeof(vmus)); 09297 09298 if (chan->_state != AST_STATE_UP) { 09299 ast_debug(1, "Before ast_answer\n"); 09300 ast_answer(chan); 09301 } 09302 09303 if (!ast_strlen_zero(data)) { 09304 char *opts[OPT_ARG_ARRAY_SIZE]; 09305 char *parse; 09306 AST_DECLARE_APP_ARGS(args, 09307 AST_APP_ARG(argv0); 09308 AST_APP_ARG(argv1); 09309 ); 09310 09311 parse = ast_strdupa(data); 09312 09313 AST_STANDARD_APP_ARGS(args, parse); 09314 09315 if (args.argc == 2) { 09316 if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1)) 09317 return -1; 09318 if (ast_test_flag(&flags, OPT_RECORDGAIN)) { 09319 int gain; 09320 if (!ast_strlen_zero(opts[OPT_ARG_RECORDGAIN])) { 09321 if (sscanf(opts[OPT_ARG_RECORDGAIN], "%30d", &gain) != 1) { 09322 ast_log(AST_LOG_WARNING, "Invalid value '%s' provided for record gain option\n", opts[OPT_ARG_RECORDGAIN]); 09323 return -1; 09324 } else { 09325 record_gain = (signed char) gain; 09326 } 09327 } else { 09328 ast_log(AST_LOG_WARNING, "Invalid Gain level set with option g\n"); 09329 } 09330 } 09331 if (ast_test_flag(&flags, OPT_AUTOPLAY) ) { 09332 play_auto = 1; 09333 if (opts[OPT_ARG_PLAYFOLDER]) { 09334 if (sscanf(opts[OPT_ARG_PLAYFOLDER], "%30d", &play_folder) != 1) { 09335 ast_log(AST_LOG_WARNING, "Invalid value '%s' provided for folder autoplay option\n", opts[OPT_ARG_PLAYFOLDER]); 09336 } 09337 } else { 09338 ast_log(AST_LOG_WARNING, "Invalid folder set with option a\n"); 09339 } 09340 if ( play_folder > 9 || play_folder < 0) { 09341 ast_log(AST_LOG_WARNING, "Invalid value '%d' provided for folder autoplay option\n", play_folder); 09342 play_folder = 0; 09343 } 09344 } 09345 } else { 09346 /* old style options parsing */ 09347 while (*(args.argv0)) { 09348 if (*(args.argv0) == 's') 09349 ast_set_flag(&flags, OPT_SILENT); 09350 else if (*(args.argv0) == 'p') 09351 ast_set_flag(&flags, OPT_PREPEND_MAILBOX); 09352 else 09353 break; 09354 (args.argv0)++; 09355 } 09356 09357 } 09358 09359 valid = ast_test_flag(&flags, OPT_SILENT); 09360 09361 if ((context = strchr(args.argv0, '@'))) 09362 *context++ = '\0'; 09363 09364 if (ast_test_flag(&flags, OPT_PREPEND_MAILBOX)) 09365 ast_copy_string(prefixstr, args.argv0, sizeof(prefixstr)); 09366 else 09367 ast_copy_string(vms.username, args.argv0, sizeof(vms.username)); 09368 09369 if (!ast_strlen_zero(vms.username) && (vmu = find_user(&vmus, context ,vms.username))) 09370 skipuser++; 09371 else 09372 valid = 0; 09373 } 09374 09375 if (!valid) 09376 res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0); 09377 09378 ast_debug(1, "After vm_authenticate\n"); 09379 if (!res) { 09380 valid = 1; 09381 if (!skipuser) 09382 vmu = &vmus; 09383 } else { 09384 res = 0; 09385 } 09386 09387 /* If ADSI is supported, setup login screen */ 09388 adsi_begin(chan, &useadsi); 09389 09390 if (!valid) { 09391 goto out; 09392 } 09393 09394 #ifdef IMAP_STORAGE 09395 pthread_once(&ts_vmstate.once, ts_vmstate.key_init); 09396 pthread_setspecific(ts_vmstate.key, &vms); 09397 09398 vms.interactive = 1; 09399 vms.updated = 1; 09400 if (vmu) 09401 ast_copy_string(vms.context, vmu->context, sizeof(vms.context)); 09402 vmstate_insert(&vms); 09403 init_vm_state(&vms); 09404 #endif 09405 if (!(vms.deleted = ast_calloc(vmu->maxmsg, sizeof(int)))) { 09406 ast_log(AST_LOG_ERROR, "Could not allocate memory for deleted message storage!\n"); 09407 cmd = ast_play_and_wait(chan, "an-error-has-occured"); 09408 return -1; 09409 } 09410 if (!(vms.heard = ast_calloc(vmu->maxmsg, sizeof(int)))) { 09411 ast_log(AST_LOG_ERROR, "Could not allocate memory for heard message storage!\n"); 09412 cmd = ast_play_and_wait(chan, "an-error-has-occured"); 09413 return -1; 09414 } 09415 09416 /* Set language from config to override channel language */ 09417 if (!ast_strlen_zero(vmu->language)) 09418 ast_string_field_set(chan, language, vmu->language); 09419 09420 /* Retrieve urgent, old and new message counts */ 09421 ast_debug(1, "Before open_mailbox\n"); 09422 res = open_mailbox(&vms, vmu, OLD_FOLDER); /* Count all messages, even Urgent */ 09423 if (res < 0) 09424 goto out; 09425 vms.oldmessages = vms.lastmsg + 1; 09426 ast_debug(1, "Number of old messages: %d\n",vms.oldmessages); 09427 /* check INBOX */ 09428 res = open_mailbox(&vms, vmu, NEW_FOLDER); 09429 if (res < 0) 09430 goto out; 09431 vms.newmessages = vms.lastmsg + 1; 09432 ast_debug(1, "Number of new messages: %d\n",vms.newmessages); 09433 /* Start in Urgent */ 09434 in_urgent = 1; 09435 res = open_mailbox(&vms, vmu, 11); /*11 is the Urgent folder */ 09436 if (res < 0) 09437 goto out; 09438 vms.urgentmessages = vms.lastmsg + 1; 09439 ast_debug(1, "Number of urgent messages: %d\n",vms.urgentmessages); 09440 09441 /* Select proper mailbox FIRST!! */ 09442 if (play_auto) { 09443 if (vms.urgentmessages) { 09444 in_urgent = 1; 09445 res = open_mailbox(&vms, vmu, 11); 09446 } else { 09447 in_urgent = 0; 09448 res = open_mailbox(&vms, vmu, play_folder); 09449 } 09450 if (res < 0) 09451 goto out; 09452 09453 /* If there are no new messages, inform the user and hangup */ 09454 if (vms.lastmsg == -1) { 09455 in_urgent = 0; 09456 cmd = vm_browse_messages(chan, &vms, vmu); 09457 res = 0; 09458 goto out; 09459 } 09460 } else { 09461 if (!vms.newmessages && !vms.urgentmessages && vms.oldmessages) { 09462 /* If we only have old messages start here */ 09463 res = open_mailbox(&vms, vmu, OLD_FOLDER); /* Count all messages, even Urgent */ 09464 in_urgent = 0; 09465 play_folder = 1; 09466 if (res < 0) 09467 goto out; 09468 } else if (!vms.urgentmessages && vms.newmessages) { 09469 /* If we have new messages but none are urgent */ 09470 in_urgent = 0; 09471 res = open_mailbox(&vms, vmu, NEW_FOLDER); 09472 if (res < 0) 09473 goto out; 09474 } 09475 } 09476 09477 if (useadsi) 09478 adsi_status(chan, &vms); 09479 res = 0; 09480 09481 /* Check to see if this is a new user */ 09482 if (!strcasecmp(vmu->mailbox, vmu->password) && 09483 (ast_test_flag(vmu, VM_FORCENAME | VM_FORCEGREET))) { 09484 if (ast_play_and_wait(chan, "vm-newuser") == -1) 09485 ast_log(AST_LOG_WARNING, "Couldn't stream new user file\n"); 09486 cmd = vm_newuser(chan, vmu, &vms, vmfmts, record_gain); 09487 if ((cmd == 't') || (cmd == '#')) { 09488 /* Timeout */ 09489 res = 0; 09490 goto out; 09491 } else if (cmd < 0) { 09492 /* Hangup */ 09493 res = -1; 09494 goto out; 09495 } 09496 } 09497 #ifdef IMAP_STORAGE 09498 ast_debug(3, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit); 09499 if (vms.quota_limit && vms.quota_usage >= vms.quota_limit) { 09500 ast_debug(1, "*** QUOTA EXCEEDED!!\n"); 09501 cmd = ast_play_and_wait(chan, "vm-mailboxfull"); 09502 } 09503 ast_debug(3, "Checking quotas: User has %d messages and limit is %d.\n",(vms.newmessages + vms.oldmessages),vmu->maxmsg); 09504 if ((vms.newmessages + vms.oldmessages) >= vmu->maxmsg) { 09505 ast_log(AST_LOG_WARNING, "No more messages possible. User has %d messages and limit is %d.\n", (vms.newmessages + vms.oldmessages), vmu->maxmsg); 09506 cmd = ast_play_and_wait(chan, "vm-mailboxfull"); 09507 } 09508 #endif 09509 if (play_auto) { 09510 cmd = '1'; 09511 } else { 09512 cmd = vm_intro(chan, vmu, &vms); 09513 } 09514 09515 vms.repeats = 0; 09516 vms.starting = 1; 09517 while ((cmd > -1) && (cmd != 't') && (cmd != '#')) { 09518 /* Run main menu */ 09519 switch (cmd) { 09520 case '1': /* First message */ 09521 vms.curmsg = 0; 09522 /* Fall through */ 09523 case '5': /* Play current message */ 09524 cmd = vm_browse_messages(chan, &vms, vmu); 09525 break; 09526 case '2': /* Change folders */ 09527 if (useadsi) 09528 adsi_folders(chan, 0, "Change to folder..."); 09529 cmd = get_folder2(chan, "vm-changeto", 0); 09530 if (cmd == '#') { 09531 cmd = 0; 09532 } else if (cmd > 0) { 09533 cmd = cmd - '0'; 09534 res = close_mailbox(&vms, vmu); 09535 if (res == ERROR_LOCK_PATH) 09536 goto out; 09537 /* If folder is not urgent, set in_urgent to zero! */ 09538 if (cmd != 11) in_urgent = 0; 09539 res = open_mailbox(&vms, vmu, cmd); 09540 if (res < 0) 09541 goto out; 09542 play_folder = cmd; 09543 cmd = 0; 09544 } 09545 if (useadsi) 09546 adsi_status2(chan, &vms); 09547 09548 if (!cmd) 09549 cmd = vm_play_folder_name(chan, vms.vmbox); 09550 09551 vms.starting = 1; 09552 break; 09553 case '3': /* Advanced options */ 09554 cmd = 0; 09555 vms.repeats = 0; 09556 while ((cmd > -1) && (cmd != 't') && (cmd != '#')) { 09557 switch (cmd) { 09558 case '1': /* Reply */ 09559 if (vms.lastmsg > -1 && !vms.starting) { 09560 cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 1, record_gain); 09561 if (cmd == ERROR_LOCK_PATH || cmd == OPERATOR_EXIT) { 09562 res = cmd; 09563 goto out; 09564 } 09565 } else 09566 cmd = ast_play_and_wait(chan, "vm-sorry"); 09567 cmd = 't'; 09568 break; 09569 case '2': /* Callback */ 09570 if (!vms.starting) 09571 ast_verb(3, "Callback Requested\n"); 09572 if (!ast_strlen_zero(vmu->callback) && vms.lastmsg > -1 && !vms.starting) { 09573 cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 2, record_gain); 09574 if (cmd == 9) { 09575 silentexit = 1; 09576 goto out; 09577 } else if (cmd == ERROR_LOCK_PATH) { 09578 res = cmd; 09579 goto out; 09580 } 09581 } else 09582 cmd = ast_play_and_wait(chan, "vm-sorry"); 09583 cmd = 't'; 09584 break; 09585 case '3': /* Envelope */ 09586 if (vms.lastmsg > -1 && !vms.starting) { 09587 cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 3, record_gain); 09588 if (cmd == ERROR_LOCK_PATH) { 09589 res = cmd; 09590 goto out; 09591 } 09592 } else 09593 cmd = ast_play_and_wait(chan, "vm-sorry"); 09594 cmd = 't'; 09595 break; 09596 case '4': /* Dialout */ 09597 if (!ast_strlen_zero(vmu->dialout)) { 09598 cmd = dialout(chan, vmu, NULL, vmu->dialout); 09599 if (cmd == 9) { 09600 silentexit = 1; 09601 goto out; 09602 } 09603 } else 09604 cmd = ast_play_and_wait(chan, "vm-sorry"); 09605 cmd = 't'; 09606 break; 09607 09608 case '5': /* Leave VoiceMail */ 09609 if (ast_test_flag(vmu, VM_SVMAIL)) { 09610 cmd = forward_message(chan, context, &vms, vmu, vmfmts, 1, record_gain, 0); 09611 if (cmd == ERROR_LOCK_PATH || cmd == OPERATOR_EXIT) { 09612 res = cmd; 09613 goto out; 09614 } 09615 } else 09616 cmd = ast_play_and_wait(chan,"vm-sorry"); 09617 cmd='t'; 09618 break; 09619 09620 case '*': /* Return to main menu */ 09621 cmd = 't'; 09622 break; 09623 09624 default: 09625 cmd = 0; 09626 if (!vms.starting) { 09627 cmd = ast_play_and_wait(chan, "vm-toreply"); 09628 } 09629 if (!ast_strlen_zero(vmu->callback) && !vms.starting && !cmd) { 09630 cmd = ast_play_and_wait(chan, "vm-tocallback"); 09631 } 09632 if (!cmd && !vms.starting) { 09633 cmd = ast_play_and_wait(chan, "vm-tohearenv"); 09634 } 09635 if (!ast_strlen_zero(vmu->dialout) && !cmd) { 09636 cmd = ast_play_and_wait(chan, "vm-tomakecall"); 09637 } 09638 if (ast_test_flag(vmu, VM_SVMAIL) && !cmd) 09639 cmd=ast_play_and_wait(chan, "vm-leavemsg"); 09640 if (!cmd) 09641 cmd = ast_play_and_wait(chan, "vm-starmain"); 09642 if (!cmd) 09643 cmd = ast_waitfordigit(chan,6000); 09644 if (!cmd) 09645 vms.repeats++; 09646 if (vms.repeats > 3) 09647 cmd = 't'; 09648 } 09649 } 09650 if (cmd == 't') { 09651 cmd = 0; 09652 vms.repeats = 0; 09653 } 09654 break; 09655 case '4': /* Go to the previous message */ 09656 if (vms.curmsg > 0) { 09657 vms.curmsg--; 09658 cmd = play_message(chan, vmu, &vms); 09659 } else { 09660 /* Check if we were listening to new 09661 messages. If so, go to Urgent messages 09662 instead of saying "no more messages" 09663 */ 09664 if (in_urgent == 0 && vms.urgentmessages > 0) { 09665 /* Check for Urgent messages */ 09666 in_urgent = 1; 09667 res = close_mailbox(&vms, vmu); 09668 if (res == ERROR_LOCK_PATH) 09669 goto out; 09670 res = open_mailbox(&vms, vmu, 11); /* Open Urgent folder */ 09671 if (res < 0) 09672 goto out; 09673 ast_debug(1, "No more new messages, opened INBOX and got %d Urgent messages\n",vms.lastmsg + 1); 09674 vms.curmsg = vms.lastmsg; 09675 if (vms.lastmsg < 0) 09676 cmd = ast_play_and_wait(chan, "vm-nomore"); 09677 } else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) { 09678 vms.curmsg = vms.lastmsg; 09679 cmd = play_message(chan, vmu, &vms); 09680 } else { 09681 cmd = ast_play_and_wait(chan, "vm-nomore"); 09682 } 09683 } 09684 break; 09685 case '6': /* Go to the next message */ 09686 if (vms.curmsg < vms.lastmsg) { 09687 vms.curmsg++; 09688 cmd = play_message(chan, vmu, &vms); 09689 } else { 09690 if (in_urgent && vms.newmessages > 0) { 09691 /* Check if we were listening to urgent 09692 * messages. If so, go to regular new messages 09693 * instead of saying "no more messages" 09694 */ 09695 in_urgent = 0; 09696 res = close_mailbox(&vms, vmu); 09697 if (res == ERROR_LOCK_PATH) 09698 goto out; 09699 res = open_mailbox(&vms, vmu, NEW_FOLDER); 09700 if (res < 0) 09701 goto out; 09702 ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); 09703 vms.curmsg = -1; 09704 if (vms.lastmsg < 0) { 09705 cmd = ast_play_and_wait(chan, "vm-nomore"); 09706 } 09707 } else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) { 09708 vms.curmsg = 0; 09709 cmd = play_message(chan, vmu, &vms); 09710 } else { 09711 cmd = ast_play_and_wait(chan, "vm-nomore"); 09712 } 09713 } 09714 break; 09715 case '7': /* Delete the current message */ 09716 if (vms.curmsg >= 0 && vms.curmsg <= vms.lastmsg) { 09717 vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg]; 09718 if (useadsi) 09719 adsi_delete(chan, &vms); 09720 if (vms.deleted[vms.curmsg]) { 09721 if (play_folder == 0) { 09722 if (in_urgent) { 09723 vms.urgentmessages--; 09724 } else { 09725 vms.newmessages--; 09726 } 09727 } 09728 else if (play_folder == 1) 09729 vms.oldmessages--; 09730 cmd = ast_play_and_wait(chan, "vm-deleted"); 09731 } else { 09732 if (play_folder == 0) { 09733 if (in_urgent) { 09734 vms.urgentmessages++; 09735 } else { 09736 vms.newmessages++; 09737 } 09738 } 09739 else if (play_folder == 1) 09740 vms.oldmessages++; 09741 cmd = ast_play_and_wait(chan, "vm-undeleted"); 09742 } 09743 if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) { 09744 if (vms.curmsg < vms.lastmsg) { 09745 vms.curmsg++; 09746 cmd = play_message(chan, vmu, &vms); 09747 } else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) { 09748 vms.curmsg = 0; 09749 cmd = play_message(chan, vmu, &vms); 09750 } else { 09751 /* Check if we were listening to urgent 09752 messages. If so, go to regular new messages 09753 instead of saying "no more messages" 09754 */ 09755 if (in_urgent == 1) { 09756 /* Check for new messages */ 09757 in_urgent = 0; 09758 res = close_mailbox(&vms, vmu); 09759 if (res == ERROR_LOCK_PATH) 09760 goto out; 09761 res = open_mailbox(&vms, vmu, NEW_FOLDER); 09762 if (res < 0) 09763 goto out; 09764 ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); 09765 vms.curmsg = -1; 09766 if (vms.lastmsg < 0) 09767 cmd = ast_play_and_wait(chan, "vm-nomore"); 09768 } else { 09769 cmd = ast_play_and_wait(chan, "vm-nomore"); 09770 } 09771 } 09772 } 09773 } else /* Delete not valid if we haven't selected a message */ 09774 cmd = 0; 09775 #ifdef IMAP_STORAGE 09776 deleted = 1; 09777 #endif 09778 break; 09779 09780 case '8': /* Forward the current messgae */ 09781 if (vms.lastmsg > -1) { 09782 cmd = forward_message(chan, context, &vms, vmu, vmfmts, 0, record_gain, in_urgent); 09783 if (cmd == ERROR_LOCK_PATH) { 09784 res = cmd; 09785 goto out; 09786 } 09787 } else { 09788 /* Check if we were listening to urgent 09789 messages. If so, go to regular new messages 09790 instead of saying "no more messages" 09791 */ 09792 if (in_urgent == 1 && vms.newmessages > 0) { 09793 /* Check for new messages */ 09794 in_urgent = 0; 09795 res = close_mailbox(&vms, vmu); 09796 if (res == ERROR_LOCK_PATH) 09797 goto out; 09798 res = open_mailbox(&vms, vmu, NEW_FOLDER); 09799 if (res < 0) 09800 goto out; 09801 ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); 09802 vms.curmsg = -1; 09803 if (vms.lastmsg < 0) 09804 cmd = ast_play_and_wait(chan, "vm-nomore"); 09805 } else { 09806 cmd = ast_play_and_wait(chan, "vm-nomore"); 09807 } 09808 } 09809 break; 09810 case '9': /* Save message to folder */ 09811 if (vms.curmsg < 0 || vms.curmsg > vms.lastmsg) { 09812 /* No message selected */ 09813 cmd = 0; 09814 break; 09815 } 09816 if (useadsi) 09817 adsi_folders(chan, 1, "Save to folder..."); 09818 cmd = get_folder2(chan, "vm-savefolder", 1); 09819 box = 0; /* Shut up compiler */ 09820 if (cmd == '#') { 09821 cmd = 0; 09822 break; 09823 } else if (cmd > 0) { 09824 box = cmd = cmd - '0'; 09825 cmd = save_to_folder(vmu, &vms, vms.curmsg, cmd); 09826 if (cmd == ERROR_LOCK_PATH) { 09827 res = cmd; 09828 goto out; 09829 #ifndef IMAP_STORAGE 09830 } else if (!cmd) { 09831 vms.deleted[vms.curmsg] = 1; 09832 #endif 09833 } else { 09834 vms.deleted[vms.curmsg] = 0; 09835 vms.heard[vms.curmsg] = 0; 09836 } 09837 } 09838 make_file(vms.fn, sizeof(vms.fn), vms.curdir, vms.curmsg); 09839 if (useadsi) 09840 adsi_message(chan, &vms); 09841 snprintf(vms.fn, sizeof(vms.fn), "vm-%s", mbox(box)); 09842 if (!cmd) { 09843 cmd = ast_play_and_wait(chan, "vm-message"); 09844 if (!cmd) 09845 cmd = say_and_wait(chan, vms.curmsg + 1, chan->language); 09846 if (!cmd) 09847 cmd = ast_play_and_wait(chan, "vm-savedto"); 09848 if (!cmd) 09849 cmd = vm_play_folder_name(chan, vms.fn); 09850 } else { 09851 cmd = ast_play_and_wait(chan, "vm-mailboxfull"); 09852 } 09853 if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) { 09854 if (vms.curmsg < vms.lastmsg) { 09855 vms.curmsg++; 09856 cmd = play_message(chan, vmu, &vms); 09857 } else if (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms.lastmsg > 0) { 09858 vms.curmsg = 0; 09859 cmd = play_message(chan, vmu, &vms); 09860 } else { 09861 /* Check if we were listening to urgent 09862 messages. If so, go to regular new messages 09863 instead of saying "no more messages" 09864 */ 09865 if (in_urgent == 1 && vms.newmessages > 0) { 09866 /* Check for new messages */ 09867 in_urgent = 0; 09868 res = close_mailbox(&vms, vmu); 09869 if (res == ERROR_LOCK_PATH) 09870 goto out; 09871 res = open_mailbox(&vms, vmu, NEW_FOLDER); 09872 if (res < 0) 09873 goto out; 09874 ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); 09875 vms.curmsg = -1; 09876 if (vms.lastmsg < 0) 09877 cmd = ast_play_and_wait(chan, "vm-nomore"); 09878 } else { 09879 cmd = ast_play_and_wait(chan, "vm-nomore"); 09880 } 09881 } 09882 } 09883 break; 09884 case '*': /* Help */ 09885 if (!vms.starting) { 09886 cmd = ast_play_and_wait(chan, "vm-onefor"); 09887 if (!strncasecmp(chan->language, "he", 2)) { 09888 cmd = ast_play_and_wait(chan, "vm-for"); 09889 } 09890 if (!cmd) 09891 cmd = vm_play_folder_name(chan, vms.vmbox); 09892 if (!cmd) 09893 cmd = ast_play_and_wait(chan, "vm-opts"); 09894 if (!cmd) 09895 cmd = vm_instructions(chan, vmu, &vms, 1, in_urgent); 09896 } else 09897 cmd = 0; 09898 break; 09899 case '0': /* Mailbox options */ 09900 cmd = vm_options(chan, vmu, &vms, vmfmts, record_gain); 09901 if (useadsi) 09902 adsi_status(chan, &vms); 09903 break; 09904 default: /* Nothing */ 09905 cmd = vm_instructions(chan, vmu, &vms, 0, in_urgent); 09906 break; 09907 } 09908 } 09909 if ((cmd == 't') || (cmd == '#')) { 09910 /* Timeout */ 09911 res = 0; 09912 } else { 09913 /* Hangup */ 09914 res = -1; 09915 } 09916 09917 out: 09918 if (res > -1) { 09919 ast_stopstream(chan); 09920 adsi_goodbye(chan); 09921 if (valid && res != OPERATOR_EXIT) { 09922 if (silentexit) 09923 res = ast_play_and_wait(chan, "vm-dialout"); 09924 else 09925 res = ast_play_and_wait(chan, "vm-goodbye"); 09926 } 09927 if ((valid && res > 0) || res == OPERATOR_EXIT) { 09928 res = 0; 09929 } 09930 if (useadsi) 09931 ast_adsi_unload_session(chan); 09932 } 09933 if (vmu) 09934 close_mailbox(&vms, vmu); 09935 if (valid) { 09936 int new = 0, old = 0, urgent = 0; 09937 snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context); 09938 manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL)); 09939 /* Urgent flag not passwd to externnotify here */ 09940 run_externnotify(vmu->context, vmu->mailbox, NULL); 09941 ast_app_inboxcount2(ext_context, &urgent, &new, &old); 09942 queue_mwi_event(ext_context, urgent, new, old); 09943 } 09944 #ifdef IMAP_STORAGE 09945 /* expunge message - use UID Expunge if supported on IMAP server*/ 09946 ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup); 09947 if (vmu && deleted == 1 && expungeonhangup == 1 && vms.mailstream != NULL) { 09948 ast_mutex_lock(&vms.lock); 09949 #ifdef HAVE_IMAP_TK2006 09950 if (LEVELUIDPLUS (vms.mailstream)) { 09951 mail_expunge_full(vms.mailstream,NIL,EX_UID); 09952 } else 09953 #endif 09954 mail_expunge(vms.mailstream); 09955 ast_mutex_unlock(&vms.lock); 09956 } 09957 /* before we delete the state, we should copy pertinent info 09958 * back to the persistent model */ 09959 if (vmu) { 09960 vmstate_delete(&vms); 09961 } 09962 #endif 09963 if (vmu) 09964 free_user(vmu); 09965 if (vms.deleted) 09966 ast_free(vms.deleted); 09967 if (vms.heard) 09968 ast_free(vms.heard); 09969 09970 #ifdef IMAP_STORAGE 09971 pthread_setspecific(ts_vmstate.key, NULL); 09972 #endif 09973 return res; 09974 }
| static int vm_forwardoptions | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| char * | curdir, | |||
| int | curmsg, | |||
| char * | vm_fmts, | |||
| char * | context, | |||
| signed char | record_gain, | |||
| long * | duration, | |||
| struct vm_state * | vms, | |||
| char * | flag | |||
| ) | [static] |
presents the option to prepend to an existing message when forwarding it.
| chan | ||
| vmu | ||
| curdir | ||
| curmsg | ||
| vmfmts | ||
| context | ||
| record_gain | ||
| duration | ||
| vms | Presents a prompt for 1 to prepend the current message, 2 to forward the message without prepending, or * to return to the main menu. |
Definition at line 6408 of file app_voicemail.c.
References ast_category_get(), ast_channel_setoption(), ast_config_destroy(), ast_config_load, ast_config_text_file_save(), ast_filecopy(), ast_filerename(), AST_OPTION_RXGAIN, ast_play_and_prepend(), ast_play_and_wait(), ast_variable_retrieve(), ast_variable_update(), ast_waitfordigit(), CONFIG_FLAG_NOCACHE, CONFIG_STATUS_FILEINVALID, copy(), INTRO, make_file(), ast_vm_user::maxsecs, and play_record_review().
Referenced by forward_message().
06410 { 06411 #ifdef IMAP_STORAGE 06412 int res; 06413 #endif 06414 int cmd = 0; 06415 int retries = 0, prepend_duration = 0, already_recorded = 0; 06416 char msgfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX]; 06417 char textfile[PATH_MAX]; 06418 struct ast_config *msg_cfg; 06419 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE }; 06420 #ifndef IMAP_STORAGE 06421 signed char zero_gain = 0; 06422 #endif 06423 const char *duration_str; 06424 06425 /* Must always populate duration correctly */ 06426 make_file(msgfile, sizeof(msgfile), curdir, curmsg); 06427 strcpy(textfile, msgfile); 06428 strcpy(backup, msgfile); 06429 strcpy(backup_textfile, msgfile); 06430 strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1); 06431 strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1); 06432 strncat(backup_textfile, "-bak.txt", sizeof(backup_textfile) - strlen(backup_textfile) - 1); 06433 06434 if ((msg_cfg = ast_config_load(textfile, config_flags)) && msg_cfg != CONFIG_STATUS_FILEINVALID && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) { 06435 *duration = atoi(duration_str); 06436 } else { 06437 *duration = 0; 06438 } 06439 06440 while ((cmd >= 0) && (cmd != 't') && (cmd != '*')) { 06441 if (cmd) 06442 retries = 0; 06443 switch (cmd) { 06444 case '1': 06445 06446 #ifdef IMAP_STORAGE 06447 /* Record new intro file */ 06448 make_file(vms->introfn, sizeof(vms->introfn), curdir, curmsg); 06449 strncat(vms->introfn, "intro", sizeof(vms->introfn)); 06450 res = ast_play_and_wait(chan, INTRO); 06451 res = ast_play_and_wait(chan, "beep"); 06452 res = play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vm_fmts, 1, vmu, (int *)duration, NULL, record_gain, vms, flag); 06453 cmd = 't'; 06454 #else 06455 06456 /* prepend a message to the current message, update the metadata and return */ 06457 06458 make_file(msgfile, sizeof(msgfile), curdir, curmsg); 06459 strcpy(textfile, msgfile); 06460 strncat(textfile, ".txt", sizeof(textfile) - 1); 06461 *duration = 0; 06462 06463 /* if we can't read the message metadata, stop now */ 06464 if (!msg_cfg) { 06465 cmd = 0; 06466 break; 06467 } 06468 06469 /* Back up the original file, so we can retry the prepend and restore it after forward. */ 06470 if (already_recorded) { 06471 ast_filecopy(backup, msgfile, NULL); 06472 copy(backup_textfile, textfile); 06473 } 06474 else { 06475 ast_filecopy(msgfile, backup, NULL); 06476 copy(textfile,backup_textfile); 06477 } 06478 already_recorded = 1; 06479 06480 if (record_gain) 06481 ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0); 06482 06483 cmd = ast_play_and_prepend(chan, NULL, msgfile, 0, vm_fmts, &prepend_duration, 1, silencethreshold, maxsilence); 06484 if (cmd == 'S') { 06485 ast_filerename(backup, msgfile, NULL); 06486 } 06487 06488 if (record_gain) 06489 ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0); 06490 06491 06492 if ((duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) 06493 *duration = atoi(duration_str); 06494 06495 if (prepend_duration) { 06496 struct ast_category *msg_cat; 06497 /* need enough space for a maximum-length message duration */ 06498 char duration_buf[12]; 06499 06500 *duration += prepend_duration; 06501 msg_cat = ast_category_get(msg_cfg, "message"); 06502 snprintf(duration_buf, 11, "%ld", *duration); 06503 if (!ast_variable_update(msg_cat, "duration", duration_buf, NULL, 0)) { 06504 ast_config_text_file_save(textfile, msg_cfg, "app_voicemail"); 06505 } 06506 } 06507 06508 #endif 06509 break; 06510 case '2': 06511 /* NULL out introfile so we know there is no intro! */ 06512 #ifdef IMAP_STORAGE 06513 *vms->introfn = '\0'; 06514 #endif 06515 cmd = 't'; 06516 break; 06517 case '*': 06518 cmd = '*'; 06519 break; 06520 default: 06521 cmd = ast_play_and_wait(chan,"vm-forwardoptions"); 06522 /* "Press 1 to prepend a message or 2 to forward the message without prepending" */ 06523 if (!cmd) 06524 cmd = ast_play_and_wait(chan,"vm-starmain"); 06525 /* "press star to return to the main menu" */ 06526 if (!cmd) 06527 cmd = ast_waitfordigit(chan,6000); 06528 if (!cmd) 06529 retries++; 06530 if (retries > 3) 06531 cmd = 't'; 06532 } 06533 } 06534 06535 if (msg_cfg) 06536 ast_config_destroy(msg_cfg); 06537 if (prepend_duration) 06538 *duration = prepend_duration; 06539 06540 if (already_recorded && cmd == -1) { 06541 /* restore original message if prepention cancelled */ 06542 ast_filerename(backup, msgfile, NULL); 06543 rename(backup_textfile, textfile); 06544 } 06545 06546 if (cmd == 't' || cmd == 'S') 06547 cmd = 0; 06548 return cmd; 06549 }
| static int vm_instructions | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| struct vm_state * | vms, | |||
| int | skipadvanced, | |||
| int | in_urgent | |||
| ) | [static] |
Definition at line 8649 of file app_voicemail.c.
References ast_channel::language, vm_state::starting, vm_instructions_en(), and vm_instructions_zh().
Referenced by vm_execmain().
08650 { 08651 if (vms->starting && !strncasecmp(chan->language, "zh", 2)) { /* CHINESE (Taiwan) syntax */ 08652 return vm_instructions_zh(chan, vmu, vms, skipadvanced, in_urgent); 08653 } else { /* Default to ENGLISH */ 08654 return vm_instructions_en(chan, vmu, vms, skipadvanced, in_urgent); 08655 } 08656 }
| static int vm_instructions_en | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| struct vm_state * | vms, | |||
| int | skipadvanced, | |||
| int | in_urgent | |||
| ) | [static] |
Definition at line 8548 of file app_voicemail.c.
References ast_play_and_wait(), ast_test_flag, ast_waitfordigit(), vm_state::curmsg, vm_state::deleted, vm_state::lastmsg, vm_state::newmessages, vm_state::repeats, vm_state::starting, vm_state::urgentmessages, VM_MESSAGEWRAP, vm_play_folder_name(), and vm_state::vmbox.
Referenced by vm_instructions(), and vm_instructions_zh().
08549 { 08550 int res = 0; 08551 /* Play instructions and wait for new command */ 08552 while (!res) { 08553 if (vms->starting) { 08554 if (vms->lastmsg > -1) { 08555 if (skipadvanced) 08556 res = ast_play_and_wait(chan, "vm-onefor-full"); 08557 else 08558 res = ast_play_and_wait(chan, "vm-onefor"); 08559 if (!res) 08560 res = vm_play_folder_name(chan, vms->vmbox); 08561 } 08562 if (!res) { 08563 if (skipadvanced) 08564 res = ast_play_and_wait(chan, "vm-opts-full"); 08565 else 08566 res = ast_play_and_wait(chan, "vm-opts"); 08567 } 08568 } else { 08569 /* Added for additional help */ 08570 if (skipadvanced) { 08571 res = ast_play_and_wait(chan, "vm-onefor-full"); 08572 if (!res) 08573 res = vm_play_folder_name(chan, vms->vmbox); 08574 res = ast_play_and_wait(chan, "vm-opts-full"); 08575 } 08576 /* Logic: 08577 * If the current message is not the first OR 08578 * if we're listening to the first new message and there are 08579 * also urgent messages, then prompt for navigation to the 08580 * previous message 08581 */ 08582 if (vms->curmsg || (!in_urgent && vms->urgentmessages > 0) || (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms->lastmsg > 0)) { 08583 res = ast_play_and_wait(chan, "vm-prev"); 08584 } 08585 if (!res && !skipadvanced) 08586 res = ast_play_and_wait(chan, "vm-advopts"); 08587 if (!res) 08588 res = ast_play_and_wait(chan, "vm-repeat"); 08589 /* Logic: 08590 * If we're not listening to the last message OR 08591 * we're listening to the last urgent message and there are 08592 * also new non-urgent messages, then prompt for navigation 08593 * to the next message 08594 */ 08595 if (!res && ((vms->curmsg != vms->lastmsg) || (in_urgent && vms->newmessages > 0) || 08596 (ast_test_flag(vmu, VM_MESSAGEWRAP) && vms->lastmsg > 0) )) { 08597 res = ast_play_and_wait(chan, "vm-next"); 08598 } 08599 if (!res) { 08600 if (!vms->deleted[vms->curmsg]) 08601 res = ast_play_and_wait(chan, "vm-delete"); 08602 else 08603 res = ast_play_and_wait(chan, "vm-undelete"); 08604 if (!res) 08605 res = ast_play_and_wait(chan, "vm-toforward"); 08606 if (!res) 08607 res = ast_play_and_wait(chan, "vm-savemessage"); 08608 } 08609 } 08610 if (!res) { 08611 res = ast_play_and_wait(chan, "vm-helpexit"); 08612 } 08613 if (!res) 08614 res = ast_waitfordigit(chan, 6000); 08615 if (!res) { 08616 vms->repeats++; 08617 if (vms->repeats > 2) { 08618 res = 't'; 08619 } 08620 } 08621 } 08622 return res; 08623 }
| static int vm_instructions_zh | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| struct vm_state * | vms, | |||
| int | skipadvanced, | |||
| int | in_urgent | |||
| ) | [static] |
Definition at line 8625 of file app_voicemail.c.
References ast_play_and_wait(), vm_state::lastmsg, vm_state::starting, vm_instructions_en(), vm_play_folder_name(), and vm_state::vmbox.
Referenced by vm_instructions().
08626 { 08627 int res = 0; 08628 /* Play instructions and wait for new command */ 08629 while (!res) { 08630 if (vms->lastmsg > -1) { 08631 res = ast_play_and_wait(chan, "vm-listen"); 08632 if (!res) 08633 res = vm_play_folder_name(chan, vms->vmbox); 08634 if (!res) 08635 res = ast_play_and_wait(chan, "press"); 08636 if (!res) 08637 res = ast_play_and_wait(chan, "digits/1"); 08638 } 08639 if (!res) 08640 res = ast_play_and_wait(chan, "vm-opts"); 08641 if (!res) { 08642 vms->starting = 0; 08643 return vm_instructions_en(chan, vmu, vms, skipadvanced, in_urgent); 08644 } 08645 } 08646 return res; 08647 }
| static int vm_intro | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8488 of file app_voicemail.c.
References ast_fileexists(), ast_log(), ast_play_and_wait(), ast_test_flag, ast_vm_user::context, DISPOSE, ast_channel::language, LOG_WARNING, ast_vm_user::mailbox, RETRIEVE, vm_state::username, vm_intro_cs(), vm_intro_de(), vm_intro_en(), vm_intro_es(), vm_intro_fr(), vm_intro_gr(), vm_intro_he(), vm_intro_it(), vm_intro_multilang(), vm_intro_nl(), vm_intro_no(), vm_intro_pl(), vm_intro_pt(), vm_intro_pt_BR(), vm_intro_se(), vm_intro_zh(), and VM_TEMPGREETWARN.
Referenced by vm_execmain().
08489 { 08490 char prefile[256]; 08491 08492 /* Notify the user that the temp greeting is set and give them the option to remove it */ 08493 snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username); 08494 if (ast_test_flag(vmu, VM_TEMPGREETWARN)) { 08495 RETRIEVE(prefile, -1, vmu->mailbox, vmu->context); 08496 if (ast_fileexists(prefile, NULL, NULL) > 0) { 08497 ast_play_and_wait(chan, "vm-tempgreetactive"); 08498 } 08499 DISPOSE(prefile, -1); 08500 } 08501 08502 /* Play voicemail intro - syntax is different for different languages */ 08503 if (0) { 08504 return 0; 08505 } else if (!strncasecmp(chan->language, "cs", 2)) { /* CZECH syntax */ 08506 return vm_intro_cs(chan, vms); 08507 } else if (!strncasecmp(chan->language, "cz", 2)) { /* deprecated CZECH syntax */ 08508 static int deprecation_warning = 0; 08509 if (deprecation_warning++ % 10 == 0) { 08510 ast_log(LOG_WARNING, "cz is not a standard language code. Please switch to using cs instead.\n"); 08511 } 08512 return vm_intro_cs(chan, vms); 08513 } else if (!strncasecmp(chan->language, "de", 2)) { /* GERMAN syntax */ 08514 return vm_intro_de(chan, vms); 08515 } else if (!strncasecmp(chan->language, "es", 2)) { /* SPANISH syntax */ 08516 return vm_intro_es(chan, vms); 08517 } else if (!strncasecmp(chan->language, "fr", 2)) { /* FRENCH syntax */ 08518 return vm_intro_fr(chan, vms); 08519 } else if (!strncasecmp(chan->language, "gr", 2)) { /* GREEK syntax */ 08520 return vm_intro_gr(chan, vms); 08521 } else if (!strncasecmp(chan->language, "he", 2)) { /* HEBREW syntax */ 08522 return vm_intro_he(chan, vms); 08523 } else if (!strncasecmp(chan->language, "it", 2)) { /* ITALIAN syntax */ 08524 return vm_intro_it(chan, vms); 08525 } else if (!strncasecmp(chan->language, "nl", 2)) { /* DUTCH syntax */ 08526 return vm_intro_nl(chan, vms); 08527 } else if (!strncasecmp(chan->language, "no", 2)) { /* NORWEGIAN syntax */ 08528 return vm_intro_no(chan, vms); 08529 } else if (!strncasecmp(chan->language, "pl", 2)) { /* POLISH syntax */ 08530 return vm_intro_pl(chan, vms); 08531 } else if (!strncasecmp(chan->language, "pt_BR", 5)) { /* BRAZILIAN PORTUGUESE syntax */ 08532 return vm_intro_pt_BR(chan, vms); 08533 } else if (!strncasecmp(chan->language, "pt", 2)) { /* PORTUGUESE syntax */ 08534 return vm_intro_pt(chan, vms); 08535 } else if (!strncasecmp(chan->language, "ru", 2)) { /* RUSSIAN syntax */ 08536 return vm_intro_multilang(chan, vms, "n"); 08537 } else if (!strncasecmp(chan->language, "se", 2)) { /* SWEDISH syntax */ 08538 return vm_intro_se(chan, vms); 08539 } else if (!strncasecmp(chan->language, "ua", 2)) { /* UKRAINIAN syntax */ 08540 return vm_intro_multilang(chan, vms, "n"); 08541 } else if (!strncasecmp(chan->language, "zh", 2)) { /* CHINESE (Taiwan) syntax */ 08542 return vm_intro_zh(chan, vms); 08543 } else { /* Default to ENGLISH */ 08544 return vm_intro_en(chan, vms); 08545 } 08546 }
| static int vm_intro_cs | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8389 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
08390 { 08391 int res; 08392 res = ast_play_and_wait(chan, "vm-youhave"); 08393 if (!res) { 08394 if (vms->newmessages) { 08395 if (vms->newmessages == 1) { 08396 res = ast_play_and_wait(chan, "digits/jednu"); 08397 } else { 08398 res = say_and_wait(chan, vms->newmessages, chan->language); 08399 } 08400 if (!res) { 08401 if ((vms->newmessages == 1)) 08402 res = ast_play_and_wait(chan, "vm-novou"); 08403 if ((vms->newmessages) > 1 && (vms->newmessages < 5)) 08404 res = ast_play_and_wait(chan, "vm-nove"); 08405 if (vms->newmessages > 4) 08406 res = ast_play_and_wait(chan, "vm-novych"); 08407 } 08408 if (vms->oldmessages && !res) 08409 res = ast_play_and_wait(chan, "vm-and"); 08410 else if (!res) { 08411 if ((vms->newmessages == 1)) 08412 res = ast_play_and_wait(chan, "vm-zpravu"); 08413 if ((vms->newmessages) > 1 && (vms->newmessages < 5)) 08414 res = ast_play_and_wait(chan, "vm-zpravy"); 08415 if (vms->newmessages > 4) 08416 res = ast_play_and_wait(chan, "vm-zprav"); 08417 } 08418 } 08419 if (!res && vms->oldmessages) { 08420 res = say_and_wait(chan, vms->oldmessages, chan->language); 08421 if (!res) { 08422 if ((vms->oldmessages == 1)) 08423 res = ast_play_and_wait(chan, "vm-starou"); 08424 if ((vms->oldmessages) > 1 && (vms->oldmessages < 5)) 08425 res = ast_play_and_wait(chan, "vm-stare"); 08426 if (vms->oldmessages > 4) 08427 res = ast_play_and_wait(chan, "vm-starych"); 08428 } 08429 if (!res) { 08430 if ((vms->oldmessages == 1)) 08431 res = ast_play_and_wait(chan, "vm-zpravu"); 08432 if ((vms->oldmessages) > 1 && (vms->oldmessages < 5)) 08433 res = ast_play_and_wait(chan, "vm-zpravy"); 08434 if (vms->oldmessages > 4) 08435 res = ast_play_and_wait(chan, "vm-zprav"); 08436 } 08437 } 08438 if (!res) { 08439 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08440 res = ast_play_and_wait(chan, "vm-no"); 08441 if (!res) 08442 res = ast_play_and_wait(chan, "vm-zpravy"); 08443 } 08444 } 08445 } 08446 return res; 08447 }
| static int vm_intro_de | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8085 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
08086 { 08087 /* Introduce messages they have */ 08088 int res; 08089 res = ast_play_and_wait(chan, "vm-youhave"); 08090 if (!res) { 08091 if (vms->newmessages) { 08092 if ((vms->newmessages == 1)) 08093 res = ast_play_and_wait(chan, "digits/1F"); 08094 else 08095 res = say_and_wait(chan, vms->newmessages, chan->language); 08096 if (!res) 08097 res = ast_play_and_wait(chan, "vm-INBOX"); 08098 if (vms->oldmessages && !res) 08099 res = ast_play_and_wait(chan, "vm-and"); 08100 else if (!res) { 08101 if ((vms->newmessages == 1)) 08102 res = ast_play_and_wait(chan, "vm-message"); 08103 else 08104 res = ast_play_and_wait(chan, "vm-messages"); 08105 } 08106 08107 } 08108 if (!res && vms->oldmessages) { 08109 if (vms->oldmessages == 1) 08110 res = ast_play_and_wait(chan, "digits/1F"); 08111 else 08112 res = say_and_wait(chan, vms->oldmessages, chan->language); 08113 if (!res) 08114 res = ast_play_and_wait(chan, "vm-Old"); 08115 if (!res) { 08116 if (vms->oldmessages == 1) 08117 res = ast_play_and_wait(chan, "vm-message"); 08118 else 08119 res = ast_play_and_wait(chan, "vm-messages"); 08120 } 08121 } 08122 if (!res) { 08123 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08124 res = ast_play_and_wait(chan, "vm-no"); 08125 if (!res) 08126 res = ast_play_and_wait(chan, "vm-messages"); 08127 } 08128 } 08129 } 08130 return res; 08131 }
| static int vm_intro_en | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 7834 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
07835 { 07836 int res; 07837 07838 /* Introduce messages they have */ 07839 res = ast_play_and_wait(chan, "vm-youhave"); 07840 if (!res) { 07841 if (vms->urgentmessages) { 07842 res = say_and_wait(chan, vms->urgentmessages, chan->language); 07843 if (!res) 07844 res = ast_play_and_wait(chan, "vm-Urgent"); 07845 if ((vms->oldmessages || vms->newmessages) && !res) { 07846 res = ast_play_and_wait(chan, "vm-and"); 07847 } else if (!res) { 07848 if ((vms->urgentmessages == 1)) 07849 res = ast_play_and_wait(chan, "vm-message"); 07850 else 07851 res = ast_play_and_wait(chan, "vm-messages"); 07852 } 07853 } 07854 if (vms->newmessages) { 07855 res = say_and_wait(chan, vms->newmessages, chan->language); 07856 if (!res) 07857 res = ast_play_and_wait(chan, "vm-INBOX"); 07858 if (vms->oldmessages && !res) 07859 res = ast_play_and_wait(chan, "vm-and"); 07860 else if (!res) { 07861 if ((vms->newmessages == 1)) 07862 res = ast_play_and_wait(chan, "vm-message"); 07863 else 07864 res = ast_play_and_wait(chan, "vm-messages"); 07865 } 07866 07867 } 07868 if (!res && vms->oldmessages) { 07869 res = say_and_wait(chan, vms->oldmessages, chan->language); 07870 if (!res) 07871 res = ast_play_and_wait(chan, "vm-Old"); 07872 if (!res) { 07873 if (vms->oldmessages == 1) 07874 res = ast_play_and_wait(chan, "vm-message"); 07875 else 07876 res = ast_play_and_wait(chan, "vm-messages"); 07877 } 07878 } 07879 if (!res) { 07880 if (!vms->urgentmessages && !vms->oldmessages && !vms->newmessages) { 07881 res = ast_play_and_wait(chan, "vm-no"); 07882 if (!res) 07883 res = ast_play_and_wait(chan, "vm-messages"); 07884 } 07885 } 07886 } 07887 return res; 07888 }
| static int vm_intro_es | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8134 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
08135 { 08136 /* Introduce messages they have */ 08137 int res; 08138 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08139 res = ast_play_and_wait(chan, "vm-youhaveno"); 08140 if (!res) 08141 res = ast_play_and_wait(chan, "vm-messages"); 08142 } else { 08143 res = ast_play_and_wait(chan, "vm-youhave"); 08144 } 08145 if (!res) { 08146 if (vms->newmessages) { 08147 if (!res) { 08148 if ((vms->newmessages == 1)) { 08149 res = ast_play_and_wait(chan, "digits/1M"); 08150 if (!res) 08151 res = ast_play_and_wait(chan, "vm-message"); 08152 if (!res) 08153 res = ast_play_and_wait(chan, "vm-INBOXs"); 08154 } else { 08155 res = say_and_wait(chan, vms->newmessages, chan->language); 08156 if (!res) 08157 res = ast_play_and_wait(chan, "vm-messages"); 08158 if (!res) 08159 res = ast_play_and_wait(chan, "vm-INBOX"); 08160 } 08161 } 08162 if (vms->oldmessages && !res) 08163 res = ast_play_and_wait(chan, "vm-and"); 08164 } 08165 if (vms->oldmessages) { 08166 if (!res) { 08167 if (vms->oldmessages == 1) { 08168 res = ast_play_and_wait(chan, "digits/1M"); 08169 if (!res) 08170 res = ast_play_and_wait(chan, "vm-message"); 08171 if (!res) 08172 res = ast_play_and_wait(chan, "vm-Olds"); 08173 } else { 08174 res = say_and_wait(chan, vms->oldmessages, chan->language); 08175 if (!res) 08176 res = ast_play_and_wait(chan, "vm-messages"); 08177 if (!res) 08178 res = ast_play_and_wait(chan, "vm-Old"); 08179 } 08180 } 08181 } 08182 } 08183 return res; 08184 }
| static int vm_intro_fr | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8232 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
08233 { 08234 /* Introduce messages they have */ 08235 int res; 08236 res = ast_play_and_wait(chan, "vm-youhave"); 08237 if (!res) { 08238 if (vms->newmessages) { 08239 res = say_and_wait(chan, vms->newmessages, chan->language); 08240 if (!res) 08241 res = ast_play_and_wait(chan, "vm-INBOX"); 08242 if (vms->oldmessages && !res) 08243 res = ast_play_and_wait(chan, "vm-and"); 08244 else if (!res) { 08245 if ((vms->newmessages == 1)) 08246 res = ast_play_and_wait(chan, "vm-message"); 08247 else 08248 res = ast_play_and_wait(chan, "vm-messages"); 08249 } 08250 08251 } 08252 if (!res && vms->oldmessages) { 08253 res = say_and_wait(chan, vms->oldmessages, chan->language); 08254 if (!res) 08255 res = ast_play_and_wait(chan, "vm-Old"); 08256 if (!res) { 08257 if (vms->oldmessages == 1) 08258 res = ast_play_and_wait(chan, "vm-message"); 08259 else 08260 res = ast_play_and_wait(chan, "vm-messages"); 08261 } 08262 } 08263 if (!res) { 08264 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08265 res = ast_play_and_wait(chan, "vm-no"); 08266 if (!res) 08267 res = ast_play_and_wait(chan, "vm-messages"); 08268 } 08269 } 08270 } 08271 return res; 08272 }
| static int vm_intro_gr | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 7633 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().
07634 { 07635 int res = 0; 07636 07637 if (vms->newmessages) { 07638 res = ast_play_and_wait(chan, "vm-youhave"); 07639 if (!res) 07640 res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, NULL); 07641 if (!res) { 07642 if ((vms->newmessages == 1)) { 07643 res = ast_play_and_wait(chan, "vm-INBOX"); 07644 if (!res) 07645 res = ast_play_and_wait(chan, "vm-message"); 07646 } else { 07647 res = ast_play_and_wait(chan, "vm-INBOXs"); 07648 if (!res) 07649 res = ast_play_and_wait(chan, "vm-messages"); 07650 } 07651 } 07652 } else if (vms->oldmessages){ 07653 res = ast_play_and_wait(chan, "vm-youhave"); 07654 if (!res) 07655 res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, NULL); 07656 if ((vms->oldmessages == 1)){ 07657 res = ast_play_and_wait(chan, "vm-Old"); 07658 if (!res) 07659 res = ast_play_and_wait(chan, "vm-message"); 07660 } else { 07661 res = ast_play_and_wait(chan, "vm-Olds"); 07662 if (!res) 07663 res = ast_play_and_wait(chan, "vm-messages"); 07664 } 07665 } else if (!vms->oldmessages && !vms->newmessages) 07666 res = ast_play_and_wait(chan, "vm-denExeteMynhmata"); 07667 return res; 07668 }
| static int vm_intro_he | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 7767 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().
07768 { 07769 int res = 0; 07770 07771 /* Introduce messages they have */ 07772 if (!res) { 07773 if ((vms->newmessages) || (vms->oldmessages)) { 07774 res = ast_play_and_wait(chan, "vm-youhave"); 07775 } 07776 /* 07777 * The word "shtei" refers to the number 2 in hebrew when performing a count 07778 * of elements. In Hebrew, there are 6 forms of enumerating the number 2 for 07779 * an element, this is one of them. 07780 */ 07781 if (vms->newmessages) { 07782 if (!res) { 07783 if (vms->newmessages == 1) { 07784 res = ast_play_and_wait(chan, "vm-INBOX1"); 07785 } else { 07786 if (vms->newmessages == 2) { 07787 res = ast_play_and_wait(chan, "vm-shtei"); 07788 } else { 07789 res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, "f"); 07790 } 07791 res = ast_play_and_wait(chan, "vm-INBOX"); 07792 } 07793 } 07794 if (vms->oldmessages && !res) { 07795 res = ast_play_and_wait(chan, "vm-and"); 07796 if (vms->oldmessages == 1) { 07797 res = ast_play_and_wait(chan, "vm-Old1"); 07798 } else { 07799 if (vms->oldmessages == 2) { 07800 res = ast_play_and_wait(chan, "vm-shtei"); 07801 } else { 07802 res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f"); 07803 } 07804 res = ast_play_and_wait(chan, "vm-Old"); 07805 } 07806 } 07807 } 07808 if (!res && vms->oldmessages && !vms->newmessages) { 07809 if (!res) { 07810 if (vms->oldmessages == 1) { 07811 res = ast_play_and_wait(chan, "vm-Old1"); 07812 } else { 07813 if (vms->oldmessages == 2) { 07814 res = ast_play_and_wait(chan, "vm-shtei"); 07815 } else { 07816 res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f"); 07817 } 07818 res = ast_play_and_wait(chan, "vm-Old"); 07819 } 07820 } 07821 } 07822 if (!res) { 07823 if (!vms->oldmessages && !vms->newmessages) { 07824 if (!res) { 07825 res = ast_play_and_wait(chan, "vm-nomessages"); 07826 } 07827 } 07828 } 07829 } 07830 return res; 07831 }
| static int vm_intro_it | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 7891 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
07892 { 07893 /* Introduce messages they have */ 07894 int res; 07895 if (!vms->oldmessages && !vms->newmessages &&!vms->urgentmessages) 07896 res = ast_play_and_wait(chan, "vm-no") || 07897 ast_play_and_wait(chan, "vm-message"); 07898 else 07899 res = ast_play_and_wait(chan, "vm-youhave"); 07900 if (!res && vms->newmessages) { 07901 res = (vms->newmessages == 1) ? 07902 ast_play_and_wait(chan, "digits/un") || 07903 ast_play_and_wait(chan, "vm-nuovo") || 07904 ast_play_and_wait(chan, "vm-message") : 07905 /* 2 or more new messages */ 07906 say_and_wait(chan, vms->newmessages, chan->language) || 07907 ast_play_and_wait(chan, "vm-nuovi") || 07908 ast_play_and_wait(chan, "vm-messages"); 07909 if (!res && vms->oldmessages) 07910 res = ast_play_and_wait(chan, "vm-and"); 07911 } 07912 if (!res && vms->oldmessages) { 07913 res = (vms->oldmessages == 1) ? 07914 ast_play_and_wait(chan, "digits/un") || 07915 ast_play_and_wait(chan, "vm-vecchio") || 07916 ast_play_and_wait(chan, "vm-message") : 07917 /* 2 or more old messages */ 07918 say_and_wait(chan, vms->oldmessages, chan->language) || 07919 ast_play_and_wait(chan, "vm-vecchi") || 07920 ast_play_and_wait(chan, "vm-messages"); 07921 } 07922 return res; 07923 }
| static int vm_intro_multilang | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| const char | message_gender[] | |||
| ) | [static] |
Definition at line 7727 of file app_voicemail.c.
References AST_DIGIT_ANY, ast_play_and_wait(), ast_say_counted_adjective(), ast_say_counted_noun(), ast_say_number(), ast_channel::language, vm_state::newmessages, and vm_state::oldmessages.
Referenced by vm_intro().
07728 { 07729 int res; 07730 int lastnum = 0; 07731 07732 res = ast_play_and_wait(chan, "vm-youhave"); 07733 07734 if (!res && vms->newmessages) { 07735 lastnum = vms->newmessages; 07736 07737 if (!(res = ast_say_number(chan, lastnum, AST_DIGIT_ANY, chan->language, message_gender))) { 07738 res = ast_say_counted_adjective(chan, lastnum, "vm-new", message_gender); 07739 } 07740 07741 if (!res && vms->oldmessages) { 07742 res = ast_play_and_wait(chan, "vm-and"); 07743 } 07744 } 07745 07746 if (!res && vms->oldmessages) { 07747 lastnum = vms->oldmessages; 07748 07749 if (!(res = ast_say_number(chan, lastnum, AST_DIGIT_ANY, chan->language, message_gender))) { 07750 res = ast_say_counted_adjective(chan, lastnum, "vm-old", message_gender); 07751 } 07752 } 07753 07754 if (!res) { 07755 if (lastnum == 0) { 07756 res = ast_play_and_wait(chan, "vm-no"); 07757 } 07758 if (!res) { 07759 res = ast_say_counted_noun(chan, lastnum, "vm-message"); 07760 } 07761 } 07762 07763 return res; 07764 }
| static int vm_intro_nl | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8275 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
08276 { 08277 /* Introduce messages they have */ 08278 int res; 08279 res = ast_play_and_wait(chan, "vm-youhave"); 08280 if (!res) { 08281 if (vms->newmessages) { 08282 res = say_and_wait(chan, vms->newmessages, chan->language); 08283 if (!res) { 08284 if (vms->newmessages == 1) 08285 res = ast_play_and_wait(chan, "vm-INBOXs"); 08286 else 08287 res = ast_play_and_wait(chan, "vm-INBOX"); 08288 } 08289 if (vms->oldmessages && !res) 08290 res = ast_play_and_wait(chan, "vm-and"); 08291 else if (!res) { 08292 if ((vms->newmessages == 1)) 08293 res = ast_play_and_wait(chan, "vm-message"); 08294 else 08295 res = ast_play_and_wait(chan, "vm-messages"); 08296 } 08297 08298 } 08299 if (!res && vms->oldmessages) { 08300 res = say_and_wait(chan, vms->oldmessages, chan->language); 08301 if (!res) { 08302 if (vms->oldmessages == 1) 08303 res = ast_play_and_wait(chan, "vm-Olds"); 08304 else 08305 res = ast_play_and_wait(chan, "vm-Old"); 08306 } 08307 if (!res) { 08308 if (vms->oldmessages == 1) 08309 res = ast_play_and_wait(chan, "vm-message"); 08310 else 08311 res = ast_play_and_wait(chan, "vm-messages"); 08312 } 08313 } 08314 if (!res) { 08315 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08316 res = ast_play_and_wait(chan, "vm-no"); 08317 if (!res) 08318 res = ast_play_and_wait(chan, "vm-messages"); 08319 } 08320 } 08321 } 08322 return res; 08323 }
| static int vm_intro_no | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8041 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
08042 { 08043 /* Introduce messages they have */ 08044 int res; 08045 08046 res = ast_play_and_wait(chan, "vm-youhave"); 08047 if (res) 08048 return res; 08049 08050 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08051 res = ast_play_and_wait(chan, "vm-no"); 08052 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 08053 return res; 08054 } 08055 08056 if (vms->newmessages) { 08057 if ((vms->newmessages == 1)) { 08058 res = ast_play_and_wait(chan, "digits/1"); 08059 res = res ? res : ast_play_and_wait(chan, "vm-ny"); 08060 res = res ? res : ast_play_and_wait(chan, "vm-message"); 08061 } else { 08062 res = say_and_wait(chan, vms->newmessages, chan->language); 08063 res = res ? res : ast_play_and_wait(chan, "vm-nye"); 08064 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 08065 } 08066 if (!res && vms->oldmessages) 08067 res = ast_play_and_wait(chan, "vm-and"); 08068 } 08069 if (!res && vms->oldmessages) { 08070 if (vms->oldmessages == 1) { 08071 res = ast_play_and_wait(chan, "digits/1"); 08072 res = res ? res : ast_play_and_wait(chan, "vm-gamel"); 08073 res = res ? res : ast_play_and_wait(chan, "vm-message"); 08074 } else { 08075 res = say_and_wait(chan, vms->oldmessages, chan->language); 08076 res = res ? res : ast_play_and_wait(chan, "vm-gamle"); 08077 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 08078 } 08079 } 08080 08081 return res; 08082 }
| static int vm_intro_pl | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 7926 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, num, vm_state::oldmessages, and say_and_wait().
Referenced by vm_intro().
07927 { 07928 /* Introduce messages they have */ 07929 int res; 07930 div_t num; 07931 07932 if (!vms->oldmessages && !vms->newmessages) { 07933 res = ast_play_and_wait(chan, "vm-no"); 07934 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 07935 return res; 07936 } else { 07937 res = ast_play_and_wait(chan, "vm-youhave"); 07938 } 07939 07940 if (vms->newmessages) { 07941 num = div(vms->newmessages, 10); 07942 if (vms->newmessages == 1) { 07943 res = ast_play_and_wait(chan, "digits/1-a"); 07944 res = res ? res : ast_play_and_wait(chan, "vm-new-a"); 07945 res = res ? res : ast_play_and_wait(chan, "vm-message"); 07946 } else if (num.rem > 1 && num.rem < 5 && num.quot != 1) { 07947 if (num.rem == 2) { 07948 if (!num.quot) { 07949 res = ast_play_and_wait(chan, "digits/2-ie"); 07950 } else { 07951 res = say_and_wait(chan, vms->newmessages - 2 , chan->language); 07952 res = res ? res : ast_play_and_wait(chan, "digits/2-ie"); 07953 } 07954 } else { 07955 res = say_and_wait(chan, vms->newmessages, chan->language); 07956 } 07957 res = res ? res : ast_play_and_wait(chan, "vm-new-e"); 07958 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 07959 } else { 07960 res = say_and_wait(chan, vms->newmessages, chan->language); 07961 res = res ? res : ast_play_and_wait(chan, "vm-new-ych"); 07962 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 07963 } 07964 if (!res && vms->oldmessages) 07965 res = ast_play_and_wait(chan, "vm-and"); 07966 } 07967 if (!res && vms->oldmessages) { 07968 num = div(vms->oldmessages, 10); 07969 if (vms->oldmessages == 1) { 07970 res = ast_play_and_wait(chan, "digits/1-a"); 07971 res = res ? res : ast_play_and_wait(chan, "vm-old-a"); 07972 res = res ? res : ast_play_and_wait(chan, "vm-message"); 07973 } else if (num.rem > 1 && num.rem < 5 && num.quot != 1) { 07974 if (num.rem == 2) { 07975 if (!num.quot) { 07976 res = ast_play_and_wait(chan, "digits/2-ie"); 07977 } else { 07978 res = say_and_wait(chan, vms->oldmessages - 2 , chan->language); 07979 res = res ? res : ast_play_and_wait(chan, "digits/2-ie"); 07980 } 07981 } else { 07982 res = say_and_wait(chan, vms->oldmessages, chan->language); 07983 } 07984 res = res ? res : ast_play_and_wait(chan, "vm-old-e"); 07985 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 07986 } else { 07987 res = say_and_wait(chan, vms->oldmessages, chan->language); 07988 res = res ? res : ast_play_and_wait(chan, "vm-old-ych"); 07989 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 07990 } 07991 } 07992 07993 return res; 07994 }
| static int vm_intro_pt | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8326 of file app_voicemail.c.
References AST_DIGIT_ANY, ast_play_and_wait(), ast_say_number(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and vm_state::urgentmessages.
Referenced by vm_intro().
08327 { 08328 /* Introduce messages they have */ 08329 int res; 08330 res = ast_play_and_wait(chan, "vm-youhave"); 08331 if (!res) { 08332 if (vms->newmessages) { 08333 res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, "f"); 08334 if (!res) { 08335 if ((vms->newmessages == 1)) { 08336 res = ast_play_and_wait(chan, "vm-message"); 08337 if (!res) 08338 res = ast_play_and_wait(chan, "vm-INBOXs"); 08339 } else { 08340 res = ast_play_and_wait(chan, "vm-messages"); 08341 if (!res) 08342 res = ast_play_and_wait(chan, "vm-INBOX"); 08343 } 08344 } 08345 if (vms->oldmessages && !res) 08346 res = ast_play_and_wait(chan, "vm-and"); 08347 } 08348 if (!res && vms->oldmessages) { 08349 res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f"); 08350 if (!res) { 08351 if (vms->oldmessages == 1) { 08352 res = ast_play_and_wait(chan, "vm-message"); 08353 if (!res) 08354 res = ast_play_and_wait(chan, "vm-Olds"); 08355 } else { 08356 res = ast_play_and_wait(chan, "vm-messages"); 08357 if (!res) 08358 res = ast_play_and_wait(chan, "vm-Old"); 08359 } 08360 } 08361 } 08362 if (!res) { 08363 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08364 res = ast_play_and_wait(chan, "vm-no"); 08365 if (!res) 08366 res = ast_play_and_wait(chan, "vm-messages"); 08367 } 08368 } 08369 } 08370 return res; 08371 }
| static int vm_intro_pt_BR | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8187 of file app_voicemail.c.
References AST_DIGIT_ANY, ast_play_and_wait(), ast_say_number(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, and vm_state::urgentmessages.
Referenced by vm_intro().
08187 { 08188 /* Introduce messages they have */ 08189 int res; 08190 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08191 res = ast_play_and_wait(chan, "vm-nomessages"); 08192 return res; 08193 } else { 08194 res = ast_play_and_wait(chan, "vm-youhave"); 08195 } 08196 if (vms->newmessages) { 08197 if (!res) 08198 res = ast_say_number(chan, vms->newmessages, AST_DIGIT_ANY, chan->language, "f"); 08199 if ((vms->newmessages == 1)) { 08200 if (!res) 08201 res = ast_play_and_wait(chan, "vm-message"); 08202 if (!res) 08203 res = ast_play_and_wait(chan, "vm-INBOXs"); 08204 } else { 08205 if (!res) 08206 res = ast_play_and_wait(chan, "vm-messages"); 08207 if (!res) 08208 res = ast_play_and_wait(chan, "vm-INBOX"); 08209 } 08210 if (vms->oldmessages && !res) 08211 res = ast_play_and_wait(chan, "vm-and"); 08212 } 08213 if (vms->oldmessages) { 08214 if (!res) 08215 res = ast_say_number(chan, vms->oldmessages, AST_DIGIT_ANY, chan->language, "f"); 08216 if (vms->oldmessages == 1) { 08217 if (!res) 08218 res = ast_play_and_wait(chan, "vm-message"); 08219 if (!res) 08220 res = ast_play_and_wait(chan, "vm-Olds"); 08221 } else { 08222 if (!res) 08223 res = ast_play_and_wait(chan, "vm-messages"); 08224 if (!res) 08225 res = ast_play_and_wait(chan, "vm-Old"); 08226 } 08227 } 08228 return res; 08229 }
| static int vm_intro_se | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 7997 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_state::newmessages, vm_state::oldmessages, say_and_wait(), and vm_state::urgentmessages.
Referenced by vm_intro().
07998 { 07999 /* Introduce messages they have */ 08000 int res; 08001 08002 res = ast_play_and_wait(chan, "vm-youhave"); 08003 if (res) 08004 return res; 08005 08006 if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { 08007 res = ast_play_and_wait(chan, "vm-no"); 08008 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 08009 return res; 08010 } 08011 08012 if (vms->newmessages) { 08013 if ((vms->newmessages == 1)) { 08014 res = ast_play_and_wait(chan, "digits/ett"); 08015 res = res ? res : ast_play_and_wait(chan, "vm-nytt"); 08016 res = res ? res : ast_play_and_wait(chan, "vm-message"); 08017 } else { 08018 res = say_and_wait(chan, vms->newmessages, chan->language); 08019 res = res ? res : ast_play_and_wait(chan, "vm-nya"); 08020 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 08021 } 08022 if (!res && vms->oldmessages) 08023 res = ast_play_and_wait(chan, "vm-and"); 08024 } 08025 if (!res && vms->oldmessages) { 08026 if (vms->oldmessages == 1) { 08027 res = ast_play_and_wait(chan, "digits/ett"); 08028 res = res ? res : ast_play_and_wait(chan, "vm-gammalt"); 08029 res = res ? res : ast_play_and_wait(chan, "vm-message"); 08030 } else { 08031 res = say_and_wait(chan, vms->oldmessages, chan->language); 08032 res = res ? res : ast_play_and_wait(chan, "vm-gamla"); 08033 res = res ? res : ast_play_and_wait(chan, "vm-messages"); 08034 } 08035 } 08036 08037 return res; 08038 }
| static int vm_intro_zh | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms | |||
| ) | [static] |
Definition at line 8450 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().
08451 { 08452 int res; 08453 /* Introduce messages they have */ 08454 res = ast_play_and_wait(chan, "vm-you"); 08455 08456 if (!res && vms->newmessages) { 08457 res = ast_play_and_wait(chan, "vm-have"); 08458 if (!res) 08459 res = say_and_wait(chan, vms->newmessages, chan->language); 08460 if (!res) 08461 res = ast_play_and_wait(chan, "vm-tong"); 08462 if (!res) 08463 res = ast_play_and_wait(chan, "vm-INBOX"); 08464 if (vms->oldmessages && !res) 08465 res = ast_play_and_wait(chan, "vm-and"); 08466 else if (!res) 08467 res = ast_play_and_wait(chan, "vm-messages"); 08468 } 08469 if (!res && vms->oldmessages) { 08470 res = ast_play_and_wait(chan, "vm-have"); 08471 if (!res) 08472 res = say_and_wait(chan, vms->oldmessages, chan->language); 08473 if (!res) 08474 res = ast_play_and_wait(chan, "vm-tong"); 08475 if (!res) 08476 res = ast_play_and_wait(chan, "vm-Old"); 08477 if (!res) 08478 res = ast_play_and_wait(chan, "vm-messages"); 08479 } 08480 if (!res && !vms->oldmessages && !vms->newmessages) { 08481 res = ast_play_and_wait(chan, "vm-haveno"); 08482 if (!res) 08483 res = ast_play_and_wait(chan, "vm-messages"); 08484 } 08485 return res; 08486 }
| static int vm_lock_path | ( | const char * | path | ) | [static] |
Lock file path only return failure if ast_lock_path returns 'timeout', not if the path does not exist or any other reason.
Definition at line 3043 of file app_voicemail.c.
References ast_lock_path(), and AST_LOCK_TIMEOUT.
Referenced by close_mailbox(), copy_message(), count_messages(), leave_voicemail(), open_mailbox(), and save_to_folder().
03044 { 03045 switch (ast_lock_path(path)) { 03046 case AST_LOCK_TIMEOUT: 03047 return -1; 03048 default: 03049 return 0; 03050 } 03051 }
| static FILE* vm_mkftemp | ( | char * | template | ) | [static] |
Definition at line 1479 of file app_voicemail.c.
References VOICEMAIL_FILE_MODE.
Referenced by sendmail(), and sendpage().
01480 { 01481 FILE *p = NULL; 01482 int pfd = mkstemp(template); 01483 chmod(template, VOICEMAIL_FILE_MODE & ~my_umask); 01484 if (pfd > -1) { 01485 p = fdopen(pfd, "w+"); 01486 if (!p) { 01487 close(pfd); 01488 pfd = -1; 01489 } 01490 } 01491 return p; 01492 }
| static 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 8659 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_CENT, adsi_logo(), ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_line, ast_adsi_transmit_message, ast_adsi_voice_mode, ast_debug, ast_fileexists(), ast_log(), AST_LOG_NOTICE, ast_play_and_wait(), ast_readstring(), ast_strlen_zero(), ast_test_flag, check_password(), ast_vm_user::context, play_record_review(), PWDCHANGE_EXTERNAL, PWDCHANGE_INTERNAL, vm_state::username, vm_change_password(), vm_change_password_shell(), VM_FORCEGREET, VM_FORCENAME, vm_invalid_password, vm_mismatch, vm_newpassword, vm_passchanged, vm_pls_try_again, and vm_reenterpassword.
Referenced by vm_execmain().
08660 { 08661 int cmd = 0; 08662 int duration = 0; 08663 int tries = 0; 08664 char newpassword[80] = ""; 08665 char newpassword2[80] = ""; 08666 char prefile[PATH_MAX] = ""; 08667 unsigned char buf[256]; 08668 int bytes=0; 08669 08670 if (ast_adsi_available(chan)) { 08671 bytes += adsi_logo(buf + bytes); 08672 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "New User Setup", ""); 08673 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", ""); 08674 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 08675 bytes += ast_adsi_voice_mode(buf + bytes, 0); 08676 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 08677 } 08678 08679 /* First, have the user change their password 08680 so they won't get here again */ 08681 for (;;) { 08682 newpassword[1] = '\0'; 08683 newpassword[0] = cmd = ast_play_and_wait(chan, vm_newpassword); 08684 if (cmd == '#') 08685 newpassword[0] = '\0'; 08686 if (cmd < 0 || cmd == 't' || cmd == '#') 08687 return cmd; 08688 cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#"); 08689 if (cmd < 0 || cmd == 't' || cmd == '#') 08690 return cmd; 08691 cmd = check_password(vmu, newpassword); /* perform password validation */ 08692 if (cmd != 0) { 08693 ast_log(AST_LOG_NOTICE, "Invalid password for user %s (%s)\n", vms->username, newpassword); 08694 cmd = ast_play_and_wait(chan, vm_invalid_password); 08695 } else { 08696 newpassword2[1] = '\0'; 08697 newpassword2[0] = cmd = ast_play_and_wait(chan, vm_reenterpassword); 08698 if (cmd == '#') 08699 newpassword2[0] = '\0'; 08700 if (cmd < 0 || cmd == 't' || cmd == '#') 08701 return cmd; 08702 cmd = ast_readstring(chan, newpassword2 + strlen(newpassword2), sizeof(newpassword2) - 1, 2000, 10000, "#"); 08703 if (cmd < 0 || cmd == 't' || cmd == '#') 08704 return cmd; 08705 if (!strcmp(newpassword, newpassword2)) 08706 break; 08707 ast_log(AST_LOG_NOTICE, "Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2); 08708 cmd = ast_play_and_wait(chan, vm_mismatch); 08709 } 08710 if (++tries == 3) 08711 return -1; 08712 if (cmd != 0) { 08713 cmd = ast_play_and_wait(chan, vm_pls_try_again); 08714 } 08715 } 08716 if (pwdchange & PWDCHANGE_INTERNAL) 08717 vm_change_password(vmu, newpassword); 08718 if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd)) 08719 vm_change_password_shell(vmu, newpassword); 08720 08721 ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); 08722 cmd = ast_play_and_wait(chan, vm_passchanged); 08723 08724 /* If forcename is set, have the user record their name */ 08725 if (ast_test_flag(vmu, VM_FORCENAME)) { 08726 snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); 08727 if (ast_fileexists(prefile, NULL, NULL) < 1) { 08728 cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08729 if (cmd < 0 || cmd == 't' || cmd == '#') 08730 return cmd; 08731 } 08732 } 08733 08734 /* If forcegreetings is set, have the user record their greetings */ 08735 if (ast_test_flag(vmu, VM_FORCEGREET)) { 08736 snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); 08737 if (ast_fileexists(prefile, NULL, NULL) < 1) { 08738 cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08739 if (cmd < 0 || cmd == 't' || cmd == '#') 08740 return cmd; 08741 } 08742 08743 snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); 08744 if (ast_fileexists(prefile, NULL, NULL) < 1) { 08745 cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08746 if (cmd < 0 || cmd == 't' || cmd == '#') 08747 return cmd; 08748 } 08749 } 08750 08751 return cmd; 08752 }
| static 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 8754 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_CENT, adsi_logo(), ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_line, ast_adsi_transmit_message, ast_adsi_voice_mode, ast_debug, ast_fileexists(), ast_log(), AST_LOG_NOTICE, ast_play_and_wait(), ast_readstring(), ast_strlen_zero(), ast_waitfordigit(), check_password(), ast_vm_user::context, DISPOSE, ast_vm_user::mailbox, ast_vm_user::password, play_record_review(), PWDCHANGE_EXTERNAL, PWDCHANGE_INTERNAL, RETRIEVE, vm_state::username, vm_change_password(), vm_change_password_shell(), vm_invalid_password, vm_mismatch, vm_newpassword, vm_passchanged, vm_pls_try_again, vm_reenterpassword, and vm_tempgreeting().
Referenced by vm_execmain().
08755 { 08756 int cmd = 0; 08757 int retries = 0; 08758 int duration = 0; 08759 char newpassword[80] = ""; 08760 char newpassword2[80] = ""; 08761 char prefile[PATH_MAX] = ""; 08762 unsigned char buf[256]; 08763 int bytes=0; 08764 08765 if (ast_adsi_available(chan)) { 08766 bytes += adsi_logo(buf + bytes); 08767 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Options Menu", ""); 08768 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", ""); 08769 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 08770 bytes += ast_adsi_voice_mode(buf + bytes, 0); 08771 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 08772 } 08773 while ((cmd >= 0) && (cmd != 't')) { 08774 if (cmd) 08775 retries = 0; 08776 switch (cmd) { 08777 case '1': /* Record your unavailable message */ 08778 snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); 08779 cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08780 break; 08781 case '2': /* Record your busy message */ 08782 snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); 08783 cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08784 break; 08785 case '3': /* Record greeting */ 08786 snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); 08787 cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08788 break; 08789 case '4': /* manage the temporary greeting */ 08790 cmd = vm_tempgreeting(chan, vmu, vms, fmtc, record_gain); 08791 break; 08792 case '5': /* change password */ 08793 if (vmu->password[0] == '-') { 08794 cmd = ast_play_and_wait(chan, "vm-no"); 08795 break; 08796 } 08797 newpassword[1] = '\0'; 08798 newpassword[0] = cmd = ast_play_and_wait(chan, vm_newpassword); 08799 if (cmd == '#') 08800 newpassword[0] = '\0'; 08801 else { 08802 if (cmd < 0) 08803 break; 08804 if ((cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#")) < 0) { 08805 break; 08806 } 08807 } 08808 cmd = check_password(vmu, newpassword); /* perform password validation */ 08809 if (cmd != 0) { 08810 ast_log(AST_LOG_NOTICE, "Invalid password for user %s (%s)\n", vms->username, newpassword); 08811 cmd = ast_play_and_wait(chan, vm_invalid_password); 08812 if (!cmd) { 08813 cmd = ast_play_and_wait(chan, vm_pls_try_again); 08814 } 08815 break; 08816 } 08817 newpassword2[1] = '\0'; 08818 newpassword2[0] = cmd = ast_play_and_wait(chan, vm_reenterpassword); 08819 if (cmd == '#') 08820 newpassword2[0] = '\0'; 08821 else { 08822 if (cmd < 0) 08823 break; 08824 08825 if ((cmd = ast_readstring(chan,newpassword2 + strlen(newpassword2),sizeof(newpassword2)-1,2000,10000,"#")) < 0) { 08826 break; 08827 } 08828 } 08829 if (strcmp(newpassword, newpassword2)) { 08830 ast_log(AST_LOG_NOTICE, "Password mismatch for user %s (%s != %s)\n", vms->username, newpassword, newpassword2); 08831 cmd = ast_play_and_wait(chan, vm_mismatch); 08832 if (!cmd) { 08833 cmd = ast_play_and_wait(chan, vm_pls_try_again); 08834 } 08835 break; 08836 } 08837 if (pwdchange & PWDCHANGE_INTERNAL) 08838 vm_change_password(vmu, newpassword); 08839 if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd)) 08840 vm_change_password_shell(vmu, newpassword); 08841 08842 ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); 08843 cmd = ast_play_and_wait(chan, vm_passchanged); 08844 break; 08845 case '*': 08846 cmd = 't'; 08847 break; 08848 default: 08849 cmd = 0; 08850 snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username); 08851 RETRIEVE(prefile, -1, vmu->mailbox, vmu->context); 08852 if (ast_fileexists(prefile, NULL, NULL)) { 08853 cmd = ast_play_and_wait(chan, "vm-tmpexists"); 08854 } 08855 DISPOSE(prefile, -1); 08856 if (!cmd) { 08857 cmd = ast_play_and_wait(chan, "vm-options"); 08858 } 08859 if (!cmd) { 08860 cmd = ast_waitfordigit(chan,6000); 08861 } 08862 if (!cmd) { 08863 retries++; 08864 } 08865 if (retries > 3) { 08866 cmd = 't'; 08867 } 08868 } 08869 } 08870 if (cmd == 't') 08871 cmd = 0; 08872 return cmd; 08873 }
| static int vm_play_folder_name | ( | struct ast_channel * | chan, | |
| char * | mbox | |||
| ) | [static] |
Definition at line 7598 of file app_voicemail.c.
References ast_play_and_wait(), ast_channel::language, vm_play_folder_name_gr(), vm_play_folder_name_pl(), and vm_play_folder_name_ua().
Referenced by get_folder(), vm_execmain(), vm_instructions_en(), and vm_instructions_zh().
07599 { 07600 int cmd; 07601 07602 if ( !strncasecmp(chan->language, "it", 2) || 07603 !strncasecmp(chan->language, "es", 2) || 07604 !strncasecmp(chan->language, "pt", 2)) { /* Italian, Spanish, or Portuguese syntax */ 07605 cmd = ast_play_and_wait(chan, "vm-messages"); /* "messages */ 07606 return cmd ? cmd : ast_play_and_wait(chan, box); 07607 } else if (!strncasecmp(chan->language, "gr", 2)) { 07608 return vm_play_folder_name_gr(chan, box); 07609 } else if (!strncasecmp(chan->language, "he", 2)) { /* Hebrew syntax */ 07610 return ast_play_and_wait(chan, box); 07611 } else if (!strncasecmp(chan->language, "pl", 2)) { 07612 return vm_play_folder_name_pl(chan, box); 07613 } else if (!strncasecmp(chan->language, "ua", 2)) { /* Ukrainian syntax */ 07614 return vm_play_folder_name_ua(chan, box); 07615 } else { /* Default English */ 07616 cmd = ast_play_and_wait(chan, box); 07617 return cmd ? cmd : ast_play_and_wait(chan, "vm-messages"); /* "messages */ 07618 } 07619 }
| static int vm_play_folder_name_gr | ( | struct ast_channel * | chan, | |
| char * | box | |||
| ) | [static] |
Definition at line 7551 of file app_voicemail.c.
References ast_play_and_wait().
Referenced by vm_play_folder_name().
07552 { 07553 int cmd; 07554 char *buf; 07555 07556 buf = alloca(strlen(box) + 2); 07557 strcpy(buf, box); 07558 strcat(buf,"s"); 07559 07560 if (!strcasecmp(box, "vm-INBOX") || !strcasecmp(box, "vm-Old")){ 07561 cmd = ast_play_and_wait(chan, buf); /* "NEA / PALIA" */ 07562 return cmd ? cmd : ast_play_and_wait(chan, "vm-messages"); /* "messages" -> "MYNHMATA" */ 07563 } else { 07564 cmd = ast_play_and_wait(chan, "vm-messages"); /* "messages" -> "MYNHMATA" */ 07565 return cmd ? cmd : ast_play_and_wait(chan, box); /* friends/family/work... -> "FILWN"/"OIKOGENIAS"/"DOULEIAS"*/ 07566 } 07567 }
| static int vm_play_folder_name_pl | ( | struct ast_channel * | chan, | |
| char * | box | |||
| ) | [static] |
Definition at line 7569 of file app_voicemail.c.
References ast_play_and_wait().
Referenced by vm_play_folder_name().
07570 { 07571 int cmd; 07572 07573 if (!strcasecmp(box, "vm-INBOX") || !strcasecmp(box, "vm-Old")) { 07574 if (!strcasecmp(box, "vm-INBOX")) 07575 cmd = ast_play_and_wait(chan, "vm-new-e"); 07576 else 07577 cmd = ast_play_and_wait(chan, "vm-old-e"); 07578 return cmd ? cmd : ast_play_and_wait(chan, "vm-messages"); 07579 } else { 07580 cmd = ast_play_and_wait(chan, "vm-messages"); 07581 return cmd ? cmd : ast_play_and_wait(chan, box); 07582 } 07583 }
| static int vm_play_folder_name_ua | ( | struct ast_channel * | chan, | |
| char * | box | |||
| ) | [static] |
Definition at line 7585 of file app_voicemail.c.
References ast_play_and_wait().
Referenced by vm_play_folder_name().
07586 { 07587 int cmd; 07588 07589 if (!strcasecmp(box, "vm-Family") || !strcasecmp(box, "vm-Friends") || !strcasecmp(box, "vm-Work")){ 07590 cmd = ast_play_and_wait(chan, "vm-messages"); 07591 return cmd ? cmd : ast_play_and_wait(chan, box); 07592 } else { 07593 cmd = ast_play_and_wait(chan, box); 07594 return cmd ? cmd : ast_play_and_wait(chan, "vm-messages"); 07595 } 07596 }
| static int vm_tempgreeting | ( | struct ast_channel * | chan, | |
| struct ast_vm_user * | vmu, | |||
| struct vm_state * | vms, | |||
| char * | fmtc, | |||
| signed char | record_gain | |||
| ) | [static] |
The handler for 'record a temporary greeting'.
| chan | ||
| vmu | ||
| vms | ||
| fmtc | ||
| record_gain | This is option 4 from the mailbox options menu. This function manages the following promptings: 1: play / record / review the temporary greeting. : invokes play_record_review(). 2: remove (delete) the temporary greeting. *: return to the main menu. |
Definition at line 8891 of file app_voicemail.c.
References ADSI_COMM_PAGE, ADSI_JUST_CENT, adsi_logo(), ADSI_MSG_DISPLAY, ast_adsi_available, ast_adsi_display, ast_adsi_set_line, ast_adsi_transmit_message, ast_adsi_voice_mode, ast_fileexists(), ast_play_and_wait(), ast_waitfordigit(), ast_vm_user::context, DELETE, DISPOSE, ast_vm_user::mailbox, play_record_review(), RETRIEVE, and vm_state::username.
Referenced by vm_options().
08892 { 08893 int cmd = 0; 08894 int retries = 0; 08895 int duration = 0; 08896 char prefile[PATH_MAX] = ""; 08897 unsigned char buf[256]; 08898 int bytes = 0; 08899 08900 if (ast_adsi_available(chan)) { 08901 bytes += adsi_logo(buf + bytes); 08902 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Temp Greeting Menu", ""); 08903 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", ""); 08904 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); 08905 bytes += ast_adsi_voice_mode(buf + bytes, 0); 08906 ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); 08907 } 08908 08909 snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username); 08910 while ((cmd >= 0) && (cmd != 't')) { 08911 if (cmd) 08912 retries = 0; 08913 RETRIEVE(prefile, -1, vmu->mailbox, vmu->context); 08914 if (ast_fileexists(prefile, NULL, NULL) <= 0) { 08915 play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08916 cmd = 't'; 08917 } else { 08918 switch (cmd) { 08919 case '1': 08920 cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); 08921 break; 08922 case '2': 08923 DELETE(prefile, -1, prefile, vmu); 08924 ast_play_and_wait(chan, "vm-tempremoved"); 08925 cmd = 't'; 08926 break; 08927 case '*': 08928 cmd = 't'; 08929 break; 08930 default: 08931 cmd = ast_play_and_wait(chan, 08932 ast_fileexists(prefile, NULL, NULL) > 0 ? /* XXX always true ? */ 08933 "vm-tempgreeting2" : "vm-tempgreeting"); 08934 if (!cmd) 08935 cmd = ast_waitfordigit(chan,6000); 08936 if (!cmd) 08937 retries++; 08938 if (retries > 3) 08939 cmd = 't'; 08940 } 08941 } 08942 DISPOSE(prefile, -1); 08943 } 08944 if (cmd == 't') 08945 cmd = 0; 08946 return cmd; 08947 }
| static int vmauthenticate | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 10180 of file app_voicemail.c.
References ast_copy_string(), AST_MAX_EXTENSION, ast_play_and_wait(), ast_strdupa, ast_strlen_zero(), ast_vm_user::context, pbx_builtin_setvar_helper(), s, strsep(), and vm_authenticate().
Referenced by load_module().
10181 { 10182 char *s = data, *user=NULL, *context=NULL, mailbox[AST_MAX_EXTENSION] = ""; 10183 struct ast_vm_user vmus; 10184 char *options = NULL; 10185 int silent = 0, skipuser = 0; 10186 int res = -1; 10187 10188 if (s) { 10189 s = ast_strdupa(s); 10190 user = strsep(&s, ","); 10191 options = strsep(&s, ","); 10192 if (user) { 10193 s = user; 10194 user = strsep(&s, "@"); 10195 context = strsep(&s, ""); 10196 if (!ast_strlen_zero(user)) 10197 skipuser++; 10198 ast_copy_string(mailbox, user, sizeof(mailbox)); 10199 } 10200 } 10201 10202 if (options) { 10203 silent = (strchr(options, 's')) != NULL; 10204 } 10205 10206 if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, skipuser, 3, silent)) { 10207 pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", mailbox); 10208 pbx_builtin_setvar_helper(chan, "AUTH_CONTEXT", vmus.context); 10209 ast_play_and_wait(chan, "auth-thankyou"); 10210 res = 0; 10211 } 10212 10213 return res; 10214 }
| static struct ast_tm* vmu_tm | ( | const struct ast_vm_user * | vmu, | |
| struct ast_tm * | tm | |||
| ) | [static, read] |
fill in *tm for current time according to the proper timezone, if any. Return tm so it can be used as a function argument.
Definition at line 4140 of file app_voicemail.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_localtime(), ast_strlen_zero(), ast_tvnow(), vm_zone::name, vm_zone::timezone, and ast_vm_user::zonetag.
Referenced by make_email_file(), and sendpage().
04141 { 04142 const struct vm_zone *z = NULL; 04143 struct timeval t = ast_tvnow(); 04144 04145 /* Does this user have a timezone specified? */ 04146 if (!ast_strlen_zero(vmu->zonetag)) { 04147 /* Find the zone in the list */ 04148 AST_LIST_LOCK(&zones); 04149 AST_LIST_TRAVERSE(&zones, z, list) { 04150 if (!strcmp(z->name, vmu->zonetag)) 04151 break; 04152 } 04153 AST_LIST_UNLOCK(&zones); 04154 } 04155 ast_localtime(&t, tm, z ? z->timezone : NULL); 04156 return tm; 04157 }
| static int wait_file | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| char * | file | |||
| ) | [static] |
Definition at line 6993 of file app_voicemail.c.
References ast_control_streamfile(), listen_control_forward_key, listen_control_pause_key, listen_control_restart_key, listen_control_reverse_key, and listen_control_stop_key.
Referenced by advanced_options(), and play_message().
06994 { 06995 return ast_control_streamfile(chan, file, listen_control_forward_key, listen_control_reverse_key, listen_control_stop_key, listen_control_pause_key, listen_control_restart_key, skipms, NULL); 06996 }
| static int wait_file2 | ( | struct ast_channel * | chan, | |
| struct vm_state * | vms, | |||
| char * | file | |||
| ) | [static] |
Definition at line 6985 of file app_voicemail.c.
References AST_DIGIT_ANY, ast_log(), AST_LOG_WARNING, and ast_stream_and_wait().
Referenced by play_message(), play_message_callerid(), and play_message_duration().
06986 { 06987 int res; 06988 if ((res = ast_stream_and_wait(chan, file, AST_DIGIT_ANY)) < 0) 06989 ast_log(AST_LOG_WARNING, "Unable to play message %s\n", file); 06990 return res; 06991 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Comedian Mail (Voicemail System)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 12023 of file app_voicemail.c.
char* addesc = "Comedian Mail" [static] |
Definition at line 707 of file app_voicemail.c.
unsigned char adsifdn[4] = "\x00\x00\x00\x0F" [static] |
Definition at line 818 of file app_voicemail.c.
Referenced by adsi_begin(), adsi_load_vmail(), and load_config().
unsigned char adsisec[4] = "\x9B\xDB\xF7\xAC" [static] |
int adsiver = 1 [static] |
Definition at line 820 of file app_voicemail.c.
Referenced by adsi_begin(), adsi_load_vmail(), and load_config().
char* app = "VoiceMail" [static] |
Definition at line 710 of file app_voicemail.c.
char* app2 = "VoiceMailMain" [static] |
Definition at line 713 of file app_voicemail.c.
char* app3 = "MailboxExists" [static] |
Definition at line 715 of file app_voicemail.c.
char* app4 = "VMAuthenticate" [static] |
Definition at line 716 of file app_voicemail.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 12023 of file app_voicemail.c.
char callcontext[AST_MAX_CONTEXT] = "" [static] |
Definition at line 804 of file app_voicemail.c.
Referenced by load_config(), and populate_defaults().
char charset[32] = "ISO-8859-1" [static] |
Definition at line 816 of file app_voicemail.c.
Referenced by encode_mime_str(), load_config(), make_email_file(), and tds_load_module().
char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64] [static] |
Definition at line 807 of file app_voicemail.c.
Referenced by load_config(), and play_message_callerid().
struct ast_cli_entry cli_voicemail[] [static] |
Initial value:
{
AST_CLI_DEFINE(handle_voicemail_show_users, "List defined voicemail boxes"),
AST_CLI_DEFINE(handle_voicemail_show_zones, "List zone message formats"),
AST_CLI_DEFINE(handle_voicemail_reload, "Reload voicemail configuration"),
}
Definition at line 10412 of file app_voicemail.c.
Referenced by load_module(), and unload_module().
char dialcontext[AST_MAX_CONTEXT] = "" [static] |
Definition at line 803 of file app_voicemail.c.
Referenced by dial_exec_full(), directory_exec(), load_config(), populate_defaults(), ring_entry(), and wait_for_answer().
char* emailbody = NULL [static] |
Definition at line 810 of file app_voicemail.c.
Referenced by load_config(), make_email_file(), and message_template_parse_emailbody().
char emaildateformat[32] = "%A, %B %d, %Y at %r" [static] |
Definition at line 821 of file app_voicemail.c.
Referenced by load_config(), make_email_file(), and prep_email_sub_vars().
char* emailsubject = NULL [static] |
char exitcontext[AST_MAX_CONTEXT] = "" [static] |
Definition at line 805 of file app_voicemail.c.
Referenced by common_exec(), conf_run(), load_config(), and populate_defaults().
char ext_pass_check_cmd[128] [static] |
Definition at line 687 of file app_voicemail.c.
char ext_pass_cmd[128] [static] |
Definition at line 686 of file app_voicemail.c.
char externnotify[160] [static] |
Definition at line 727 of file app_voicemail.c.
char fromstring[100] [static] |
Definition at line 814 of file app_voicemail.c.
Referenced by load_config(), make_email_file(), and sendpage().
struct ast_flags globalflags = {0} [static] |
Definition at line 799 of file app_voicemail.c.
Referenced by find_or_create(), find_user(), find_user_realtime(), forward_message(), load_config(), make_email_file(), populate_defaults(), sendmail(), and vm_execmain().
| struct ao2_container* inprocess_container |
Definition at line 838 of file app_voicemail.c.
Referenced by inprocess_count(), load_module(), and unload_module().
char listen_control_forward_key[12] [static] |
char listen_control_pause_key[12] [static] |
char listen_control_restart_key[12] [static] |
char listen_control_reverse_key[12] [static] |
char listen_control_stop_key[12] [static] |
struct ast_custom_function mailbox_exists_acf [static] |
Initial value:
{
.name = "MAILBOX_EXISTS",
.read = acf_mailbox_exists,
}
Definition at line 10175 of file app_voicemail.c.
Referenced by load_module(), and unload_module().
char mailcmd[160] [static] |
Definition at line 726 of file app_voicemail.c.
int maxdeletedmsg [static] |
Definition at line 723 of file app_voicemail.c.
int maxgreet [static] |
Definition at line 733 of file app_voicemail.c.
int maxlogins [static] |
Definition at line 735 of file app_voicemail.c.
int maxmsg [static] |
Definition at line 722 of file app_voicemail.c.
int maxsilence [static] |
int minpassword [static] |
Definition at line 736 of file app_voicemail.c.
struct ast_event_sub* mwi_sub_sub [static] |
Subscription to ... MWI event subscriptions
Definition at line 753 of file app_voicemail.c.
struct ast_taskprocessor* mwi_subscription_tps [static] |
Definition at line 779 of file app_voicemail.c.
Referenced by load_module(), mwi_sub_event_cb(), mwi_unsub_event_cb(), and unload_module().
struct ast_event_sub* mwi_unsub_sub [static] |
Subscription to ... MWI event un-subscriptions
Definition at line 755 of file app_voicemail.c.
int my_umask [static] |
Definition at line 689 of file app_voicemail.c.
char* pagerbody = NULL [static] |
char pagerfromstring[100] [static] |
char* pagersubject = NULL [static] |
ast_cond_t poll_cond = PTHREAD_COND_INITIALIZER [static] |
Definition at line 748 of file app_voicemail.c.
unsigned int poll_freq [static] |
Polling frequency
Definition at line 743 of file app_voicemail.c.
ast_mutex_t poll_lock = ((ast_mutex_t) PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP ) [static] |
Definition at line 747 of file app_voicemail.c.
Referenced by mb_poll_thread(), and stop_poll_thread().
unsigned int poll_mailboxes [static] |
Poll mailboxes for changes since there is something external to app_voicemail that may change them.
Definition at line 740 of file app_voicemail.c.
pthread_t poll_thread = AST_PTHREADT_NULL [static] |
Definition at line 749 of file app_voicemail.c.
unsigned char poll_thread_run [static] |
Definition at line 750 of file app_voicemail.c.
int pwdchange = PWDCHANGE_INTERNAL [static] |
Definition at line 693 of file app_voicemail.c.
int saydurationminfo [static] |
Definition at line 801 of file app_voicemail.c.
Referenced by load_config(), and populate_defaults().
char serveremail[80] [static] |
Definition at line 725 of file app_voicemail.c.
int silencethreshold = 128 [static] |
Definition at line 724 of file app_voicemail.c.
Referenced by ast_record_review(), and setup_privacy_args().
int skipms [static] |
Definition at line 734 of file app_voicemail.c.
Referenced by controlplayback_exec(), and handle_controlstreamfile().
struct ast_smdi_interface* smdi_iface = NULL [static] |
Definition at line 728 of file app_voicemail.c.
char userscontext[AST_MAX_EXTENSION] = "default" [static] |
Definition at line 705 of file app_voicemail.c.
struct ast_app_option vm_app_options[128] = { [ 's' ] = { .flag = OPT_SILENT }, [ 'b' ] = { .flag = OPT_BUSY_GREETING }, [ 'u' ] = { .flag = OPT_UNAVAIL_GREETING }, [ 'g' ] = { .flag = OPT_RECORDGAIN , .arg_index = OPT_ARG_RECORDGAIN + 1 }, [ 'd' ] = { .flag = OPT_DTMFEXIT , .arg_index = OPT_ARG_DTMFEXIT + 1 }, [ 'p' ] = { .flag = OPT_PREPEND_MAILBOX }, [ 'a' ] = { .flag = OPT_AUTOPLAY , .arg_index = OPT_ARG_PLAYFOLDER + 1 }, [ 'U' ] = { .flag = OPT_MESSAGE_Urgent }, [ 'P' ] = { .flag = OPT_MESSAGE_PRIORITY }} [static] |
| enum { ... } vm_box |
char vm_invalid_password[80] = "vm-invalid-password" [static] |
Definition at line 796 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
char vm_mismatch[80] = "vm-mismatch" [static] |
Definition at line 795 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
char vm_newpassword[80] = "vm-newpassword" [static] |
Definition at line 792 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
| enum { ... } vm_option_args |
| enum { ... } vm_option_flags |
char vm_passchanged[80] = "vm-passchanged" [static] |
Definition at line 793 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
char vm_password[80] = "vm-password" [static] |
char vm_pls_try_again[80] = "vm-pls-try-again" [static] |
Definition at line 797 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
char vm_reenterpassword[80] = "vm-reenterpassword" [static] |
Definition at line 794 of file app_voicemail.c.
Referenced by load_config(), vm_newuser(), and vm_options().
char VM_SPOOL_DIR[PATH_MAX] [static] |
Definition at line 684 of file app_voicemail.c.
char vmfmts[80] [static] |
Definition at line 729 of file app_voicemail.c.
int vmmaxsecs [static] |
Definition at line 732 of file app_voicemail.c.
int vmminsecs [static] |
Definition at line 731 of file app_voicemail.c.
double volgain [static] |
Definition at line 730 of file app_voicemail.c.
char zonetag[80] [static] |
1.5.9