Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Data Structures | Macros | Enumerations | Functions | Variables
app_voicemail.c File Reference

Comedian Mail - Voicemail System. More...

#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/mwi.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/strings.h"
#include "asterisk/smdi.h"
#include "asterisk/astobj2.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/test.h"
#include "asterisk/format_cache.h"
Include dependency graph for app_voicemail.c:

Go to the source code of this file.

Data Structures

struct  alias_mailbox_mapping
 
struct  ast_vm_user
 
struct  inprocess
 
struct  leave_vm_options
 Options for leaving voicemail with the voicemail() application. More...
 
struct  mailbox_alias_mapping
 
struct  users
 list of users found in the config file More...
 
struct  vm_state
 
struct  vm_zone
 
struct  zones
 

Macros

#define ALIASES_OUTPUT_FORMAT   "%-32s %-32s\n"
 
#define ASTERISK_USERNAME   "asterisk"
 
#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 ERROR_MAX_MSGS   -101
 
#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 MAPPING_BUCKETS   511
 
#define MAX_DATETIME_FORMAT   512
 
#define MAX_MAIL_BODY_CONTENT_SIZE   134217728L
 
#define MAX_NUM_CID_CONTEXTS   10
 
#define MAX_VM_CONTEXT_LEN   (AST_MAX_CONTEXT)
 
#define MAX_VM_MAILBOX_LEN   (MAX_VM_MBOX_ID_LEN + MAX_VM_CONTEXT_LEN)
 
#define MAX_VM_MBOX_ID_LEN   (AST_MAX_EXTENSION)
 
#define MAXMSG   100
 
#define MAXMSGLIMIT   9999
 
#define MINPASSWORD   0
 
#define MSG_ID_LEN   256
 
#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 /* 1 second */
 
#define STORE(a, b, c, d, e, f, g, h, i, j, k)
 
#define tdesc   "Comedian Mail (Voicemail System)"
 
#define UPDATE_MSG_ID(a, b, c, d, e, f)
 
#define VALID_DTMF   "1234567890*#" /* Yes ABCD are valid dtmf but what phones have those? */
 
#define VM_ALLOCED   (1 << 13)
 
#define VM_ATTACH   (1 << 11)
 
#define VM_DELETE   (1 << 12)
 
#define VM_DIRECTFORWARD   (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  vm_box {
  NEW_FOLDER = 0 , OLD_FOLDER = 1 , WORK_FOLDER = 2 , FAMILY_FOLDER = 3 ,
  FRIENDS_FOLDER = 4 , GREETINGS_FOLDER = -1
}
 
enum  vm_option_args {
  OPT_ARG_RECORDGAIN = 0 , OPT_ARG_PLAYFOLDER = 1 , OPT_ARG_DTMFEXIT = 2 , OPT_ARG_BEEP_TONE = 3 ,
  OPT_ARG_ARRAY_SIZE = 4
}
 
enum  vm_option_flags {
  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) , OPT_EARLYM_GREETING = (1 << 10) , OPT_BEEP = (1 << 11) , OPT_SILENT_IF_GREET = (1 << 12)
}
 
enum  vm_passwordlocation { OPT_PWLOC_VOICEMAILCONF = 0 , OPT_PWLOC_SPOOLDIR = 1 , OPT_PWLOC_USERSCONF = 2 }
 

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_vm_info (struct ast_channel *chan, const char *cmd, char *args, char *buf, size_t len)
 
static int actual_load_config (int reload, struct ast_config *cfg, struct ast_config *ucfg)
 
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 int add_message_id (struct ast_config *msg_cfg, char *dir, int msg, char *filename, char *id, size_t id_size, struct ast_vm_user *vmu, int folder)
 
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. More...
 
static struct alias_mailbox_mappingalias_mailbox_mapping_create (const char *alias, const char *mailbox)
 
 AO2_STRING_FIELD_CMP_FN (alias_mailbox_mapping, alias)
 
 AO2_STRING_FIELD_CMP_FN (mailbox_alias_mapping, mailbox)
 
 AO2_STRING_FIELD_HASH_FN (alias_mailbox_mapping, alias)
 
 AO2_STRING_FIELD_HASH_FN (mailbox_alias_mapping, mailbox)
 
static int append_mailbox (const char *context, const char *box, const char *data)
 
static int append_vmu_info_astman (struct mansession *s, struct ast_vm_user *vmu, const char *event_name, const char *actionid)
 Append vmu info string into given astman with event_name. More...
 
static void apply_option (struct ast_vm_user *vmu, const char *var, const char *value)
 Sets a specific property value. More...
 
static void apply_options (struct ast_vm_user *vmu, const char *options)
 Destructively Parse options and apply. More...
 
static void apply_options_full (struct ast_vm_user *retval, struct ast_variable *var)
 Loads the options specific to a voicemail user. More...
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static const char * ast_str_encode_mime (struct ast_str **end, ssize_t maxlen, const char *start, 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. More...
 
static const char * ast_str_quote (struct ast_str **buf, ssize_t maxlen, const char *from)
 Wraps a character sequence in double quotes, escaping occurences of quotes within the string. More...
 
static int change_password_realtime (struct ast_vm_user *vmu, const char *password)
 Performs a change of the voicemail passowrd in the realtime engine. More...
 
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. More...
 
static int check_password (struct ast_vm_user *vmu, char *password)
 Check that password meets minimum required length. More...
 
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. More...
 
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, const char *dest_folder)
 Copies a message from one mailbox to another. More...
 
static void copy_plain_file (char *frompath, char *topath)
 Copies a voicemail information (envelope) file. More...
 
static int count_messages (struct ast_vm_user *vmu, char *dir)
 Find all .txt files - even if they are not in sequence from 0000. More...
 
static int create_dirpath (char *dest, int len, const char *context, const char *ext, const char *folder)
 basically mkdir -p $dest/$context/$ext/$folder More...
 
static int dialout (struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)
 
static struct ast_vm_userfind_or_create (const char *context, const char *box)
 
static struct ast_vm_userfind_user (struct ast_vm_user *ivm, const char *context, const char *mailbox)
 Finds a voicemail user from the users file or the realtime engine. More...
 
static struct ast_vm_userfind_user_realtime (struct ast_vm_user *ivm, const char *context, const char *mailbox)
 Finds a voicemail user from the realtime engine. More...
 
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. More...
 
static void free_user (struct ast_vm_user *vmu)
 
static void free_user_final (struct ast_vm_user *vmu)
 
static void free_vm_users (void)
 Free the users structure. More...
 
static void free_vm_zones (void)
 Free the zones structure. More...
 
static void free_zone (struct vm_zone *z)
 
static void generate_msg_id (char *dst)
 Sets the destination string to a uniquely identifying msg_id string. More...
 
static int get_date (char *s, int len)
 Gets the current date and time, as formatted string. More...
 
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 More...
 
static int get_folder2 (struct ast_channel *chan, char *fn, int start)
 plays a prompt and waits for a keypress. More...
 
static int get_folder_by_name (const char *name)
 
static int get_folder_ja (struct ast_channel *chan, int start)
 
static char * handle_voicemail_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Reload voicemail configuration from the CLI. More...
 
static char * handle_voicemail_show_aliases (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show a list of voicemail zones in the CLI. More...
 
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. More...
 
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. More...
 
static int has_voicemail (const char *mailbox, const char *folder)
 Determines if the given folder has messages. More...
 
static int inboxcount (const char *mailbox, int *newmsgs, int *oldmsgs)
 
static int inboxcount2 (const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
 Check the given mailbox's message count. More...
 
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. More...
 
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. More...
 
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. More...
 
static void load_aliases (struct ast_config *cfg)
 
static int load_config (int reload)
 
static int load_module (void)
 Load the module. More...
 
static void load_users (struct ast_config *cfg)
 
static void load_zonemessages (struct ast_config *cfg)
 
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. More...
 
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, const char *msg_id)
 Creates the email file to be sent to indicate a new voicemail exists for a user. More...
 
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. More...
 
static int manager_list_voicemail_users (struct mansession *s, const struct message *m)
 Manager list voicemail users command. More...
 
static int manager_match_mailbox (struct ast_mwi_state *mwi_state, void *data)
 
static int manager_status_voicemail_user (struct mansession *s, const struct message *m)
 
static int manager_voicemail_refresh (struct mansession *s, const struct message *m)
 
static void * mb_poll_thread (void *data)
 
static const char * mbox (struct ast_vm_user *vmu, int id)
 
static int message_range_and_existence_check (struct vm_state *vms, const char *msg_ids[], size_t num_msgs, int *msg_nums, struct ast_vm_user *vmu)
 common bounds checking and existence check for Voicemail API functions. More...
 
static int messagecount (const char *mailbox_id, const char *folder)
 
static int msg_create_from_file (struct ast_vm_recording_data *recdata)
 
static void mwi_handle_subscribe (const char *id, struct ast_mwi_subscriber *sub)
 
static int mwi_handle_subscribe2 (void *data)
 
static void mwi_handle_unsubscribe (const char *id, struct ast_mwi_subscriber *sub)
 
static int mwi_handle_unsubscribe2 (void *data)
 
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. More...
 
static void notify_new_state (struct ast_vm_user *vmu)
 
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_by_id (struct ast_channel *chan, const char *mailbox, const char *context, const char *msg_id)
 Finds a message in a specific mailbox by msg_id and plays it to the channel. More...
 
static int play_message_by_id_helper (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, const char *msg_id)
 
static int play_message_callerid (struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback, int saycidnumber)
 
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, int *sound_duration, const char *unlockdir, signed char record_gain, struct vm_state *vms, char *flag, const char *msg_id, int forwardintro)
 
static int poll_subscribed_mailbox (struct ast_mwi_state *mwi_state, void *data)
 
static void populate_defaults (struct ast_vm_user *vmu)
 Sets default voicemail system options to a voicemail user. More...
 
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, const char *category, const char *flag)
 
static void print_mappings (void *v_obj, void *where, ao2_prnt_fn *prnt)
 
static void queue_mwi_event (const char *channel_id, const char *box, int urgent, int new, int old)
 
static void read_password_from_file (const char *secretfn, char *password, int passwordlen)
 
static int reload (void)
 
static void rename_file (char *sfn, char *dfn)
 Renames a message in a mailbox folder. More...
 
static int resequence_mailbox (struct ast_vm_user *vmu, char *dir, int stopcount)
 
static int reset_user_pw (const char *context, const char *mailbox, const char *newpass)
 Resets a user password to a specified password. More...
 
static void run_externnotify (const char *context, const char *extension, const char *flag)
 
static int save_to_folder (struct ast_vm_user *vmu, struct vm_state *vms, int msg, int box, int *newmsg, int move)
 
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, const char *msg_id)
 
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 int separate_mailbox (char *mailbox_id, char **mailbox, char **context)
 
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. More...
 
static const char * substitute_escapes (const char *value)
 
static int unload_module (void)
 
static int valid_config (const struct ast_config *cfg)
 Check if configuration file is valid. More...
 
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_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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static int vm_browse_messages_ja (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
 Japanese syntax for 'You have N messages' greeting. More...
 
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. More...
 
static int vm_browse_messages_vi (struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu)
 Vietnamese syntax for 'You have N messages' greeting. More...
 
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. More...
 
static void vm_change_password (struct ast_vm_user *vmu, const char *newpassword)
 The handler for the change password option. More...
 
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. More...
 
static int vm_exec (struct ast_channel *chan, const char *data)
 
static int vm_execmain (struct ast_channel *chan, const char *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. More...
 
static const char * vm_index_to_foldername (int id)
 
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_ja (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_da (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_is (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_ja (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_vi (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. More...
 
static struct ast_vm_mailbox_snapshotvm_mailbox_snapshot_create (const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
 
static struct ast_vm_mailbox_snapshotvm_mailbox_snapshot_destroy (struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 
static int vm_msg_forward (const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
 
static int vm_msg_move (const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
 
static int vm_msg_play (struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb cb)
 
static int vm_msg_remove (const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
 
static struct ast_vm_msg_snapshotvm_msg_snapshot_alloc (void)
 
static int vm_msg_snapshot_create (struct ast_vm_user *vmu, struct vm_state *vms, struct ast_vm_mailbox_snapshot *mailbox_snapshot, int snapshot_index, int mailbox_index, int descending, enum ast_vm_snapshot_sort_val sort_val)
 Create and store off all the msgs in an open mailbox. More...
 
static struct ast_vm_msg_snapshotvm_msg_snapshot_destroy (struct ast_vm_msg_snapshot *msg_snapshot)
 
static int vm_newuser_setup (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_ja (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_playmsgexec (struct ast_channel *chan, const char *data)
 
static int vm_sayname (struct ast_channel *chan, const char *mailbox_id)
 
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'. More...
 
static int vmauthenticate (struct ast_channel *chan, const char *data)
 
static int vmsayname_exec (struct ast_channel *chan, const char *data)
 
static const struct ast_tmvmu_tm (const struct ast_vm_user *vmu, struct ast_tm *tm)
 fill in *tm for current time according to the proper timezone, if any. More...
 
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)
 
static int write_password_to_file (const char *secretfn, const char *password)
 

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, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, .optional_modules = "res_adsi,res_smdi", }
 
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 struct ao2_containeralias_mailbox_mappings
 
static char aliasescontext [MAX_VM_CONTEXT_LEN]
 
static const struct ast_module_infoast_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
 
static char emaildateformat [32] = "%A, %B %d, %Y at %r"
 
static char * emailsubject
 
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_containerinprocess_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 char locale [20]
 
static struct ao2_containermailbox_alias_mappings
 
static const char *const mailbox_folders []
 
static char mailcmd [160] = SENDMAIL
 
static int maxdeletedmsg
 
static int maxgreet
 
static int maxlogins = 3
 
static int maxmsg = MAXMSG
 
static int maxsilence
 
static int minpassword = MINPASSWORD
 
static int msg_id_incrementor
 
struct ast_mwi_observer mwi_observer
 
static struct ast_taskprocessormwi_subscription_tps
 
static int my_umask
 
static char * pagerbody
 
static char pagerdateformat [32] = "%A, %B %d, %Y at %r"
 
static char pagerfromstring [100]
 
static char * pagersubject
 
static int passwordlocation
 
static char * playmsg_app = "VoiceMailPlayMsg"
 
static ast_cond_t poll_cond = PTHREAD_COND_INITIALIZER
 
static unsigned int poll_freq = DEFAULT_POLL_FREQ
 
static ast_mutex_t poll_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
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 = 2
 
static char * sayname_app = "VMSayName"
 
static char serveremail [80] = ASTERISK_USERNAME
 
static int silencethreshold = 128
 
static int skipms = 3000
 
static struct ast_smdi_interfacesmdi_iface = NULL
 
static struct users users = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static char userscontext [AST_MAX_EXTENSION] = "default"
 
static const struct ast_app_option vm_app_options [128] = { [ 's' ] = { .flag = OPT_SILENT }, [ 'S' ] = { .flag = OPT_SILENT_IF_GREET }, [ '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 }, [ 'e' ] = { .flag = OPT_EARLYM_GREETING }, [ 't' ] = { .flag = OPT_BEEP , .arg_index = OPT_ARG_BEEP_TONE + 1 } }
 
static const struct ast_vm_greeter_functions vm_greeter_table
 
static struct ast_custom_function vm_info_acf
 
static char vm_invalid_password [80] = "vm-invalid-password"
 
static char vm_login [80] = "vm-login"
 
static char vm_mismatch [80] = "vm-mismatch"
 
static char vm_newpassword [80] = "vm-newpassword"
 
static char vm_newuser [80] = "vm-newuser"
 
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_prepend_timeout [80] = "vm-then-pound"
 
static char vm_reenterpassword [80] = "vm-reenterpassword"
 
static char VM_SPOOL_DIR [PATH_MAX]
 
static const struct ast_vm_functions vm_table
 
static char * vmauthenticate_app = "VMAuthenticate"
 
static char vmfmts [80] = "wav"
 
static int vmmaxsecs
 
static int vmminsecs
 
static char * voicemail_app = "VoiceMail"
 
static char * voicemailmain_app = "VoiceMailMain"
 
static double volgain
 
static struct zones zones = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static char zonetag [80]
 

Detailed Description

Comedian Mail - Voicemail System.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

unixODBC (http://www.unixodbc.org/) A source distribution of University of Washington's IMAP c-client (http://www.washington.edu/imap/)

See also
Note
For information about voicemail IMAP storage, https://wiki.asterisk.org/wiki/display/AST/IMAP+Voicemail+Storage
Todo:
This module requires res_adsi to load. This needs to be optional during compilation.
Todo:
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.

Macro Definition Documentation

◆ ALIASES_OUTPUT_FORMAT

#define ALIASES_OUTPUT_FORMAT   "%-32s %-32s\n"

◆ ASTERISK_USERNAME

#define ASTERISK_USERNAME   "asterisk"

Definition at line 517 of file app_voicemail.c.

◆ CHUNKSIZE

#define CHUNKSIZE   65536

Definition at line 514 of file app_voicemail.c.

◆ COMMAND_TIMEOUT

#define COMMAND_TIMEOUT   5000

Definition at line 510 of file app_voicemail.c.

◆ COPY

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

Definition at line 868 of file app_voicemail.c.

◆ DEFAULT_LISTEN_CONTROL_FORWARD_KEY

#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY   "#"

Definition at line 522 of file app_voicemail.c.

◆ DEFAULT_LISTEN_CONTROL_PAUSE_KEY

#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY   "0"

Definition at line 524 of file app_voicemail.c.

◆ DEFAULT_LISTEN_CONTROL_RESTART_KEY

#define DEFAULT_LISTEN_CONTROL_RESTART_KEY   "2"

Definition at line 525 of file app_voicemail.c.

◆ DEFAULT_LISTEN_CONTROL_REVERSE_KEY

#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY   "*"

Definition at line 523 of file app_voicemail.c.

◆ DEFAULT_LISTEN_CONTROL_STOP_KEY

#define DEFAULT_LISTEN_CONTROL_STOP_KEY   "13456789"

Definition at line 526 of file app_voicemail.c.

◆ DEFAULT_POLL_FREQ

#define DEFAULT_POLL_FREQ   30

By default, poll every 30 seconds

Definition at line 939 of file app_voicemail.c.

◆ DELETE

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

Definition at line 869 of file app_voicemail.c.

◆ DISPOSE

#define DISPOSE (   a,
  b 
)

Definition at line 864 of file app_voicemail.c.

◆ ENDL

#define ENDL   "\n"

Definition at line 544 of file app_voicemail.c.

◆ ERROR_LOCK_PATH

#define ERROR_LOCK_PATH   -100

Definition at line 569 of file app_voicemail.c.

◆ ERROR_MAX_MSGS

#define ERROR_MAX_MSGS   -101

Definition at line 570 of file app_voicemail.c.

◆ EXISTS

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

Definition at line 866 of file app_voicemail.c.

◆ HVSU_OUTPUT_FORMAT

#define HVSU_OUTPUT_FORMAT   "%-10s %-5s %-25s %-10s %6s\n"

◆ HVSZ_OUTPUT_FORMAT

#define HVSZ_OUTPUT_FORMAT   "%-15s %-20s %-45s\n"

◆ INTRO

#define INTRO   "vm-intro"

Definition at line 532 of file app_voicemail.c.

◆ MAPPING_BUCKETS

#define MAPPING_BUCKETS   511

Definition at line 962 of file app_voicemail.c.

◆ MAX_DATETIME_FORMAT

#define MAX_DATETIME_FORMAT   512

Definition at line 547 of file app_voicemail.c.

◆ MAX_MAIL_BODY_CONTENT_SIZE

#define MAX_MAIL_BODY_CONTENT_SIZE   134217728L

Definition at line 534 of file app_voicemail.c.

◆ MAX_NUM_CID_CONTEXTS

#define MAX_NUM_CID_CONTEXTS   10

Definition at line 548 of file app_voicemail.c.

◆ MAX_VM_CONTEXT_LEN

#define MAX_VM_CONTEXT_LEN   (AST_MAX_CONTEXT)

Definition at line 745 of file app_voicemail.c.

◆ MAX_VM_MAILBOX_LEN

#define MAX_VM_MAILBOX_LEN   (MAX_VM_MBOX_ID_LEN + MAX_VM_CONTEXT_LEN)

Definition at line 747 of file app_voicemail.c.

◆ MAX_VM_MBOX_ID_LEN

#define MAX_VM_MBOX_ID_LEN   (AST_MAX_EXTENSION)

Definition at line 744 of file app_voicemail.c.

◆ MAXMSG

#define MAXMSG   100

Definition at line 536 of file app_voicemail.c.

◆ MAXMSGLIMIT

#define MAXMSGLIMIT   9999

Definition at line 537 of file app_voicemail.c.

◆ MINPASSWORD

#define MINPASSWORD   0

Default minimum mailbox password length

Definition at line 539 of file app_voicemail.c.

◆ MSG_ID_LEN

#define MSG_ID_LEN   256

Definition at line 3720 of file app_voicemail.c.

◆ OPERATOR_EXIT

#define OPERATOR_EXIT   300

Definition at line 571 of file app_voicemail.c.

◆ PWDCHANGE_EXTERNAL

#define PWDCHANGE_EXTERNAL   (1 << 2)

Definition at line 882 of file app_voicemail.c.

◆ PWDCHANGE_INTERNAL

#define PWDCHANGE_INTERNAL   (1 << 1)

Definition at line 881 of file app_voicemail.c.

◆ RENAME

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

Definition at line 867 of file app_voicemail.c.

◆ RETRIEVE

#define RETRIEVE (   a,
  b,
  c,
  d 
)

Definition at line 863 of file app_voicemail.c.

◆ SENDMAIL

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

Definition at line 531 of file app_voicemail.c.

◆ SMDI_MWI_WAIT_TIMEOUT

#define SMDI_MWI_WAIT_TIMEOUT   1000 /* 1 second */

Definition at line 508 of file app_voicemail.c.

◆ STORE

#define STORE (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
 
)

Definition at line 865 of file app_voicemail.c.

◆ tdesc

#define tdesc   "Comedian Mail (Voicemail System)"

Definition at line 891 of file app_voicemail.c.

◆ UPDATE_MSG_ID

#define UPDATE_MSG_ID (   a,
  b,
  c,
  d,
  e,
 
)

Definition at line 870 of file app_voicemail.c.

◆ VALID_DTMF

#define VALID_DTMF   "1234567890*#" /* Yes ABCD are valid dtmf but what phones have those? */

Definition at line 527 of file app_voicemail.c.

◆ VM_ALLOCED

#define VM_ALLOCED   (1 << 13)

Structure was malloc'ed, instead of placed in a return (usually static) buffer

Definition at line 563 of file app_voicemail.c.

◆ VM_ATTACH

#define VM_ATTACH   (1 << 11)

Attach message to voicemail notifications?

Definition at line 561 of file app_voicemail.c.

◆ VM_DELETE

#define VM_DELETE   (1 << 12)

Delete message after sending notification

Definition at line 562 of file app_voicemail.c.

◆ VM_DIRECTFORWARD

#define VM_DIRECTFORWARD   (1 << 10)

Permit caller to use the Directory app for selecting to which mailbox to forward a VM

Definition at line 560 of file app_voicemail.c.

◆ VM_ENVELOPE

#define VM_ENVELOPE   (1 << 4)

Play the envelope information (who-from, time received, etc.)

Definition at line 554 of file app_voicemail.c.

◆ VM_FORCEGREET

#define VM_FORCEGREET   (1 << 8)

Have new users record their greetings

Definition at line 558 of file app_voicemail.c.

◆ VM_FORCENAME

#define VM_FORCENAME   (1 << 7)

Have new users record their name

Definition at line 557 of file app_voicemail.c.

◆ VM_FWDURGAUTO

#define VM_FWDURGAUTO   (1 << 18)

Autoset of Urgent flag on forwarded Urgent messages set globally

Definition at line 568 of file app_voicemail.c.

◆ VM_MESSAGEWRAP

#define VM_MESSAGEWRAP   (1 << 17)

Wrap around from the last message to the first, and vice-versa

Definition at line 567 of file app_voicemail.c.

◆ VM_MOVEHEARD

#define VM_MOVEHEARD   (1 << 16)

Move a "heard" message to Old after listening to it

Definition at line 566 of file app_voicemail.c.

◆ VM_OPERATOR

#define VM_OPERATOR   (1 << 1)

Allow 0 to be pressed to go to 'o' extension

Definition at line 551 of file app_voicemail.c.

◆ VM_PBXSKIP

#define VM_PBXSKIP   (1 << 9)

Skip the [PBX] preamble in the Subject line of emails

Definition at line 559 of file app_voicemail.c.

◆ VM_REVIEW

#define VM_REVIEW   (1 << 0)

After recording, permit the caller to review the recording before saving

Definition at line 550 of file app_voicemail.c.

◆ VM_SAYCID

#define VM_SAYCID   (1 << 2)

Repeat the CallerID info during envelope playback

Definition at line 552 of file app_voicemail.c.

◆ VM_SAYDURATION

#define VM_SAYDURATION   (1 << 5)

Play the length of the message during envelope playback

Definition at line 555 of file app_voicemail.c.

◆ VM_SEARCH

#define VM_SEARCH   (1 << 14)

Search all contexts for a matching mailbox

Definition at line 564 of file app_voicemail.c.

◆ VM_SKIPAFTERCMD

#define VM_SKIPAFTERCMD   (1 << 6)

After deletion, assume caller wants to go to the next message

Definition at line 556 of file app_voicemail.c.

◆ VM_SVMAIL

#define VM_SVMAIL   (1 << 3)

Allow the user to compose a new VM from within VoicemailMain

Definition at line 553 of file app_voicemail.c.

◆ VM_TEMPGREETWARN

#define VM_TEMPGREETWARN   (1 << 15)

Remind user tempgreeting is set

Definition at line 565 of file app_voicemail.c.

◆ VMSTATE_MAX_MSG_ARRAY

#define VMSTATE_MAX_MSG_ARRAY   256

Definition at line 799 of file app_voicemail.c.

◆ VOICEMAIL_CONFIG

#define VOICEMAIL_CONFIG   "voicemail.conf"

Definition at line 516 of file app_voicemail.c.

◆ VOICEMAIL_DIR_MODE

#define VOICEMAIL_DIR_MODE   0777

Definition at line 512 of file app_voicemail.c.

◆ VOICEMAIL_FILE_MODE

#define VOICEMAIL_FILE_MODE   0666

Definition at line 513 of file app_voicemail.c.

Enumeration Type Documentation

◆ vm_box

enum vm_box
Enumerator
NEW_FOLDER 
OLD_FOLDER 
WORK_FOLDER 
FAMILY_FOLDER 
FRIENDS_FOLDER 
GREETINGS_FOLDER 

Definition at line 573 of file app_voicemail.c.

573  {
574  NEW_FOLDER = 0,
575  OLD_FOLDER = 1,
576  WORK_FOLDER = 2,
577  FAMILY_FOLDER = 3,
578  FRIENDS_FOLDER = 4,
579  GREETINGS_FOLDER = -1
580 };
@ FRIENDS_FOLDER
@ NEW_FOLDER
@ GREETINGS_FOLDER
@ FAMILY_FOLDER
@ WORK_FOLDER
@ OLD_FOLDER

◆ vm_option_args

Enumerator
OPT_ARG_RECORDGAIN 
OPT_ARG_PLAYFOLDER 
OPT_ARG_DTMFEXIT 
OPT_ARG_BEEP_TONE 
OPT_ARG_ARRAY_SIZE 

Definition at line 597 of file app_voicemail.c.

597  {
598  OPT_ARG_RECORDGAIN = 0,
599  OPT_ARG_PLAYFOLDER = 1,
600  OPT_ARG_DTMFEXIT = 2,
601  OPT_ARG_BEEP_TONE = 3,
602  /* This *must* be the last value in this enum! */
603  OPT_ARG_ARRAY_SIZE = 4,
604 };
@ OPT_ARG_RECORDGAIN
@ OPT_ARG_PLAYFOLDER
@ OPT_ARG_BEEP_TONE
@ OPT_ARG_ARRAY_SIZE
@ OPT_ARG_DTMFEXIT

◆ vm_option_flags

Enumerator
OPT_SILENT 
OPT_BUSY_GREETING 
OPT_UNAVAIL_GREETING 
OPT_RECORDGAIN 
OPT_PREPEND_MAILBOX 
OPT_AUTOPLAY 
OPT_DTMFEXIT 
OPT_MESSAGE_Urgent 
OPT_MESSAGE_PRIORITY 
OPT_EARLYM_GREETING 
OPT_BEEP 
OPT_SILENT_IF_GREET 

Definition at line 582 of file app_voicemail.c.

582  {
583  OPT_SILENT = (1 << 0),
584  OPT_BUSY_GREETING = (1 << 1),
585  OPT_UNAVAIL_GREETING = (1 << 2),
586  OPT_RECORDGAIN = (1 << 3),
587  OPT_PREPEND_MAILBOX = (1 << 4),
588  OPT_AUTOPLAY = (1 << 6),
589  OPT_DTMFEXIT = (1 << 7),
590  OPT_MESSAGE_Urgent = (1 << 8),
591  OPT_MESSAGE_PRIORITY = (1 << 9),
592  OPT_EARLYM_GREETING = (1 << 10),
593  OPT_BEEP = (1 << 11),
594  OPT_SILENT_IF_GREET = (1 << 12),
595 };
@ OPT_MESSAGE_PRIORITY
@ OPT_PREPEND_MAILBOX
@ OPT_BEEP
@ OPT_BUSY_GREETING
@ OPT_RECORDGAIN
@ OPT_EARLYM_GREETING
@ OPT_SILENT_IF_GREET
@ OPT_UNAVAIL_GREETING
@ OPT_SILENT
@ OPT_DTMFEXIT
@ OPT_MESSAGE_Urgent
@ OPT_AUTOPLAY

◆ vm_passwordlocation

Enumerator
OPT_PWLOC_VOICEMAILCONF 
OPT_PWLOC_SPOOLDIR 
OPT_PWLOC_USERSCONF 

Definition at line 606 of file app_voicemail.c.

606  {
608  OPT_PWLOC_SPOOLDIR = 1,
610 };
@ OPT_PWLOC_USERSCONF
@ OPT_PWLOC_SPOOLDIR
@ OPT_PWLOC_VOICEMAILCONF

Function Documentation

◆ __has_voicemail()

static int __has_voicemail ( const char *  context,
const char *  mailbox,
const char *  folder,
int  shortcircuit 
)
static

Definition at line 5912 of file app_voicemail.c.

5913 {
5914  DIR *dir;
5915  struct dirent *de;
5916  char fn[256];
5917  int ret = 0;
5918  struct alias_mailbox_mapping *mapping;
5919  char *c;
5920  char *m;
5921 
5922  /* If no mailbox, return immediately */
5923  if (ast_strlen_zero(mailbox))
5924  return 0;
5925 
5926  if (ast_strlen_zero(folder))
5927  folder = "INBOX";
5928  if (ast_strlen_zero(context))
5929  context = "default";
5930 
5931  c = (char *)context;
5932  m = (char *)mailbox;
5933 
5935  char tmp[MAX_VM_MAILBOX_LEN];
5936 
5937  snprintf(tmp, MAX_VM_MAILBOX_LEN, "%s@%s", mailbox, context);
5939  if (mapping) {
5940  separate_mailbox(ast_strdupa(mapping->mailbox), &m, &c);
5941  ao2_ref(mapping, -1);
5942  }
5943  }
5944 
5945  snprintf(fn, sizeof(fn), "%s%s/%s/%s", VM_SPOOL_DIR, c, m, folder);
5946 
5947  if (!(dir = opendir(fn)))
5948  return 0;
5949 
5950  while ((de = readdir(dir))) {
5951  if (!strncasecmp(de->d_name, "msg", 3)) {
5952  if (shortcircuit) {
5953  ret = 1;
5954  break;
5955  } else if (!strncasecmp(de->d_name + 8, "txt", 3)) {
5956  ret++;
5957  }
5958  }
5959  }
5960 
5961  closedir(dir);
5962 
5963  return ret;
5964 }
static int separate_mailbox(char *mailbox_id, char **mailbox, char **context)
static char aliasescontext[MAX_VM_CONTEXT_LEN]
#define MAX_VM_MAILBOX_LEN
static char VM_SPOOL_DIR[PATH_MAX]
static struct ao2_container * alias_mailbox_mappings
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
static int tmp()
Definition: bt_open.c:389
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:207
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
static struct test_val c

References alias_mailbox_mappings, aliasescontext, ao2_find, ao2_ref, ast_strdupa, ast_strlen_zero(), c, context, alias_mailbox_mapping::mailbox, mailbox, MAX_VM_MAILBOX_LEN, OBJ_SEARCH_KEY, separate_mailbox(), tmp(), and VM_SPOOL_DIR.

Referenced by has_voicemail(), inboxcount2(), and messagecount().

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 16527 of file app_voicemail.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 16527 of file app_voicemail.c.

◆ acf_vm_info()

static int acf_vm_info ( struct ast_channel chan,
const char *  cmd,
char *  args,
char *  buf,
size_t  len 
)
static

Definition at line 12589 of file app_voicemail.c.

12590 {
12591  struct ast_vm_user svm;
12592  struct ast_vm_user *vmu = NULL;
12593  char *parse;
12594  char *mailbox;
12595  char *context;
12596  int res = 0;
12597 
12599  AST_APP_ARG(mailbox_context);
12600  AST_APP_ARG(attribute);
12601  AST_APP_ARG(folder);
12602  );
12603 
12604  buf[0] = '\0';
12605 
12606  if (ast_strlen_zero(args)) {
12607  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12608  return -1;
12609  }
12610 
12611  parse = ast_strdupa(args);
12613 
12614  if (ast_strlen_zero(arg.mailbox_context)
12615  || ast_strlen_zero(arg.attribute)
12616  || separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
12617  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12618  return -1;
12619  }
12620 
12621  memset(&svm, 0, sizeof(svm));
12622  vmu = find_user(&svm, context, mailbox);
12623 
12624  if (!strncasecmp(arg.attribute, "exists", 5)) {
12625  ast_copy_string(buf, vmu ? "1" : "0", len);
12626  free_user(vmu);
12627  return 0;
12628  }
12629 
12630  if (vmu) {
12631  if (!strncasecmp(arg.attribute, "password", 8)) {
12632  ast_copy_string(buf, vmu->password, len);
12633  } else if (!strncasecmp(arg.attribute, "fullname", 8)) {
12634  ast_copy_string(buf, vmu->fullname, len);
12635  } else if (!strncasecmp(arg.attribute, "email", 5)) {
12636  ast_copy_string(buf, vmu->email, len);
12637  } else if (!strncasecmp(arg.attribute, "pager", 5)) {
12638  ast_copy_string(buf, vmu->pager, len);
12639  } else if (!strncasecmp(arg.attribute, "language", 8)) {
12641  } else if (!strncasecmp(arg.attribute, "locale", 6)) {
12642  ast_copy_string(buf, vmu->locale, len);
12643  } else if (!strncasecmp(arg.attribute, "tz", 2)) {
12644  ast_copy_string(buf, vmu->zonetag, len);
12645  } else if (!strncasecmp(arg.attribute, "count", 5)) {
12646  char *mailbox_id;
12647 
12648  mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
12649  sprintf(mailbox_id, "%s@%s", mailbox, context);/* Safe */
12650 
12651  /* If mbxfolder is empty messagecount will default to INBOX */
12652  res = messagecount(mailbox_id, arg.folder);
12653  if (res < 0) {
12654  ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
12655  free_user(vmu);
12656  return -1;
12657  }
12658  snprintf(buf, len, "%d", res);
12659  } else {
12660  ast_log(LOG_ERROR, "Unknown attribute '%s' for VM_INFO\n", arg.attribute);
12661  free_user(vmu);
12662  return -1;
12663  }
12664  free_user(vmu);
12665  }
12666 
12667  return 0;
12668 }
static void free_user(struct ast_vm_user *vmu)
static int messagecount(const char *mailbox_id, const char *folder)
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.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define ast_log
Definition: astobj2.c:42
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1844
const char * ast_channel_language(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_ERROR
#define NULL
Definition: resample.c:96
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:406
char fullname[80]
char pager[80]
char zonetag[80]
char password[80]
char locale[20]
char language[MAX_LANGUAGE]
const char * args

References args, ast_alloca, AST_APP_ARG, ast_channel_language(), ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), buf, context, ast_vm_user::email, find_user(), free_user(), ast_vm_user::fullname, ast_vm_user::language, len(), ast_vm_user::locale, LOG_ERROR, mailbox, messagecount(), NULL, ast_vm_user::pager, parse(), ast_vm_user::password, S_OR, separate_mailbox(), and ast_vm_user::zonetag.

◆ actual_load_config()

static int actual_load_config ( int  reload,
struct ast_config cfg,
struct ast_config ucfg 
)
static

Definition at line 13590 of file app_voicemail.c.

13591 {
13592  struct ast_vm_user *current;
13593  char *cat;
13594  const char *val;
13595  char *q, *stringp, *tmp;
13596  int x;
13597  unsigned int tmpadsi[4];
13598  char secretfn[PATH_MAX] = "";
13599  long tps_queue_low;
13600  long tps_queue_high;
13601 
13602 #ifdef IMAP_STORAGE
13603  ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
13604 #endif
13605  /* set audio control prompts */
13611 
13612 #ifdef IMAP_STORAGE
13613  ast_mwi_state_callback_all(imap_close_subscribed_mailbox, NULL);
13614 #endif
13615 
13616  /* Free all the users structure */
13617  free_vm_users();
13618 
13619  /* Free all the zones structure */
13620  free_vm_zones();
13621 
13622  /* Remove all aliases */
13625 
13626  AST_LIST_LOCK(&users);
13627 
13628  memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
13629  memset(ext_pass_check_cmd, 0, sizeof(ext_pass_check_cmd));
13630 
13631  if (cfg) {
13632  /* General settings */
13633 
13634  if (!(val = ast_variable_retrieve(cfg, "general", "userscontext")))
13635  val = "default";
13637 
13638  aliasescontext[0] = '\0';
13639  val = ast_variable_retrieve(cfg, "general", "aliasescontext");
13641 
13642  /* Attach voice message to mail message ? */
13643  if (!(val = ast_variable_retrieve(cfg, "general", "attach")))
13644  val = "yes";
13646 
13647  if (!(val = ast_variable_retrieve(cfg, "general", "searchcontexts")))
13648  val = "no";
13650 
13651  volgain = 0.0;
13652  if ((val = ast_variable_retrieve(cfg, "general", "volgain")))
13653  sscanf(val, "%30lf", &volgain);
13654 
13655 #ifdef ODBC_STORAGE
13656  strcpy(odbc_database, "asterisk");
13657  if ((val = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
13658  ast_copy_string(odbc_database, val, sizeof(odbc_database));
13659  }
13660  strcpy(odbc_table, "voicemessages");
13661  if ((val = ast_variable_retrieve(cfg, "general", "odbctable"))) {
13662  ast_copy_string(odbc_table, val, sizeof(odbc_table));
13663  }
13664 #endif
13665  /* Mail command */
13666  strcpy(mailcmd, SENDMAIL);
13667  if ((val = ast_variable_retrieve(cfg, "general", "mailcmd")))
13668  ast_copy_string(mailcmd, val, sizeof(mailcmd)); /* User setting */
13669 
13670  maxsilence = 0;
13671  if ((val = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
13672  maxsilence = atoi(val);
13673  if (maxsilence > 0)
13674  maxsilence *= 1000;
13675  }
13676 
13677  if (!(val = ast_variable_retrieve(cfg, "general", "maxmsg"))) {
13678  maxmsg = MAXMSG;
13679  } else {
13680  maxmsg = atoi(val);
13681  if (maxmsg < 0) {
13682  ast_log(AST_LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", val, MAXMSG);
13683  maxmsg = MAXMSG;
13684  } else if (maxmsg > MAXMSGLIMIT) {
13685  ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
13686  maxmsg = MAXMSGLIMIT;
13687  }
13688  }
13689 
13690  if (!(val = ast_variable_retrieve(cfg, "general", "backupdeleted"))) {
13691  maxdeletedmsg = 0;
13692  } else {
13693  if (sscanf(val, "%30d", &x) == 1)
13694  maxdeletedmsg = x;
13695  else if (ast_true(val))
13697  else
13698  maxdeletedmsg = 0;
13699 
13700  if (maxdeletedmsg < 0) {
13701  ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox '%s'. Using default value %i\n", val, MAXMSG);
13703  } else if (maxdeletedmsg > MAXMSGLIMIT) {
13704  ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
13706  }
13707  }
13708 
13709  /* Load date format config for voicemail mail */
13710  if ((val = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
13712  }
13713 
13714  /* Load date format config for voicemail pager mail */
13715  if ((val = ast_variable_retrieve(cfg, "general", "pagerdateformat"))) {
13717  }
13718 
13719  /* External password changing command */
13720  if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) {
13723  } else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) {
13726  }
13727 
13728  /* External password validation command */
13729  if ((val = ast_variable_retrieve(cfg, "general", "externpasscheck"))) {
13731  ast_debug(1, "found externpasscheck: %s\n", ext_pass_check_cmd);
13732  }
13733 
13734 #ifdef IMAP_STORAGE
13735  /* IMAP server address */
13736  if ((val = ast_variable_retrieve(cfg, "general", "imapserver"))) {
13737  ast_copy_string(imapserver, val, sizeof(imapserver));
13738  } else {
13739  ast_copy_string(imapserver, "localhost", sizeof(imapserver));
13740  }
13741  /* IMAP server port */
13742  if ((val = ast_variable_retrieve(cfg, "general", "imapport"))) {
13743  ast_copy_string(imapport, val, sizeof(imapport));
13744  } else {
13745  ast_copy_string(imapport, "143", sizeof(imapport));
13746  }
13747  /* IMAP server flags */
13748  if ((val = ast_variable_retrieve(cfg, "general", "imapflags"))) {
13749  ast_copy_string(imapflags, val, sizeof(imapflags));
13750  }
13751  /* IMAP server master username */
13752  if ((val = ast_variable_retrieve(cfg, "general", "authuser"))) {
13753  ast_copy_string(authuser, val, sizeof(authuser));
13754  }
13755  /* IMAP server master password */
13756  if ((val = ast_variable_retrieve(cfg, "general", "authpassword"))) {
13757  ast_copy_string(authpassword, val, sizeof(authpassword));
13758  }
13759  /* Expunge on exit */
13760  if ((val = ast_variable_retrieve(cfg, "general", "expungeonhangup"))) {
13761  if (ast_false(val))
13762  expungeonhangup = 0;
13763  else
13764  expungeonhangup = 1;
13765  } else {
13766  expungeonhangup = 1;
13767  }
13768  /* IMAP voicemail folder */
13769  if ((val = ast_variable_retrieve(cfg, "general", "imapfolder"))) {
13770  ast_copy_string(imapfolder, val, sizeof(imapfolder));
13771  } else {
13772  ast_copy_string(imapfolder, "INBOX", sizeof(imapfolder));
13773  }
13774  if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) {
13775  ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder));
13776  }
13777  if ((val = ast_variable_retrieve(cfg, "general", "imapgreetings"))) {
13778  imapgreetings = ast_true(val);
13779  } else {
13780  imapgreetings = 0;
13781  }
13782  if ((val = ast_variable_retrieve(cfg, "general", "greetingfolder"))) {
13783  ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
13784  } else if ((val = ast_variable_retrieve(cfg, "general", "greetingsfolder"))) {
13785  /* Also support greetingsfolder as documented in voicemail.conf.sample */
13786  ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
13787  } else {
13788  ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder));
13789  }
13790  if ((val = ast_variable_retrieve(cfg, "general", "imap_poll_logout"))) {
13791  imap_poll_logout = ast_true(val);
13792  } else {
13793  imap_poll_logout = 0;
13794  }
13795 
13796  /* There is some very unorthodox casting done here. This is due
13797  * to the way c-client handles the argument passed in. It expects a
13798  * void pointer and casts the pointer directly to a long without
13799  * first dereferencing it. */
13800  if ((val = ast_variable_retrieve(cfg, "general", "imapreadtimeout"))) {
13801  mail_parameters(NIL, SET_READTIMEOUT, (void *) (atol(val)));
13802  } else {
13803  mail_parameters(NIL, SET_READTIMEOUT, (void *) 60L);
13804  }
13805 
13806  if ((val = ast_variable_retrieve(cfg, "general", "imapwritetimeout"))) {
13807  mail_parameters(NIL, SET_WRITETIMEOUT, (void *) (atol(val)));
13808  } else {
13809  mail_parameters(NIL, SET_WRITETIMEOUT, (void *) 60L);
13810  }
13811 
13812  if ((val = ast_variable_retrieve(cfg, "general", "imapopentimeout"))) {
13813  mail_parameters(NIL, SET_OPENTIMEOUT, (void *) (atol(val)));
13814  } else {
13815  mail_parameters(NIL, SET_OPENTIMEOUT, (void *) 60L);
13816  }
13817 
13818  if ((val = ast_variable_retrieve(cfg, "general", "imapclosetimeout"))) {
13819  mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) (atol(val)));
13820  } else {
13821  mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L);
13822  }
13823 
13824  /* Increment configuration version */
13825  imapversion++;
13826 #endif
13827  /* External voicemail notify application */
13828  if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
13830  ast_debug(1, "found externnotify: %s\n", externnotify);
13831  } else {
13832  externnotify[0] = '\0';
13833  }
13834 
13835  /* SMDI voicemail notification */
13836  if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
13837  ast_debug(1, "Enabled SMDI voicemail notification\n");
13838  if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
13840  } else {
13841  ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
13842  smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
13843  }
13844  if (!smdi_iface) {
13845  ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
13846  }
13847  }
13848 
13849  /* Silence treshold */
13851  if ((val = ast_variable_retrieve(cfg, "general", "silencethreshold")))
13852  silencethreshold = atoi(val);
13853 
13854  if (!(val = ast_variable_retrieve(cfg, "general", "serveremail")))
13857 
13858  vmmaxsecs = 0;
13859  if ((val = ast_variable_retrieve(cfg, "general", "maxsecs"))) {
13860  if (sscanf(val, "%30d", &x) == 1) {
13861  vmmaxsecs = x;
13862  } else {
13863  ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
13864  }
13865  } else if ((val = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
13866  static int maxmessage_deprecate = 0;
13867  if (maxmessage_deprecate == 0) {
13868  maxmessage_deprecate = 1;
13869  ast_log(AST_LOG_WARNING, "Setting 'maxmessage' has been deprecated in favor of 'maxsecs'.\n");
13870  }
13871  if (sscanf(val, "%30d", &x) == 1) {
13872  vmmaxsecs = x;
13873  } else {
13874  ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
13875  }
13876  }
13877 
13878  vmminsecs = 0;
13879  if ((val = ast_variable_retrieve(cfg, "general", "minsecs"))) {
13880  if (sscanf(val, "%30d", &x) == 1) {
13881  vmminsecs = x;
13882  if (maxsilence / 1000 >= vmminsecs) {
13883  ast_log(AST_LOG_WARNING, "maxsilence should be less than minsecs or you may get empty messages\n");
13884  }
13885  } else {
13886  ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
13887  }
13888  } else if ((val = ast_variable_retrieve(cfg, "general", "minmessage"))) {
13889  static int maxmessage_deprecate = 0;
13890  if (maxmessage_deprecate == 0) {
13891  maxmessage_deprecate = 1;
13892  ast_log(AST_LOG_WARNING, "Setting 'minmessage' has been deprecated in favor of 'minsecs'.\n");
13893  }
13894  if (sscanf(val, "%30d", &x) == 1) {
13895  vmminsecs = x;
13896  if (maxsilence / 1000 >= vmminsecs) {
13897  ast_log(AST_LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
13898  }
13899  } else {
13900  ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
13901  }
13902  }
13903 
13904  val = ast_variable_retrieve(cfg, "general", "format");
13905  if (!val) {
13906  val = "wav";
13907  } else {
13908  tmp = ast_strdupa(val);
13910  if (!val) {
13911  ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n");
13912  val = "wav";
13913  }
13914  }
13915  ast_copy_string(vmfmts, val, sizeof(vmfmts));
13916 
13917  skipms = 3000;
13918  if ((val = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
13919  if (sscanf(val, "%30d", &x) == 1) {
13920  maxgreet = x;
13921  } else {
13922  ast_log(AST_LOG_WARNING, "Invalid max message greeting length\n");
13923  }
13924  }
13925 
13926  if ((val = ast_variable_retrieve(cfg, "general", "skipms"))) {
13927  if (sscanf(val, "%30d", &x) == 1) {
13928  skipms = x;
13929  } else {
13930  ast_log(AST_LOG_WARNING, "Invalid skipms value\n");
13931  }
13932  }
13933 
13934  maxlogins = 3;
13935  if ((val = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
13936  if (sscanf(val, "%30d", &x) == 1) {
13937  maxlogins = x;
13938  } else {
13939  ast_log(AST_LOG_WARNING, "Invalid max failed login attempts\n");
13940  }
13941  }
13942 
13944  if ((val = ast_variable_retrieve(cfg, "general", "minpassword"))) {
13945  if (sscanf(val, "%30d", &x) == 1) {
13946  minpassword = x;
13947  } else {
13948  ast_log(AST_LOG_WARNING, "Invalid minimum password length. Default to %d\n", minpassword);
13949  }
13950  }
13951 
13952  /* Force new user to record name ? */
13953  if (!(val = ast_variable_retrieve(cfg, "general", "forcename")))
13954  val = "no";
13956 
13957  /* Force new user to record greetings ? */
13958  if (!(val = ast_variable_retrieve(cfg, "general", "forcegreetings")))
13959  val = "no";
13961 
13962  if ((val = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) {
13963  ast_debug(1, "VM_CID Internal context string: %s\n", val);
13964  stringp = ast_strdupa(val);
13965  for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
13966  if (!ast_strlen_zero(stringp)) {
13967  q = strsep(&stringp, ",");
13968  while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
13969  q++;
13971  ast_debug(1, "VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
13972  } else {
13973  cidinternalcontexts[x][0] = '\0';
13974  }
13975  }
13976  }
13977  if (!(val = ast_variable_retrieve(cfg, "general", "review"))){
13978  ast_debug(1, "VM Review Option disabled globally\n");
13979  val = "no";
13980  }
13982 
13983  /* Temporary greeting reminder */
13984  if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
13985  ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n");
13986  val = "no";
13987  } else {
13988  ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n");
13989  }
13991  if (!(val = ast_variable_retrieve(cfg, "general", "messagewrap"))){
13992  ast_debug(1, "VM next message wrap disabled globally\n");
13993  val = "no";
13994  }
13996 
13997  if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){
13998  ast_debug(1, "VM Operator break disabled globally\n");
13999  val = "no";
14000  }
14002 
14003  if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) {
14004  ast_debug(1, "VM CID Info before msg disabled globally\n");
14005  val = "no";
14006  }
14008 
14009  if (!(val = ast_variable_retrieve(cfg, "general", "sendvoicemail"))){
14010  ast_debug(1, "Send Voicemail msg disabled globally\n");
14011  val = "no";
14012  }
14014 
14015  if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) {
14016  ast_debug(1, "ENVELOPE before msg enabled globally\n");
14017  val = "yes";
14018  }
14020 
14021  if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) {
14022  ast_debug(1, "Move Heard enabled globally\n");
14023  val = "yes";
14024  }
14026 
14027  if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) {
14028  ast_debug(1, "Autoset of Urgent flag on forwarded Urgent messages disabled globally\n");
14029  val = "no";
14030  }
14032 
14033  if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
14034  ast_debug(1, "Duration info before msg enabled globally\n");
14035  val = "yes";
14036  }
14038 
14039  saydurationminfo = 2;
14040  if ((val = ast_variable_retrieve(cfg, "general", "saydurationm"))) {
14041  if (sscanf(val, "%30d", &x) == 1) {
14042  saydurationminfo = x;
14043  } else {
14044  ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
14045  }
14046  }
14047 
14048  if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
14049  ast_debug(1, "We are not going to skip to the next msg after save/delete\n");
14050  val = "no";
14051  }
14053 
14054  if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) {
14056  ast_debug(1, "found dialout context: %s\n", dialcontext);
14057  } else {
14058  dialcontext[0] = '\0';
14059  }
14060 
14061  if ((val = ast_variable_retrieve(cfg, "general", "callback"))) {
14063  ast_debug(1, "found callback context: %s\n", callcontext);
14064  } else {
14065  callcontext[0] = '\0';
14066  }
14067 
14068  if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
14070  ast_debug(1, "found operator context: %s\n", exitcontext);
14071  } else {
14072  exitcontext[0] = '\0';
14073  }
14074 
14075  /* load password sounds configuration */
14076  if ((val = ast_variable_retrieve(cfg, "general", "vm-login")))
14077  ast_copy_string(vm_login, val, sizeof(vm_login));
14078  if ((val = ast_variable_retrieve(cfg, "general", "vm-newuser")))
14080  if ((val = ast_variable_retrieve(cfg, "general", "vm-password")))
14082  if ((val = ast_variable_retrieve(cfg, "general", "vm-newpassword")))
14084  if ((val = ast_variable_retrieve(cfg, "general", "vm-invalid-password")))
14086  if ((val = ast_variable_retrieve(cfg, "general", "vm-passchanged")))
14088  if ((val = ast_variable_retrieve(cfg, "general", "vm-reenterpassword")))
14090  if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
14092  if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
14094  }
14095  if ((val = ast_variable_retrieve(cfg, "general", "vm-prepend-timeout"))) {
14097  }
14098  /* load configurable audio prompts */
14099  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
14101  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val))
14103  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val))
14105  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val))
14107  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val))
14109 
14110  if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory")))
14111  val = "no";
14113 
14114  if (!(val = ast_variable_retrieve(cfg, "general", "passwordlocation"))) {
14115  val = "voicemail.conf";
14116  }
14117  if (!(strcmp(val, "spooldir"))) {
14119  } else {
14121  }
14122 
14124  if ((val = ast_variable_retrieve(cfg, "general", "pollfreq"))) {
14125  if (sscanf(val, "%30u", &poll_freq) != 1) {
14127  ast_log(AST_LOG_ERROR, "'%s' is not a valid value for the pollfreq option!\n", val);
14128  }
14129  }
14130 
14131  poll_mailboxes = 0;
14132  if ((val = ast_variable_retrieve(cfg, "general", "pollmailboxes")))
14134 
14135  memset(fromstring, 0, sizeof(fromstring));
14136  memset(pagerfromstring, 0, sizeof(pagerfromstring));
14137  strcpy(charset, "ISO-8859-1");
14138  if (emailbody) {
14140  emailbody = NULL;
14141  }
14142  if (emailsubject) {
14144  emailsubject = NULL;
14145  }
14146  if (pagerbody) {
14148  pagerbody = NULL;
14149  }
14150  if (pagersubject) {
14152  pagersubject = NULL;
14153  }
14154  if ((val = ast_variable_retrieve(cfg, "general", "pbxskip")))
14156  if ((val = ast_variable_retrieve(cfg, "general", "fromstring")))
14158  if ((val = ast_variable_retrieve(cfg, "general", "pagerfromstring")))
14160  if ((val = ast_variable_retrieve(cfg, "general", "charset")))
14161  ast_copy_string(charset, val, sizeof(charset));
14162  if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
14163  sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14164  for (x = 0; x < 4; x++) {
14165  memcpy(&adsifdn[x], &tmpadsi[x], 1);
14166  }
14167  }
14168  if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) {
14169  sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14170  for (x = 0; x < 4; x++) {
14171  memcpy(&adsisec[x], &tmpadsi[x], 1);
14172  }
14173  }
14174  if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) {
14175  if (atoi(val)) {
14176  adsiver = atoi(val);
14177  }
14178  }
14179  if ((val = ast_variable_retrieve(cfg, "general", "tz"))) {
14180  ast_copy_string(zonetag, val, sizeof(zonetag));
14181  }
14182  if ((val = ast_variable_retrieve(cfg, "general", "locale"))) {
14183  ast_copy_string(locale, val, sizeof(locale));
14184  }
14185  if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) {
14187  }
14188  if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
14190  }
14191  if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
14193  }
14194  if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
14196  }
14197 
14198  tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14199  if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_high"))) {
14200  if (sscanf(val, "%30ld", &tps_queue_high) != 1 || tps_queue_high <= 0) {
14201  ast_log(AST_LOG_WARNING, "Invalid the taskprocessor high water alert trigger level '%s'\n", val);
14202  tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14203  }
14204  }
14205  tps_queue_low = -1;
14206  if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_low"))) {
14207  if (sscanf(val, "%30ld", &tps_queue_low) != 1 ||
14208  tps_queue_low < -1 || tps_queue_high < tps_queue_low) {
14209  ast_log(AST_LOG_WARNING, "Invalid the taskprocessor low water clear alert level '%s'\n", val);
14210  tps_queue_low = -1;
14211  }
14212  }
14213  if (ast_taskprocessor_alert_set_levels(mwi_subscription_tps, tps_queue_low, tps_queue_high)) {
14214  ast_log(AST_LOG_WARNING, "Failed to set alert levels for voicemail taskprocessor.\n");
14215  }
14216 
14217  /* load mailboxes from users.conf */
14218  if (ucfg) {
14219  for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
14220  if (!strcasecmp(cat, "general")) {
14221  continue;
14222  }
14223  if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
14224  continue;
14225  if ((current = find_or_create(userscontext, cat))) {
14228  ast_copy_string(current->context, userscontext, sizeof(current->context));
14229  if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) {
14230  current->passwordlocation = OPT_PWLOC_USERSCONF;
14231  }
14232 
14233  switch (current->passwordlocation) {
14234  case OPT_PWLOC_SPOOLDIR:
14235  snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox);
14236  read_password_from_file(secretfn, current->password, sizeof(current->password));
14237  }
14238  }
14239  }
14240  }
14241 
14242  /* load mailboxes from voicemail.conf */
14243 
14244  /*
14245  * Aliases must be loaded before users or the aliases won't be notified
14246  * if there's existing voicemail in the user mailbox.
14247  */
14248  load_aliases(cfg);
14249 
14250  load_zonemessages(cfg);
14251 
14252  load_users(cfg);
14253 
14255 
14259  stop_poll_thread();;
14260 
14261  return 0;
14262  } else {
14264  ast_log(AST_LOG_WARNING, "Failed to load configuration file.\n");
14265  return 0;
14266  }
14267 }
static char pagerfromstring[100]
static char vm_password[80]
static char vm_invalid_password[80]
#define VM_SEARCH
static char listen_control_reverse_key[12]
static char serveremail[80]
#define VM_SAYCID
#define VM_FWDURGAUTO
#define VM_SAYDURATION
static int pwdchange
#define VM_TEMPGREETWARN
static int skipms
#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY
static char mailcmd[160]
static int vmminsecs
static void read_password_from_file(const char *secretfn, char *password, int passwordlen)
static void apply_options_full(struct ast_vm_user *retval, struct ast_variable *var)
Loads the options specific to a voicemail user.
static void populate_defaults(struct ast_vm_user *vmu)
Sets default voicemail system options to a voicemail user.
static struct ast_taskprocessor * mwi_subscription_tps
#define VM_OPERATOR
static char vm_newpassword[80]
static struct ast_flags globalflags
static char listen_control_forward_key[12]
static char vm_login[80]
#define VM_DIRECTFORWARD
static char vm_newuser[80]
static unsigned char adsisec[4]
static const char * substitute_escapes(const char *value)
#define VM_SKIPAFTERCMD
static pthread_t poll_thread
static char zonetag[80]
static char * pagersubject
static int maxmsg
static char vmfmts[80]
static void load_zonemessages(struct ast_config *cfg)
static int passwordlocation
static char vm_mismatch[80]
#define ASTERISK_USERNAME
static char vm_pls_try_again[80]
#define VM_PBXSKIP
static char ext_pass_check_cmd[128]
static struct ast_vm_user * find_or_create(const char *context, const char *box)
static char * pagerbody
static char dialcontext[AST_MAX_CONTEXT]
#define DEFAULT_POLL_FREQ
#define VM_ENVELOPE
static void stop_poll_thread(void)
#define MAXMSG
#define DEFAULT_LISTEN_CONTROL_RESTART_KEY
static char listen_control_stop_key[12]
static char fromstring[100]
#define PWDCHANGE_INTERNAL
#define VM_FORCEGREET
#define VM_MESSAGEWRAP
static char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64]
#define DEFAULT_LISTEN_CONTROL_STOP_KEY
static char emaildateformat[32]
static char vm_reenterpassword[80]
static int saydurationminfo
#define VM_ATTACH
static void load_users(struct ast_config *cfg)
static int maxgreet
#define SENDMAIL
#define VM_FORCENAME
static char ext_pass_cmd[128]
static int is_valid_dtmf(const char *key)
Determines if a DTMF key entered is valid.
static char pagerdateformat[32]
static double volgain
static int adsiver
static int maxlogins
static char * emailsubject
static struct ao2_container * mailbox_alias_mappings
#define VM_MOVEHEARD
static char externnotify[160]
static char listen_control_restart_key[12]
#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY
#define MAX_NUM_CID_CONTEXTS
static char vm_prepend_timeout[80]
static char userscontext[AST_MAX_EXTENSION]
static char callcontext[AST_MAX_CONTEXT]
static int maxdeletedmsg
static char * emailbody
static char listen_control_pause_key[12]
static int silencethreshold
static void start_poll_thread(void)
static unsigned int poll_mailboxes
#define MINPASSWORD
static int minpassword
static unsigned int poll_freq
static void free_vm_zones(void)
Free the zones structure.
#define VM_SVMAIL
#define PWDCHANGE_EXTERNAL
static char locale[20]
static unsigned char adsifdn[4]
static int maxsilence
static void load_aliases(struct ast_config *cfg)
static int vmmaxsecs
#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY
#define MAXMSGLIMIT
static char exitcontext[AST_MAX_CONTEXT]
#define VM_REVIEW
static char vm_passchanged[80]
static struct ast_smdi_interface * smdi_iface
static void free_vm_users(void)
Free the users structure.
#define PATH_MAX
Definition: asterisk.h:40
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_MULTIPLE
Definition: astobj2.h:1049
@ OBJ_UNLINK
Definition: astobj2.h:1039
charset
Definition: chan_unistim.c:336
@ THRESHOLD_SILENCE
Definition: dsp.h:73
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Definition: dsp.c:1999
char * ast_format_str_reduce(char *fmts)
Definition: file.c:1867
char * strsep(char **str, const char *delims)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3327
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:768
const char * ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
Retrieve a configuration variable within the configuration set.
Definition: main/config.c:758
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1215
#define AST_LOG_WARNING
#define AST_LOG_ERROR
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_PTHREADT_NULL
Definition: lock.h:66
size_t current
Definition: main/cli.c:113
void ast_mwi_state_callback_all(on_mwi_state handler, void *data)
For each managed mailbox call the given handler.
Definition: mwi.c:338
struct ast_smdi_interface * ast_smdi_interface_find(const char *iface_name)
Find an SMDI interface with the specified name.
Definition: res_smdi.c:563
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: main/utils.c:2097
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
Definition: main/utils.c:2114
list of users found in the config file
Definition: ast_expr2.c:325
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
Definition: taskprocessor.h:64
int ast_taskprocessor_alert_set_levels(struct ast_taskprocessor *tps, long low_water, long high_water)
Set the high and low alert water marks of the given taskprocessor queue.
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94

References adsifdn, adsisec, adsiver, alias_mailbox_mappings, aliasescontext, ao2_callback, apply_options_full(), ast_category_browse(), ast_config_option(), ast_copy_string(), ast_debug, ast_dsp_get_threshold_from_settings(), ast_false(), ast_format_str_reduce(), ast_free, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log, AST_LOG_ERROR, AST_LOG_WARNING, ast_mwi_state_callback_all(), AST_PTHREADT_NULL, ast_set2_flag, ast_smdi_interface_find(), ast_strdup, ast_strdupa, ast_strlen_zero(), ast_taskprocessor_alert_set_levels(), AST_TASKPROCESSOR_HIGH_WATER_LEVEL, ast_true(), ast_variable_browse(), ast_variable_retrieve(), ASTERISK_USERNAME, callcontext, cidinternalcontexts, current, 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, ext_pass_check_cmd, ext_pass_cmd, externnotify, find_or_create(), free_vm_users(), free_vm_zones(), fromstring, globalflags, is_valid_dtmf(), listen_control_forward_key, listen_control_pause_key, listen_control_restart_key, listen_control_reverse_key, listen_control_stop_key, load_aliases(), load_users(), load_zonemessages(), locale, LOG_ERROR, mailbox_alias_mappings, mailcmd, MAX_NUM_CID_CONTEXTS, maxdeletedmsg, maxgreet, maxlogins, MAXMSG, maxmsg, MAXMSGLIMIT, maxsilence, MINPASSWORD, minpassword, mwi_subscription_tps, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, OPT_PWLOC_SPOOLDIR, OPT_PWLOC_USERSCONF, OPT_PWLOC_VOICEMAILCONF, pagerbody, pagerdateformat, pagerfromstring, pagersubject, passwordlocation, PATH_MAX, poll_freq, poll_mailboxes, poll_thread, populate_defaults(), pwdchange, PWDCHANGE_EXTERNAL, PWDCHANGE_INTERNAL, read_password_from_file(), S_OR, saydurationminfo, SENDMAIL, serveremail, silencethreshold, skipms, smdi_iface, start_poll_thread(), stop_poll_thread(), strsep(), substitute_escapes(), THRESHOLD_SILENCE, tmp(), userscontext, VM_ATTACH, VM_DIRECTFORWARD, VM_ENVELOPE, VM_FORCEGREET, VM_FORCENAME, VM_FWDURGAUTO, vm_invalid_password, vm_login, VM_MESSAGEWRAP, vm_mismatch, VM_MOVEHEARD, vm_newpassword, vm_newuser, VM_OPERATOR, vm_passchanged, vm_password, VM_PBXSKIP, vm_pls_try_again, vm_prepend_timeout, vm_reenterpassword, VM_REVIEW, VM_SAYCID, VM_SAYDURATION, VM_SEARCH, VM_SKIPAFTERCMD, VM_SPOOL_DIR, VM_SVMAIL, VM_TEMPGREETWARN, vmfmts, vmmaxsecs, vmminsecs, volgain, and zonetag.

Referenced by load_config().

◆ add_email_attachment()

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 5235 of file app_voicemail.c.

5236 {
5237  char fname[PATH_MAX] = "";
5238  char sox_gain_tmpdir[PATH_MAX];
5239  char *file_to_delete = NULL, *dir_to_delete = NULL;
5240  int res;
5241  char altfname[PATH_MAX] = "";
5242  int altused = 0;
5243  char altformat[80] = "";
5244  char *c = NULL;
5245 
5246  /* Eww. We want formats to tell us their own MIME type */
5247  char *mime_type = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
5248 
5249  /* Users of multiple file formats need special attention. */
5250  snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5251  if (!ast_file_is_readable(fname)) {
5252  ast_copy_string(altformat, vmfmts, sizeof(altformat));
5253  c = strchr(altformat, '|');
5254  if (c) {
5255  *c = '\0';
5256  }
5257  ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - trying first/alternate format %s\n", fname, strerror(errno), altformat);
5258  snprintf(altfname, sizeof(altfname), "%s.%s", attach, altformat);
5259  if (!ast_file_is_readable(altfname)) {
5260  ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - alternate format %s failure\n", altfname, strerror(errno), altformat);
5261  } else {
5262  altused = 1;
5263  }
5264  }
5265 
5266  /* This 'while' loop will only execute once. We use it so that we can 'break' */
5267  while (vmu->volgain < -.001 || vmu->volgain > .001 || altused) {
5268  char tmpdir[PATH_MAX];
5269 
5270  create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
5271 
5272  res = snprintf(sox_gain_tmpdir, sizeof(sox_gain_tmpdir), "%s/vm-gain-XXXXXX", tmpdir);
5273  if (res >= sizeof(sox_gain_tmpdir)) {
5274  ast_log(LOG_ERROR, "Failed to create temporary directory path %s: Out of buffer space\n", tmpdir);
5275  break;
5276  }
5277 
5278  if (mkdtemp(sox_gain_tmpdir)) {
5279  int soxstatus = 0;
5280  char sox_gain_cmd[PATH_MAX];
5281 
5282  ast_debug(3, "sox_gain_tmpdir: %s\n", sox_gain_tmpdir);
5283 
5284  /* Save for later */
5285  dir_to_delete = sox_gain_tmpdir;
5286 
5287  res = snprintf(fname, sizeof(fname), "%s/output.%s", sox_gain_tmpdir, format);
5288  if (res >= sizeof(fname)) {
5289  ast_log(LOG_ERROR, "Failed to create filename buffer for %s/output.%s: Too long\n", sox_gain_tmpdir, format);
5290  break;
5291  }
5292 
5293  if (!altused) {
5294  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5295  vmu->volgain, attach, format, fname);
5296  } else {
5297  if (!strcasecmp(format, "wav")) {
5298  if (vmu->volgain < -.001 || vmu->volgain > .001) {
5299  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s -e signed-integer -b 16 %s",
5300  vmu->volgain, attach, altformat, fname);
5301  } else {
5302  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s -e signed-integer -b 16 %s",
5303  attach, altformat, fname);
5304  }
5305  } else {
5306  if (vmu->volgain < -.001 || vmu->volgain > .001) {
5307  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5308  vmu->volgain, attach, altformat, fname);
5309  } else {
5310  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s %s",
5311  attach, altformat, fname);
5312  }
5313  }
5314  }
5315 
5316  if (res >= sizeof(sox_gain_cmd)) {
5317  ast_log(LOG_ERROR, "Failed to generate sox command, out of buffer space\n");
5318  break;
5319  }
5320 
5321  soxstatus = ast_safe_system(sox_gain_cmd);
5322  if (!soxstatus) {
5323  /* Save for later */
5324  file_to_delete = fname;
5325  ast_debug(3, "VOLGAIN: Stored at: %s - Level: %.4f - Mailbox: %s\n", fname, vmu->volgain, mailbox);
5326  } else {
5327  ast_log(LOG_WARNING, "Sox failed to re-encode %s: %s (have you installed support for all sox file formats?)\n",
5328  fname,
5329  soxstatus == 1 ? "Problem with command line options" : "An error occurred during file processing");
5330  ast_log(LOG_WARNING, "Voicemail attachment will have no volume gain.\n");
5331  }
5332  }
5333 
5334  break;
5335  }
5336 
5337  if (!file_to_delete) {
5338  res = snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5339  if (res >= sizeof(fname)) {
5340  ast_log(LOG_ERROR, "Failed to create filename buffer for %s.%s: Too long\n", attach, format);
5341  return -1;
5342  }
5343  }
5344 
5345  fprintf(p, "--%s" ENDL, bound);
5346  if (msgnum > -1)
5347  fprintf(p, "Content-Type: %s%s; name=\"%s\"" ENDL, mime_type, format, filename);
5348  else
5349  fprintf(p, "Content-Type: %s%s; name=\"%s.%s\"" ENDL, mime_type, format, greeting_attachment, format);
5350  fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
5351  fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
5352  if (msgnum > -1)
5353  fprintf(p, "Content-Disposition: attachment; filename=\"%s\"" ENDL ENDL, filename);
5354  else
5355  fprintf(p, "Content-Disposition: attachment; filename=\"%s.%s\"" ENDL ENDL, greeting_attachment, format);
5356  ast_base64_encode_file_path(fname, p, ENDL);
5357  if (last)
5358  fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound);
5359 
5360  if (file_to_delete) {
5361  unlink(file_to_delete);
5362  }
5363 
5364  if (dir_to_delete) {
5365  rmdir(dir_to_delete);
5366  }
5367 
5368  return 0;
5369 }
struct sla_ringing_trunk * last
Definition: app_meetme.c:1094
#define ENDL
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 snd_pcm_format_t format
Definition: chan_alsa.c:106
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
Definition: extconf.c:829
char * mkdtemp(char *template_s)
#define LOG_WARNING
int errno
char context[MAX_VM_CONTEXT_LEN]
char mailbox[MAX_VM_MBOX_ID_LEN]
double volgain
int ast_file_is_readable(const char *filename)
Test that a file exists and is readable by the effective user.
Definition: main/utils.c:3003
int ast_base64_encode_file_path(const char *filename, FILE *outputfile, const char *endl)
Performs a base 64 encode algorithm on the contents of a File.
Definition: main/utils.c:702

References ast_base64_encode_file_path(), ast_copy_string(), ast_debug, ast_file_is_readable(), ast_log, AST_LOG_WARNING, ast_safe_system(), c, ast_vm_user::context, create_dirpath(), ENDL, errno, format, last, LOG_ERROR, LOG_WARNING, mailbox, ast_vm_user::mailbox, mkdtemp(), NULL, PATH_MAX, vmfmts, and ast_vm_user::volgain.

Referenced by make_email_file().

◆ add_message_id()

static int add_message_id ( struct ast_config msg_cfg,
char *  dir,
int  msg,
char *  filename,
char *  id,
size_t  id_size,
struct ast_vm_user vmu,
int  folder 
)
static

Definition at line 12266 of file app_voicemail.c.

12267 {
12268  struct ast_variable *var;
12269  struct ast_category *cat;
12270  generate_msg_id(id);
12271 
12272  var = ast_variable_new("msg_id", id, "");
12273  if (!var) {
12274  return -1;
12275  }
12276 
12277  cat = ast_category_get(msg_cfg, "message", NULL);
12278  if (!cat) {
12279  ast_log(LOG_ERROR, "Voicemail data file %s/%d.txt has no [message] category?\n", dir, msg);
12281  return -1;
12282  }
12283 
12284  ast_variable_append(cat, var);
12285 
12286  if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
12287  ast_log(LOG_WARNING, "Unable to update %s to have a message ID\n", filename);
12288  return -1;
12289  }
12290 
12291  UPDATE_MSG_ID(dir, msg, id, vmu, msg_cfg, folder);
12292  return 0;
12293 }
#define UPDATE_MSG_ID(a, b, c, d, e, f)
static void generate_msg_id(char *dst)
Sets the destination string to a uniquely identifying msg_id string.
#define var
Definition: ast_expr2f.c:614
int ast_config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator)
Save a config text file preserving the pre 13.2 behavior.
Definition: main/config.c:2597
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
Definition: extconf.c:1177
#define ast_variable_new(name, value, filename)
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
Definition: main/config.c:1096
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
Structure for variables, used for configurations and for channel variables.

References ast_category_get(), ast_config_text_file_save(), ast_log, ast_variable_append(), ast_variable_new, ast_variables_destroy(), generate_msg_id(), LOG_ERROR, LOG_WARNING, NULL, UPDATE_MSG_ID, and var.

Referenced by vm_msg_snapshot_create().

◆ adsi_begin()

static void adsi_begin ( struct ast_channel chan,
int *  useadsi 
)
static

Definition at line 7305 of file app_voicemail.c.

7306 {
7307  int x;
7308  if (!ast_adsi_available(chan))
7309  return;
7310  x = ast_adsi_load_session(chan, adsifdn, adsiver, 1);
7311  if (x < 0)
7312  return;
7313  if (!x) {
7314  if (adsi_load_vmail(chan, useadsi)) {
7315  ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n");
7316  return;
7317  }
7318  } else
7319  *useadsi = 1;
7320 }
int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
Check if scripts for a given app are already loaded. Version may be -1, if any version is okay,...
Definition: adsi.c:76
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
static int adsi_load_vmail(struct ast_channel *chan, int *useadsi)

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().

◆ adsi_delete()

static void adsi_delete ( struct ast_channel chan,
struct vm_state vms 
)
static

Definition at line 7501 of file app_voicemail.c.

7502 {
7503  int bytes = 0;
7504  unsigned char buf[256];
7505  unsigned char keys[8];
7506 
7507  int x;
7508 
7509  if (!ast_adsi_available(chan))
7510  return;
7511 
7512  /* New meaning for keys */
7513  for (x = 0; x < 5; x++)
7514  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7515 
7516  keys[6] = 0x0;
7517  keys[7] = 0x0;
7518 
7519  if (!vms->curmsg) {
7520  /* No prev key, provide "Folder" instead */
7521  keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7522  }
7523  if (vms->curmsg >= vms->lastmsg) {
7524  /* If last message ... */
7525  if (vms->curmsg) {
7526  /* but not only message, provide "Folder" instead */
7527  keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7528  } else {
7529  /* Otherwise if only message, leave blank */
7530  keys[3] = 1;
7531  }
7532  }
7533 
7534  /* If deleted, show "undeleted" */
7535 #ifdef IMAP_STORAGE
7536  ast_mutex_lock(&vms->lock);
7537 #endif
7538  if (vms->deleted[vms->curmsg]) {
7539  keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7540  }
7541 #ifdef IMAP_STORAGE
7542  ast_mutex_unlock(&vms->lock);
7543 #endif
7544 
7545  /* Except "Exit" */
7546  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7547  bytes += ast_adsi_set_keys(buf + bytes, keys);
7548  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7549 
7551 }
#define ADSI_KEY_APPS
Definition: adsi.h:109
#define ADSI_KEY_SKT
Definition: adsi.h:117
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ast_mutex_unlock(a)
Definition: lock.h:188
#define ast_mutex_lock(a)
Definition: lock.h:187
int * deleted

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(), ast_mutex_lock, ast_mutex_unlock, buf, vm_state::curmsg, vm_state::deleted, and vm_state::lastmsg.

Referenced by vm_execmain().

◆ adsi_folders()

static void adsi_folders ( struct ast_channel chan,
int  start,
char *  label 
)
static

Definition at line 7370 of file app_voicemail.c.

7371 {
7372  unsigned char buf[256];
7373  int bytes = 0;
7374  unsigned char keys[8];
7375  int x, y;
7376 
7377  if (!ast_adsi_available(chan))
7378  return;
7379 
7380  for (x = 0; x < 5; x++) {
7381  y = ADSI_KEY_APPS + 12 + start + x;
7382  if (y > ADSI_KEY_APPS + 12 + 4)
7383  y = 0;
7384  keys[x] = ADSI_KEY_SKT | y;
7385  }
7386  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17);
7387  keys[6] = 0;
7388  keys[7] = 0;
7389 
7390  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, "");
7391  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
7392  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7393  bytes += ast_adsi_set_keys(buf + bytes, keys);
7394  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7395 
7397 }
int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
Loads a line of info into the display.
Definition: adsi.c:274
#define ADSI_JUST_CENT
Definition: adsi.h:114
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
#define ADSI_COMM_PAGE
Definition: adsi.h:107

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(), ast_adsi_voice_mode(), and buf.

Referenced by vm_execmain().

◆ adsi_goodbye()

static void adsi_goodbye ( struct ast_channel chan)
static

Definition at line 7656 of file app_voicemail.c.

7657 {
7658  unsigned char buf[256];
7659  int bytes = 0;
7660 
7661  if (!ast_adsi_available(chan))
7662  return;
7663  bytes += adsi_logo(buf + bytes);
7664  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
7665  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
7666  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7667  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7668 
7670 }
#define ADSI_JUST_LEFT
Definition: adsi.h:112
static int adsi_logo(unsigned char *buf)

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(), ast_adsi_voice_mode(), and buf.

Referenced by vm_execmain().

◆ adsi_load_vmail()

static int adsi_load_vmail ( struct ast_channel chan,
int *  useadsi 
)
static

Definition at line 7176 of file app_voicemail.c.

7177 {
7178  unsigned char buf[256];
7179  int bytes = 0;
7180  int x;
7181  char num[5];
7182 
7183  *useadsi = 0;
7184  bytes += ast_adsi_data_mode(buf + bytes);
7186 
7187  bytes = 0;
7188  bytes += adsi_logo(buf);
7189  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7190 #ifdef DISPLAY
7191  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .", "");
7192 #endif
7193  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7194  bytes += ast_adsi_data_mode(buf + bytes);
7196 
7198  bytes = 0;
7199  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", "");
7200  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7201  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7202  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7204  return 0;
7205  }
7206 
7207 #ifdef DISPLAY
7208  /* Add a dot */
7209  bytes = 0;
7210  bytes += ast_adsi_logo(buf);
7211  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7212  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ..", "");
7213  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7215 #endif
7216  bytes = 0;
7217  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1);
7218  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1);
7219  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advanced", "3", 1);
7220  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1);
7221  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1);
7222  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1);
7224 
7225 #ifdef DISPLAY
7226  /* Add another dot */
7227  bytes = 0;
7228  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ...", "");
7229  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7230 
7231  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7233 #endif
7234 
7235  bytes = 0;
7236  /* These buttons we load but don't use yet */
7237  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 6, "Previous", "Prev", "4", 1);
7238  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 8, "Repeat", "Repeat", "5", 1);
7239  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 7, "Delete", "Delete", "7", 1);
7240  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 9, "Next", "Next", "6", 1);
7241  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 10, "Save", "Save", "9", 1);
7242  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 11, "Undelete", "Restore", "7", 1);
7244 
7245 #ifdef DISPLAY
7246  /* Add another dot */
7247  bytes = 0;
7248  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ....", "");
7249  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7251 #endif
7252 
7253  bytes = 0;
7254  for (x = 0; x < 5; x++) {
7255  snprintf(num, sizeof(num), "%d", x);
7256  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(NULL, x), mbox(NULL, x), num, 1);
7257  }
7258  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + 5, "Cancel", "Cancel", "#", 1);
7260 
7261 #ifdef DISPLAY
7262  /* Add another dot */
7263  bytes = 0;
7264  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .....", "");
7265  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7267 #endif
7268 
7269  if (ast_adsi_end_download(chan)) {
7270  bytes = 0;
7271  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Download Unsuccessful.", "");
7272  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7273  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7274  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7276  return 0;
7277  }
7278  bytes = 0;
7279  bytes += ast_adsi_download_disconnect(buf + bytes);
7280  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7282 
7283  ast_debug(1, "Done downloading scripts...\n");
7284 
7285 #ifdef DISPLAY
7286  /* Add last dot */
7287  bytes = 0;
7288  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
7289  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7290 #endif
7291  ast_debug(1, "Restarting session...\n");
7292 
7293  bytes = 0;
7294  /* Load the session now */
7295  if (ast_adsi_load_session(chan, adsifdn, adsiver, 1) == 1) {
7296  *useadsi = 1;
7297  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", "");
7298  } else
7299  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Failed!", "");
7300 
7302  return 0;
7303 }
int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
Creates "load soft key" parameters.
Definition: adsi.c:296
#define ADSI_MSG_DOWNLOAD
Definition: adsi.h:33
int ast_adsi_data_mode(unsigned char *buf)
Puts CPE in data mode.
Definition: adsi.c:219
int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
Definition: adsi.c:32
int ast_adsi_end_download(struct ast_channel *chan)
Definition: adsi.c:43
int ast_adsi_download_disconnect(unsigned char *buf)
Disconnects (and hopefully saves) a downloaded script.
Definition: adsi.c:208
static char * addesc
static const char * mbox(struct ast_vm_user *vmu, int id)

References addesc, 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, buf, mbox(), and NULL.

Referenced by adsi_begin().

◆ adsi_login()

static void adsi_login ( struct ast_channel chan)
static

Definition at line 7322 of file app_voicemail.c.

7323 {
7324  unsigned char buf[256];
7325  int bytes = 0;
7326  unsigned char keys[8];
7327  int x;
7328  if (!ast_adsi_available(chan))
7329  return;
7330 
7331  for (x = 0; x < 8; x++)
7332  keys[x] = 0;
7333  /* Set one key for next */
7334  keys[3] = ADSI_KEY_APPS + 3;
7335 
7336  bytes += adsi_logo(buf + bytes);
7337  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, " ", "");
7338  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ", "");
7339  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7340  bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Mailbox: ******", "");
7341  bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 1, 1, ADSI_JUST_LEFT);
7342  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Enter", "Enter", "#", 1);
7343  bytes += ast_adsi_set_keys(buf + bytes, keys);
7344  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7346 }
int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
Set input information.
Definition: adsi.c:318
int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
Set input format.
Definition: adsi.c:329
#define ADSI_DIR_FROM_LEFT
Definition: adsi.h:120

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(), ast_adsi_voice_mode(), and buf.

Referenced by vm_authenticate().

◆ adsi_logo()

static int adsi_logo ( unsigned char *  buf)
static

Definition at line 7168 of file app_voicemail.c.

7169 {
7170  int bytes = 0;
7171  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
7172  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
7173  return bytes;
7174 }

References ADSI_COMM_PAGE, ADSI_JUST_CENT, ast_adsi_display(), and buf.

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

◆ adsi_message()

static void adsi_message ( struct ast_channel chan,
struct vm_state vms 
)
static

Definition at line 7399 of file app_voicemail.c.

7400 {
7401  int bytes = 0;
7402  unsigned char buf[256];
7403  char buf1[256], buf2[256];
7404  char fn2[PATH_MAX];
7405 
7406  char cid[256] = "";
7407  char *val;
7408  char *name, *num;
7409  char datetime[21] = "";
7410  FILE *f;
7411 
7412  unsigned char keys[8];
7413 
7414  int x;
7415 
7416  if (!ast_adsi_available(chan))
7417  return;
7418 
7419  /* Retrieve important info */
7420  snprintf(fn2, sizeof(fn2), "%s.txt", vms->fn);
7421  f = fopen(fn2, "r");
7422  if (f) {
7423  while (!feof(f)) {
7424  if (!fgets((char *) buf, sizeof(buf), f)) {
7425  continue;
7426  }
7427  if (!feof(f)) {
7428  char *stringp = NULL;
7429  stringp = (char *) buf;
7430  strsep(&stringp, "=");
7431  val = strsep(&stringp, "=");
7432  if (!ast_strlen_zero(val)) {
7433  if (!strcmp((char *) buf, "callerid"))
7434  ast_copy_string(cid, val, sizeof(cid));
7435  if (!strcmp((char *) buf, "origdate"))
7436  ast_copy_string(datetime, val, sizeof(datetime));
7437  }
7438  }
7439  }
7440  fclose(f);
7441  }
7442  /* New meaning for keys */
7443  for (x = 0; x < 5; x++)
7444  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7445  keys[6] = 0x0;
7446  keys[7] = 0x0;
7447 
7448  if (!vms->curmsg) {
7449  /* No prev key, provide "Folder" instead */
7450  keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7451  }
7452  if (vms->curmsg >= vms->lastmsg) {
7453  /* If last message ... */
7454  if (vms->curmsg) {
7455  /* but not only message, provide "Folder" instead */
7456  keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7457  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7458 
7459  } else {
7460  /* Otherwise if only message, leave blank */
7461  keys[3] = 1;
7462  }
7463  }
7464 
7465  if (!ast_strlen_zero(cid)) {
7466  ast_callerid_parse(cid, &name, &num);
7467  if (!name)
7468  name = num;
7469  } else {
7470  name = "Unknown Caller";
7471  }
7472 
7473  /* If deleted, show "undeleted" */
7474 #ifdef IMAP_STORAGE
7475  ast_mutex_lock(&vms->lock);
7476 #endif
7477  if (vms->deleted[vms->curmsg]) {
7478  keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7479  }
7480 #ifdef IMAP_STORAGE
7481  ast_mutex_unlock(&vms->lock);
7482 #endif
7483 
7484  /* Except "Exit" */
7485  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7486  snprintf(buf1, sizeof(buf1), "%s%s", vms->curbox,
7487  strcasecmp(vms->curbox, "INBOX") ? " Messages" : "");
7488  snprintf(buf2, sizeof(buf2), "Message %d of %d", vms->curmsg + 1, vms->lastmsg + 1);
7489 
7490  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7491  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7492  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, name, "");
7493  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, datetime, "");
7494  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7495  bytes += ast_adsi_set_keys(buf + bytes, keys);
7496  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7497 
7499 }
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
Definition: callerid.c:1008
static const char name[]
Definition: format_mp3.c:68
static struct ast_threadstorage buf2
static struct ast_threadstorage buf1
char curbox[80]
char fn[PATH_MAX]

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_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), buf, buf1, buf2, vm_state::curbox, vm_state::curmsg, vm_state::deleted, vm_state::fn, vm_state::lastmsg, name, NULL, PATH_MAX, and strsep().

Referenced by play_message(), and vm_execmain().

◆ adsi_password()

static void adsi_password ( struct ast_channel chan)
static

Definition at line 7348 of file app_voicemail.c.

7349 {
7350  unsigned char buf[256];
7351  int bytes = 0;
7352  unsigned char keys[8];
7353  int x;
7354  if (!ast_adsi_available(chan))
7355  return;
7356 
7357  for (x = 0; x < 8; x++)
7358  keys[x] = 0;
7359  /* Set one key for next */
7360  keys[3] = ADSI_KEY_APPS + 3;
7361 
7362  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7363  bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
7364  bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
7365  bytes += ast_adsi_set_keys(buf + bytes, keys);
7366  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7368 }

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(), ast_adsi_voice_mode(), and buf.

Referenced by vm_authenticate().

◆ adsi_status()

static void adsi_status ( struct ast_channel chan,
struct vm_state vms 
)
static

Definition at line 7553 of file app_voicemail.c.

7554 {
7555  unsigned char buf[256] = "";
7556  char buf1[256] = "", buf2[256] = "";
7557  int bytes = 0;
7558  unsigned char keys[8];
7559  int x;
7560 
7561  char *newm = (vms->newmessages == 1) ? "message" : "messages";
7562  char *oldm = (vms->oldmessages == 1) ? "message" : "messages";
7563  if (!ast_adsi_available(chan))
7564  return;
7565  if (vms->newmessages) {
7566  snprintf(buf1, sizeof(buf1), "You have %d new", vms->newmessages);
7567  if (vms->oldmessages) {
7568  strncat(buf1, " and", sizeof(buf1) - strlen(buf1) - 1);
7569  snprintf(buf2, sizeof(buf2), "%d old %s.", vms->oldmessages, oldm);
7570  } else {
7571  snprintf(buf2, sizeof(buf2), "%s.", newm);
7572  }
7573  } else if (vms->oldmessages) {
7574  snprintf(buf1, sizeof(buf1), "You have %d old", vms->oldmessages);
7575  snprintf(buf2, sizeof(buf2), "%s.", oldm);
7576  } else {
7577  strcpy(buf1, "You have no messages.");
7578  buf2[0] = ' ';
7579  buf2[1] = '\0';
7580  }
7581  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7582  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7583  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7584 
7585  for (x = 0; x < 6; x++)
7586  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7587  keys[6] = 0;
7588  keys[7] = 0;
7589 
7590  /* Don't let them listen if there are none */
7591  if (vms->lastmsg < 0)
7592  keys[0] = 1;
7593  bytes += ast_adsi_set_keys(buf + bytes, keys);
7594 
7595  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7596 
7598 }
int newmessages
int oldmessages

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(), buf, buf1, buf2, vm_state::lastmsg, vm_state::newmessages, and vm_state::oldmessages.

Referenced by vm_execmain().

◆ adsi_status2()

static void adsi_status2 ( struct ast_channel chan,
struct vm_state vms 
)
static

Definition at line 7600 of file app_voicemail.c.

7601 {
7602  unsigned char buf[256] = "";
7603  char buf1[256] = "", buf2[256] = "";
7604  int bytes = 0;
7605  unsigned char keys[8];
7606  int x;
7607 
7608  char *mess = (vms->lastmsg == 0) ? "message" : "messages";
7609 
7610  if (!ast_adsi_available(chan))
7611  return;
7612 
7613  /* Original command keys */
7614  for (x = 0; x < 6; x++)
7615  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7616 
7617  keys[6] = 0;
7618  keys[7] = 0;
7619 
7620  if ((vms->lastmsg + 1) < 1)
7621  keys[0] = 0;
7622 
7623  snprintf(buf1, sizeof(buf1), "%s%s has", vms->curbox,
7624  strcasecmp(vms->curbox, "INBOX") ? " folder" : "");
7625 
7626  if (vms->lastmsg + 1)
7627  snprintf(buf2, sizeof(buf2), "%d %s.", vms->lastmsg + 1, mess);
7628  else
7629  strcpy(buf2, "no messages.");
7630  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7631  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7632  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, "", "");
7633  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7634  bytes += ast_adsi_set_keys(buf + bytes, keys);
7635 
7636  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7637 
7639 
7640 }

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(), buf, buf1, buf2, vm_state::curbox, and vm_state::lastmsg.

Referenced by vm_execmain().

◆ advanced_options()

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.

Parameters
chan
vmu
vms
msg
option
record_gainProvides handling for the play message envelope, call the person back, or reply to message.
Returns
zero on success, -1 on error.

Definition at line 15215 of file app_voicemail.c.

15216 {
15217  int res = 0;
15218  char filename[PATH_MAX];
15219  struct ast_config *msg_cfg = NULL;
15220  const char *origtime, *context;
15221  char *name, *num;
15222  int retries = 0;
15223  char *cid;
15224  struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE, };
15225 
15226  vms->starting = 0;
15227 
15228  make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
15229 
15230  /* Retrieve info from VM attribute file */
15231  snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
15232  RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
15233  msg_cfg = ast_config_load(filename, config_flags);
15234  DISPOSE(vms->curdir, vms->curmsg);
15235  if (!valid_config(msg_cfg)) {
15236  ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
15237  return 0;
15238  }
15239 
15240  if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) {
15241  ast_config_destroy(msg_cfg);
15242  return 0;
15243  }
15244 
15245  cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid"));
15246 
15247  context = ast_variable_retrieve(msg_cfg, "message", "context");
15248  if (!strncasecmp("macro", context, 5)) /* Macro names in contexts are useless for our needs */
15249  context = ast_variable_retrieve(msg_cfg, "message", "macrocontext");
15250  switch (option) {
15251  case 3: /* Play message envelope */
15252  if (!res) {
15253  res = play_message_datetime(chan, vmu, origtime, filename);
15254  }
15255  if (!res) {
15256  res = play_message_callerid(chan, vms, cid, context, 0, 1);
15257  }
15258 
15259  res = 't';
15260  break;
15261 
15262  case 2: /* Call back */
15263 
15264  if (ast_strlen_zero(cid))
15265  break;
15266 
15267  ast_callerid_parse(cid, &name, &num);
15268  while ((res > -1) && (res != 't')) {
15269  switch (res) {
15270  case '1':
15271  if (num) {
15272  /* Dial the CID number */
15273  res = dialout(chan, vmu, num, vmu->callback);
15274  if (res) {
15275  ast_config_destroy(msg_cfg);
15276  return 9;
15277  }
15278  } else {
15279  res = '2';
15280  }
15281  break;
15282 
15283  case '2':
15284  /* Want to enter a different number, can only do this if there's a dialout context for this user */
15285  if (!ast_strlen_zero(vmu->dialout)) {
15286  res = dialout(chan, vmu, NULL, vmu->dialout);
15287  if (res) {
15288  ast_config_destroy(msg_cfg);
15289  return 9;
15290  }
15291  } else {
15292  ast_verb(3, "Caller can not specify callback number - no dialout context available\n");
15293  res = ast_play_and_wait(chan, "vm-sorry");
15294  }
15295  ast_config_destroy(msg_cfg);
15296  return res;
15297  case '*':
15298  res = 't';
15299  break;
15300  case '3':
15301  case '4':
15302  case '5':
15303  case '6':
15304  case '7':
15305  case '8':
15306  case '9':
15307  case '0':
15308 
15309  res = ast_play_and_wait(chan, "vm-sorry");
15310  retries++;
15311  break;
15312  default:
15313  if (num) {
15314  ast_verb(3, "Confirm CID number '%s' is number to use for callback\n", num);
15315  res = ast_play_and_wait(chan, "vm-num-i-have");
15316  if (!res)
15317  res = play_message_callerid(chan, vms, num, vmu->context, 1, 1);
15318  if (!res)
15319  res = ast_play_and_wait(chan, "vm-tocallnum");
15320  /* Only prompt for a caller-specified number if there is a dialout context specified */
15321  if (!ast_strlen_zero(vmu->dialout)) {
15322  if (!res)
15323  res = ast_play_and_wait(chan, "vm-calldiffnum");
15324  }
15325  } else {
15326  res = ast_play_and_wait(chan, "vm-nonumber");
15327  if (!ast_strlen_zero(vmu->dialout)) {
15328  if (!res)
15329  res = ast_play_and_wait(chan, "vm-toenternumber");
15330  }
15331  }
15332  if (!res) {
15333  res = ast_play_and_wait(chan, "vm-star-cancel");
15334  }
15335  if (!res) {
15336  res = ast_waitfordigit(chan, 6000);
15337  }
15338  if (!res) {
15339  retries++;
15340  if (retries > 3) {
15341  res = 't';
15342  }
15343  }
15344  ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
15345  isprint(res) ? res : '?', isprint(res) ? res : '?');
15346  break;
15347 
15348  }
15349  if (res == 't')
15350  res = 0;
15351  else if (res == '*')
15352  res = -1;
15353  }
15354  break;
15355 
15356  case 1: /* Reply */
15357  /* Send reply directly to sender */
15358  if (ast_strlen_zero(cid))
15359  break;
15360 
15361  ast_callerid_parse(cid, &name, &num);
15362  if (!num) {
15363  ast_verb(3, "No CID number available, no reply sent\n");
15364  if (!res)
15365  res = ast_play_and_wait(chan, "vm-nonumber");
15366  ast_config_destroy(msg_cfg);
15367  return res;
15368  } else {
15369  struct ast_vm_user vmu2, *vmu3;
15370  memset(&vmu2, 0, sizeof(vmu2));
15371  vmu3 = find_user(&vmu2, vmu->context, num);
15372  if (vmu3) {
15373  struct leave_vm_options leave_options;
15374  char mailbox[AST_MAX_EXTENSION * 2 + 2];
15375  snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context);
15376 
15377  ast_verb(3, "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
15378 
15379  memset(&leave_options, 0, sizeof(leave_options));
15380  leave_options.record_gain = record_gain;
15381  leave_options.beeptone = "beep";
15382  res = leave_voicemail(chan, mailbox, &leave_options);
15383  if (!res)
15384  res = 't';
15385  ast_config_destroy(msg_cfg);
15386  free_user(vmu3);
15387  return res;
15388  } else {
15389  /* Sender has no mailbox, can't reply */
15390  ast_verb(3, "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
15391  ast_play_and_wait(chan, "vm-nobox");
15392  res = 't';
15393  ast_config_destroy(msg_cfg);
15394  return res;
15395  }
15396  }
15397  res = 0;
15398 
15399  break;
15400  }
15401 
15402  ast_config_destroy(msg_cfg);
15403 
15404 #ifndef IMAP_STORAGE
15405  if (!res) {
15406  make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
15407  vms->heard[msg] = 1;
15408  res = wait_file(chan, vms, vms->fn);
15409  }
15410 #endif
15411  return res;
15412 }
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 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 appropria...
static int valid_config(const struct ast_config *cfg)
Check if configuration file is valid.
static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback, int saycidnumber)
#define DISPOSE(a, b)
static int wait_file(struct ast_channel *chan, struct vm_state *vms, char *file)
static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *vmu, const char *origtime, const char *filename)
#define RETRIEVE(a, b, c, d)
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3176
#define AST_MAX_EXTENSION
Definition: channel.h:134
int ast_play_and_wait(struct ast_channel *chan, const char *fn)
Play a stream and wait for a digit, returning the digit that was pressed.
Definition: main/app.c:1686
#define ast_config_load(filename, flags)
Load a config file.
@ CONFIG_FLAG_NOCACHE
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
#define ast_verb(level,...)
Structure used to handle boolean flags.
Definition: utils.h:199
char callback[80]
char dialout[80]
Options for leaving voicemail with the voicemail() application.
Definition: app_minivm.c:654
signed char record_gain
Definition: app_minivm.c:656
char curdir[PATH_MAX]
int * heard
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189

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_test_suite_event_notify, ast_variable_retrieve(), ast_verb, ast_waitfordigit(), leave_vm_options::beeptone, ast_vm_user::callback, CONFIG_FLAG_NOCACHE, context, ast_vm_user::context, vm_state::curdir, vm_state::curmsg, dialout(), ast_vm_user::dialout, DISPOSE, find_user(), vm_state::fn, free_user(), vm_state::heard, leave_voicemail(), mailbox, ast_vm_user::mailbox, make_file(), name, NULL, PATH_MAX, play_message_callerid(), play_message_datetime(), leave_vm_options::record_gain, RETRIEVE, vm_state::starting, valid_config(), and wait_file().

Referenced by vm_execmain().

◆ alias_mailbox_mapping_create()

static struct alias_mailbox_mapping* alias_mailbox_mapping_create ( const char *  alias,
const char *  mailbox 
)
static

Definition at line 13498 of file app_voicemail.c.

13499 {
13500  struct alias_mailbox_mapping *mapping;
13501  size_t from_len = strlen(alias) + 1;
13502  size_t to_len = strlen(mailbox) + 1;
13503 
13504  mapping = ao2_alloc(sizeof(*mapping) + from_len + to_len, NULL);
13505  if (!mapping) {
13506  return NULL;
13507  }
13508  mapping->alias = mapping->buf;
13509  mapping->mailbox = mapping->buf + from_len;
13510  ast_copy_string(mapping->alias, alias, from_len); /* Safe */
13511  ast_copy_string(mapping->mailbox, mailbox, to_len); /* Safe */
13512 
13513  return mapping;
13514 }
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409

References alias_mailbox_mapping::alias, ao2_alloc, ast_copy_string(), alias_mailbox_mapping::buf, alias_mailbox_mapping::mailbox, mailbox, and NULL.

Referenced by load_aliases().

◆ AO2_STRING_FIELD_CMP_FN() [1/2]

AO2_STRING_FIELD_CMP_FN ( alias_mailbox_mapping  ,
alias   
)

◆ AO2_STRING_FIELD_CMP_FN() [2/2]

AO2_STRING_FIELD_CMP_FN ( mailbox_alias_mapping  ,
mailbox   
)

◆ AO2_STRING_FIELD_HASH_FN() [1/2]

AO2_STRING_FIELD_HASH_FN ( alias_mailbox_mapping  ,
alias   
)

◆ AO2_STRING_FIELD_HASH_FN() [2/2]

AO2_STRING_FIELD_HASH_FN ( mailbox_alias_mapping  ,
mailbox   
)

◆ append_mailbox()

static int append_mailbox ( const char *  context,
const char *  box,
const char *  data 
)
static

Definition at line 12335 of file app_voicemail.c.

12336 {
12337  /* Assumes lock is already held */
12338  char *tmp;
12339  char *stringp;
12340  char *s;
12341  struct ast_vm_user *vmu;
12342  char mailbox_full[MAX_VM_MAILBOX_LEN];
12343  int new = 0, old = 0, urgent = 0;
12344  char secretfn[PATH_MAX] = "";
12345 
12346  tmp = ast_strdupa(data);
12347 
12348  if (!(vmu = find_or_create(context, box)))
12349  return -1;
12350 
12351  populate_defaults(vmu);
12352 
12353  stringp = tmp;
12354  if ((s = strsep(&stringp, ","))) {
12355  if (!ast_strlen_zero(s) && s[0] == '*') {
12356  ast_log(LOG_WARNING, "Invalid password detected for mailbox %s. The password"
12357  "\n\tmust be reset in voicemail.conf.\n", box);
12358  }
12359  /* assign password regardless of validity to prevent NULL password from being assigned */
12360  ast_copy_string(vmu->password, s, sizeof(vmu->password));
12361  }
12362  if (stringp && (s = strsep(&stringp, ","))) {
12363  ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
12364  }
12365  if (stringp && (s = strsep(&stringp, ","))) {
12366  vmu->email = ast_strdup(s);
12367  }
12368  if (stringp && (s = strsep(&stringp, ","))) {
12369  ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
12370  }
12371  if (stringp) {
12372  apply_options(vmu, stringp);
12373  }
12374 
12375  switch (vmu->passwordlocation) {
12376  case OPT_PWLOC_SPOOLDIR:
12377  snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
12378  read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
12379  }
12380 
12381  snprintf(mailbox_full, MAX_VM_MAILBOX_LEN, "%s%s%s",
12382  box,
12383  ast_strlen_zero(context) ? "" : "@",
12384  context);
12385 
12386  inboxcount2(mailbox_full, &urgent, &new, &old);
12387 #ifdef IMAP_STORAGE
12388  imap_logout(mailbox_full);
12389 #endif
12390  queue_mwi_event(NULL, mailbox_full, urgent, new, old);
12391 
12392  return 0;
12393 }
static void apply_options(struct ast_vm_user *vmu, const char *options)
Destructively Parse options and apply.
static void queue_mwi_event(const char *channel_id, const char *box, int urgent, int new, int old)
static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Check the given mailbox's message count.
int passwordlocation

References apply_options(), ast_copy_string(), ast_log, ast_strdup, ast_strdupa, ast_strlen_zero(), context, ast_vm_user::context, ast_vm_user::email, find_or_create(), ast_vm_user::fullname, inboxcount2(), LOG_WARNING, ast_vm_user::mailbox, MAX_VM_MAILBOX_LEN, NULL, OPT_PWLOC_SPOOLDIR, ast_vm_user::pager, ast_vm_user::password, ast_vm_user::passwordlocation, PATH_MAX, populate_defaults(), queue_mwi_event(), read_password_from_file(), strsep(), tmp(), and VM_SPOOL_DIR.

Referenced by load_users().

◆ append_vmu_info_astman()

static int append_vmu_info_astman ( struct mansession s,
struct ast_vm_user vmu,
const char *  event_name,
const char *  actionid 
)
static

Append vmu info string into given astman with event_name.

Returns
0 failed. 1 otherwise.

Definition at line 13137 of file app_voicemail.c.

13143 {
13144  int new;
13145  int old;
13146  char *mailbox;
13147  int ret;
13148 
13149  if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {
13150  ast_log(LOG_ERROR, "Wrong input parameter.");
13151  return 0;
13152  }
13153 
13154  /* create mailbox string */
13155  if (!ast_strlen_zero(vmu->context)) {
13156  ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);
13157  } else {
13158  ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);
13159  }
13160  if (ret == -1) {
13161  ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));
13162  return 0;
13163  }
13164 
13165  /* get mailbox count */
13166  ret = inboxcount(mailbox, &new, &old);
13167  ast_free(mailbox);
13168  if (ret == -1) {
13169  ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n",
13170  vmu->mailbox ?: "", vmu->context ?: "");
13171  return 0;
13172  }
13173 
13174  astman_append(s,
13175  "Event: %s\r\n"
13176  "%s"
13177  "VMContext: %s\r\n"
13178  "VoiceMailbox: %s\r\n"
13179  "Fullname: %s\r\n"
13180  "Email: %s\r\n"
13181  "Pager: %s\r\n"
13182  "ServerEmail: %s\r\n"
13183  "FromString: %s\r\n"
13184  "MailCommand: %s\r\n"
13185  "Language: %s\r\n"
13186  "TimeZone: %s\r\n"
13187  "Callback: %s\r\n"
13188  "Dialout: %s\r\n"
13189  "UniqueID: %s\r\n"
13190  "ExitContext: %s\r\n"
13191  "SayDurationMinimum: %d\r\n"
13192  "SayEnvelope: %s\r\n"
13193  "SayCID: %s\r\n"
13194  "AttachMessage: %s\r\n"
13195  "AttachmentFormat: %s\r\n"
13196  "DeleteMessage: %s\r\n"
13197  "VolumeGain: %.2f\r\n"
13198  "CanReview: %s\r\n"
13199  "CallOperator: %s\r\n"
13200  "MaxMessageCount: %d\r\n"
13201  "MaxMessageLength: %d\r\n"
13202  "NewMessageCount: %d\r\n"
13203  "OldMessageCount: %d\r\n"
13204 #ifdef IMAP_STORAGE
13205  "IMAPUser: %s\r\n"
13206  "IMAPServer: %s\r\n"
13207  "IMAPPort: %s\r\n"
13208  "IMAPFlags: %s\r\n"
13209 #endif
13210  "\r\n",
13211 
13212  event_name,
13213  actionid,
13214  vmu->context,
13215  vmu->mailbox,
13216  vmu->fullname,
13217  vmu->email,
13218  vmu->pager,
13221  mailcmd,
13222  vmu->language,
13223  vmu->zonetag,
13224  vmu->callback,
13225  vmu->dialout,
13226  vmu->uniqueid,
13227  vmu->exit,
13228  vmu->saydurationm,
13229  ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
13230  ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
13231  ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
13232  vmu->attachfmt,
13233  ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
13234  vmu->volgain,
13235  ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
13236  ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
13237  vmu->maxmsg,
13238  vmu->maxsecs,
13239  new,
13240  old
13241 #ifdef IMAP_STORAGE
13242  ,
13243  vmu->imapuser,
13244  vmu->imapserver,
13245  vmu->imapport,
13246  vmu->imapflags
13247 #endif
13248  );
13249 
13250  return 1;
13251 
13252 }
static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
#define VM_DELETE
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3087
char serveremail[80]
char uniqueid[80]
char fromstring[100]
char exit[80]
char attachfmt[20]
#define ast_test_flag(p, flag)
Definition: utils.h:63

References ast_asprintf, ast_free, ast_log, ast_strlen_zero(), ast_test_flag, astman_append(), ast_vm_user::attachfmt, ast_vm_user::callback, ast_vm_user::context, ast_vm_user::dialout, ast_vm_user::email, errno, ast_vm_user::exit, ast_vm_user::fromstring, fromstring, ast_vm_user::fullname, inboxcount(), ast_vm_user::language, LOG_ERROR, mailbox, ast_vm_user::mailbox, mailcmd, ast_vm_user::maxmsg, ast_vm_user::maxsecs, NULL, ast_vm_user::pager, ast_vm_user::saydurationm, ast_vm_user::serveremail, 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 manager_list_voicemail_users(), and manager_status_voicemail_user().

◆ apply_option()

static void apply_option ( struct ast_vm_user vmu,
const char *  var,
const char *  value 
)
static

Sets a specific property value.

Parameters
vmuThe voicemail user object to work with.
varThe name of the property to be set.
valueThe value to be set to the property.

The property name must be one of the understood properties. See the source for details.

Definition at line 1248 of file app_voicemail.c.

1249 {
1250  int x;
1251  if (!strcasecmp(var, "attach")) {
1253  } else if (!strcasecmp(var, "attachfmt")) {
1254  ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
1255  } else if (!strcasecmp(var, "serveremail")) {
1256  ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
1257  } else if (!strcasecmp(var, "fromstring")) {
1258  ast_copy_string(vmu->fromstring, value, sizeof(vmu->fromstring));
1259  } else if (!strcasecmp(var, "emailbody")) {
1260  ast_free(vmu->emailbody);
1262  } else if (!strcasecmp(var, "emailsubject")) {
1263  ast_free(vmu->emailsubject);
1265  } else if (!strcasecmp(var, "language")) {
1266  ast_copy_string(vmu->language, value, sizeof(vmu->language));
1267  } else if (!strcasecmp(var, "tz")) {
1268  ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
1269  } else if (!strcasecmp(var, "locale")) {
1270  ast_copy_string(vmu->locale, value, sizeof(vmu->locale));
1271 #ifdef IMAP_STORAGE
1272  } else if (!strcasecmp(var, "imapuser")) {
1273  ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
1274  vmu->imapversion = imapversion;
1275  } else if (!strcasecmp(var, "imapserver")) {
1276  ast_copy_string(vmu->imapserver, value, sizeof(vmu->imapserver));
1277  vmu->imapversion = imapversion;
1278  } else if (!strcasecmp(var, "imapport")) {
1279  ast_copy_string(vmu->imapport, value, sizeof(vmu->imapport));
1280  vmu->imapversion = imapversion;
1281  } else if (!strcasecmp(var, "imapflags")) {
1282  ast_copy_string(vmu->imapflags, value, sizeof(vmu->imapflags));
1283  vmu->imapversion = imapversion;
1284  } else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
1285  ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
1286  vmu->imapversion = imapversion;
1287  } else if (!strcasecmp(var, "imapfolder")) {
1288  ast_copy_string(vmu->imapfolder, value, sizeof(vmu->imapfolder));
1289  vmu->imapversion = imapversion;
1290  } else if (!strcasecmp(var, "imapvmshareid")) {
1291  ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
1292  vmu->imapversion = imapversion;
1293 #endif
1294  } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
1296  } else if (!strcasecmp(var, "saycid")){
1298  } else if (!strcasecmp(var, "sendvoicemail")){
1300  } else if (!strcasecmp(var, "review")){
1302  } else if (!strcasecmp(var, "tempgreetwarn")){
1304  } else if (!strcasecmp(var, "messagewrap")){
1306  } else if (!strcasecmp(var, "operator")) {
1308  } else if (!strcasecmp(var, "envelope")){
1310  } else if (!strcasecmp(var, "moveheard")){
1312  } else if (!strcasecmp(var, "sayduration")){
1314  } else if (!strcasecmp(var, "saydurationm")){
1315  if (sscanf(value, "%30d", &x) == 1) {
1316  vmu->saydurationm = x;
1317  } else {
1318  ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
1319  }
1320  } else if (!strcasecmp(var, "forcename")){
1322  } else if (!strcasecmp(var, "forcegreetings")){
1324  } else if (!strcasecmp(var, "callback")) {
1325  ast_copy_string(vmu->callback, value, sizeof(vmu->callback));
1326  } else if (!strcasecmp(var, "dialout")) {
1327  ast_copy_string(vmu->dialout, value, sizeof(vmu->dialout));
1328  } else if (!strcasecmp(var, "exitcontext")) {
1329  ast_copy_string(vmu->exit, value, sizeof(vmu->exit));
1330  } else if (!strcasecmp(var, "minsecs")) {
1331  if (sscanf(value, "%30d", &x) == 1 && x >= 0) {
1332  vmu->minsecs = x;
1333  } else {
1334  ast_log(LOG_WARNING, "Invalid min message length of %s. Using global value %d\n", value, vmminsecs);
1335  vmu->minsecs = vmminsecs;
1336  }
1337  } else if (!strcasecmp(var, "maxmessage") || !strcasecmp(var, "maxsecs")) {
1338  vmu->maxsecs = atoi(value);
1339  if (vmu->maxsecs <= 0) {
1340  ast_log(AST_LOG_WARNING, "Invalid max message length of %s. Using global value %d\n", value, vmmaxsecs);
1341  vmu->maxsecs = vmmaxsecs;
1342  } else {
1343  vmu->maxsecs = atoi(value);
1344  }
1345  if (!strcasecmp(var, "maxmessage"))
1346  ast_log(AST_LOG_WARNING, "Option 'maxmessage' has been deprecated in favor of 'maxsecs'. Please make that change in your voicemail config.\n");
1347  } else if (!strcasecmp(var, "maxmsg")) {
1348  vmu->maxmsg = atoi(value);
1349  /* Accept maxmsg=0 (Greetings only voicemail) */
1350  if (vmu->maxmsg < 0) {
1351  ast_log(AST_LOG_WARNING, "Invalid number of messages per folder maxmsg=%s. Using default value %d\n", value, MAXMSG);
1352  vmu->maxmsg = MAXMSG;
1353  } else if (vmu->maxmsg > MAXMSGLIMIT) {
1354  ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %d. Cannot accept value maxmsg=%s\n", MAXMSGLIMIT, value);
1355  vmu->maxmsg = MAXMSGLIMIT;
1356  }
1357  } else if (!strcasecmp(var, "nextaftercmd")) {
1359  } else if (!strcasecmp(var, "backupdeleted")) {
1360  if (sscanf(value, "%30d", &x) == 1)
1361  vmu->maxdeletedmsg = x;
1362  else if (ast_true(value))
1363  vmu->maxdeletedmsg = MAXMSG;
1364  else
1365  vmu->maxdeletedmsg = 0;
1366 
1367  if (vmu->maxdeletedmsg < 0) {
1368  ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox backupdeleted=%s. Using default value %d\n", value, MAXMSG);
1369  vmu->maxdeletedmsg = MAXMSG;
1370  } else if (vmu->maxdeletedmsg > MAXMSGLIMIT) {
1371  ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %d. Cannot accept value backupdeleted=%s\n", MAXMSGLIMIT, value);
1372  vmu->maxdeletedmsg = MAXMSGLIMIT;
1373  }
1374  } else if (!strcasecmp(var, "volgain")) {
1375  sscanf(value, "%30lf", &vmu->volgain);
1376  } else if (!strcasecmp(var, "passwordlocation")) {
1377  if (!strcasecmp(value, "spooldir")) {
1379  } else {
1381  }
1382  } else if (!strcasecmp(var, "options")) {
1383  apply_options(vmu, value);
1384  }
1385 }
char * emailsubject
char * emailbody
int value
Definition: syslog.c:37

References apply_options(), ast_copy_string(), ast_free, ast_log, AST_LOG_WARNING, ast_set2_flag, ast_strdup, ast_true(), ast_vm_user::attachfmt, ast_vm_user::callback, ast_vm_user::dialout, ast_vm_user::emailbody, ast_vm_user::emailsubject, ast_vm_user::exit, ast_vm_user::fromstring, ast_vm_user::language, ast_vm_user::locale, LOG_WARNING, ast_vm_user::maxdeletedmsg, MAXMSG, ast_vm_user::maxmsg, MAXMSGLIMIT, ast_vm_user::maxsecs, ast_vm_user::minsecs, OPT_PWLOC_SPOOLDIR, OPT_PWLOC_VOICEMAILCONF, ast_vm_user::passwordlocation, ast_vm_user::saydurationm, ast_vm_user::serveremail, substitute_escapes(), value, var, VM_ATTACH, VM_DELETE, VM_ENVELOPE, VM_FORCEGREET, VM_FORCENAME, VM_MESSAGEWRAP, VM_MOVEHEARD, VM_OPERATOR, VM_REVIEW, VM_SAYCID, VM_SAYDURATION, VM_SKIPAFTERCMD, VM_SVMAIL, VM_TEMPGREETWARN, vmmaxsecs, vmminsecs, ast_vm_user::volgain, and ast_vm_user::zonetag.

Referenced by apply_options(), and apply_options_full().

◆ apply_options()

static void apply_options ( struct ast_vm_user vmu,
const char *  options 
)
static

Destructively Parse options and apply.

Definition at line 1503 of file app_voicemail.c.

1504 {
1505  char *stringp;
1506  char *s;
1507  char *var, *value;
1508  stringp = ast_strdupa(options);
1509  while ((s = strsep(&stringp, "|"))) {
1510  value = s;
1511  if ((var = strsep(&value, "=")) && value) {
1512  apply_option(vmu, var, value);
1513  }
1514  }
1515 }
static void apply_option(struct ast_vm_user *vmu, const char *var, const char *value)
Sets a specific property value.
static struct test_options options

References apply_option(), ast_strdupa, options, strsep(), value, and var.

Referenced by append_mailbox(), and apply_option().

◆ apply_options_full()

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 1522 of file app_voicemail.c.

1523 {
1524  for (; var; var = var->next) {
1525  if (!strcasecmp(var->name, "vmsecret")) {
1526  ast_copy_string(retval->password, var->value, sizeof(retval->password));
1527  } else if (!strcasecmp(var->name, "secret") || !strcasecmp(var->name, "password")) { /* don't overwrite vmsecret if it exists */
1528  if (ast_strlen_zero(retval->password)) {
1529  if (!ast_strlen_zero(var->value) && var->value[0] == '*') {
1530  ast_log(LOG_WARNING, "Invalid password detected for mailbox %s. The password"
1531  "\n\tmust be reset in voicemail.conf.\n", retval->mailbox);
1532  } else {
1533  ast_copy_string(retval->password, var->value, sizeof(retval->password));
1534  }
1535  }
1536  } else if (!strcasecmp(var->name, "uniqueid")) {
1537  ast_copy_string(retval->uniqueid, var->value, sizeof(retval->uniqueid));
1538  } else if (!strcasecmp(var->name, "pager")) {
1539  ast_copy_string(retval->pager, var->value, sizeof(retval->pager));
1540  } else if (!strcasecmp(var->name, "email")) {
1541  ast_free(retval->email);
1542  retval->email = ast_strdup(var->value);
1543  } else if (!strcasecmp(var->name, "fullname")) {
1544  ast_copy_string(retval->fullname, var->value, sizeof(retval->fullname));
1545  } else if (!strcasecmp(var->name, "context")) {
1546  ast_copy_string(retval->context, var->value, sizeof(retval->context));
1547  } else if (!strcasecmp(var->name, "emailsubject")) {
1548  ast_free(retval->emailsubject);
1549  retval->emailsubject = ast_strdup(substitute_escapes(var->value));
1550  } else if (!strcasecmp(var->name, "emailbody")) {
1551  ast_free(retval->emailbody);
1552  retval->emailbody = ast_strdup(substitute_escapes(var->value));
1553 #ifdef IMAP_STORAGE
1554  } else if (!strcasecmp(var->name, "imapuser")) {
1555  ast_copy_string(retval->imapuser, var->value, sizeof(retval->imapuser));
1556  retval->imapversion = imapversion;
1557  } else if (!strcasecmp(var->name, "imapserver")) {
1558  ast_copy_string(retval->imapserver, var->value, sizeof(retval->imapserver));
1559  retval->imapversion = imapversion;
1560  } else if (!strcasecmp(var->name, "imapport")) {
1561  ast_copy_string(retval->imapport, var->value, sizeof(retval->imapport));
1562  retval->imapversion = imapversion;
1563  } else if (!strcasecmp(var->name, "imapflags")) {
1564  ast_copy_string(retval->imapflags, var->value, sizeof(retval->imapflags));
1565  retval->imapversion = imapversion;
1566  } else if (!strcasecmp(var->name, "imappassword") || !strcasecmp(var->name, "imapsecret")) {
1567  ast_copy_string(retval->imappassword, var->value, sizeof(retval->imappassword));
1568  retval->imapversion = imapversion;
1569  } else if (!strcasecmp(var->name, "imapfolder")) {
1570  ast_copy_string(retval->imapfolder, var->value, sizeof(retval->imapfolder));
1571  retval->imapversion = imapversion;
1572  } else if (!strcasecmp(var->name, "imapvmshareid")) {
1573  ast_copy_string(retval->imapvmshareid,