Asterisk - The Open Source Telephony Project  GIT-master-c797500
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"

Go to the source code of this file.

Data Structures

struct  alias_mailbox_mapping
 
struct  ast_vm_user
 
struct  baseio
 
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 BASELINELEN   72
 
#define BASEMAXINLINE   256
 
#define CHUNKSIZE   65536
 
#define COMMAND_TIMEOUT   5000
 
#define COPY(a, b, c, d, e, f, g, h)   (copy_plain_file(g,h));
 
#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY   "#"
 
#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY   "0"
 
#define DEFAULT_LISTEN_CONTROL_RESTART_KEY   "2"
 
#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY   "*"
 
#define DEFAULT_LISTEN_CONTROL_STOP_KEY   "13456789"
 
#define DEFAULT_POLL_FREQ   30
 
#define DELETE(a, b, c, d)   (vm_delete(c))
 
#define DISPOSE(a, b)
 
#define ENDL   "\n"
 
#define ERROR_LOCK_PATH   -100
 
#define 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_DIRECFORWARD   (1 << 10)
 
#define VM_ENVELOPE   (1 << 4)
 
#define VM_FORCEGREET   (1 << 8)
 
#define VM_FORCENAME   (1 << 7)
 
#define VM_FWDURGAUTO   (1 << 18)
 
#define VM_MESSAGEWRAP   (1 << 17)
 
#define VM_MOVEHEARD   (1 << 16)
 
#define VM_OPERATOR   (1 << 1)
 
#define VM_PBXSKIP   (1 << 9)
 
#define VM_REVIEW   (1 << 0)
 
#define VM_SAYCID   (1 << 2)
 
#define VM_SAYDURATION   (1 << 5)
 
#define VM_SEARCH   (1 << 14)
 
#define VM_SKIPAFTERCMD   (1 << 6)
 
#define VM_SVMAIL   (1 << 3)
 
#define VM_TEMPGREETWARN   (1 << 15)
 
#define VMSTATE_MAX_MSG_ARRAY   256
 
#define VOICEMAIL_CONFIG   "voicemail.conf"
 
#define VOICEMAIL_DIR_MODE   0777
 
#define VOICEMAIL_FILE_MODE   0666
 

Enumerations

enum  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_ARRAY_SIZE = 3 }
 
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)
}
 
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 base_encode (char *filename, FILE *so)
 Performs a base 64 encode algorithm on the contents of a File. 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 inbuf (struct baseio *bio, FILE *fi)
 utility used by inchar(), for base_encode() More...
 
static int inchar (struct baseio *bio, FILE *fi)
 utility used by base_encode() 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 ochar (struct baseio *bio, int c, FILE *so)
 utility used by base_encode() More...
 
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_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 FILE * vm_mkftemp (char *template)
 
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 }, [ '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 } }
 
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
  • Config_vm
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 507 of file app_voicemail.c.

Referenced by actual_load_config().

◆ BASELINELEN

#define BASELINELEN   72

Definition at line 532 of file app_voicemail.c.

Referenced by ochar().

◆ BASEMAXINLINE

#define BASEMAXINLINE   256

Definition at line 533 of file app_voicemail.c.

Referenced by base_encode(), and inbuf().

◆ CHUNKSIZE

#define CHUNKSIZE   65536

Definition at line 504 of file app_voicemail.c.

◆ COMMAND_TIMEOUT

#define COMMAND_TIMEOUT   5000

Definition at line 500 of file app_voicemail.c.

◆ COPY

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

Definition at line 864 of file app_voicemail.c.

Referenced by copy_message(), and save_to_folder().

◆ DEFAULT_LISTEN_CONTROL_FORWARD_KEY

#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY   "#"

Definition at line 512 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DEFAULT_LISTEN_CONTROL_PAUSE_KEY

#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY   "0"

Definition at line 514 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DEFAULT_LISTEN_CONTROL_RESTART_KEY

#define DEFAULT_LISTEN_CONTROL_RESTART_KEY   "2"

Definition at line 515 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DEFAULT_LISTEN_CONTROL_REVERSE_KEY

#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY   "*"

Definition at line 513 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DEFAULT_LISTEN_CONTROL_STOP_KEY

#define DEFAULT_LISTEN_CONTROL_STOP_KEY   "13456789"

Definition at line 516 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DEFAULT_POLL_FREQ

#define DEFAULT_POLL_FREQ   30

By default, poll every 30 seconds

Definition at line 935 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DELETE

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

◆ DISPOSE

#define DISPOSE (   a,
  b 
)

◆ ENDL

#define ENDL   "\n"

Definition at line 537 of file app_voicemail.c.

Referenced by add_email_attachment(), base_encode(), make_email_file(), ochar(), and sendpage().

◆ ERROR_LOCK_PATH

#define ERROR_LOCK_PATH   -100

◆ ERROR_MAX_MSGS

#define ERROR_MAX_MSGS   -101

Definition at line 563 of file app_voicemail.c.

Referenced by close_mailbox(), and save_to_folder().

◆ EXISTS

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

Definition at line 862 of file app_voicemail.c.

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

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

Referenced by leave_voicemail(), and play_record_review().

◆ MAPPING_BUCKETS

#define MAPPING_BUCKETS   511

Definition at line 958 of file app_voicemail.c.

Referenced by load_module().

◆ MAX_DATETIME_FORMAT

#define MAX_DATETIME_FORMAT   512

Definition at line 540 of file app_voicemail.c.

◆ MAX_MAIL_BODY_CONTENT_SIZE

#define MAX_MAIL_BODY_CONTENT_SIZE   134217728L

Definition at line 525 of file app_voicemail.c.

Referenced by vm_allocate_dh().

◆ MAX_NUM_CID_CONTEXTS

#define MAX_NUM_CID_CONTEXTS   10

Definition at line 541 of file app_voicemail.c.

Referenced by actual_load_config(), and play_message_callerid().

◆ MAX_VM_CONTEXT_LEN

#define MAX_VM_CONTEXT_LEN   (AST_MAX_CONTEXT)

Definition at line 741 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 743 of file app_voicemail.c.

Referenced by __has_voicemail(), append_mailbox(), and find_user().

◆ MAX_VM_MBOX_ID_LEN

#define MAX_VM_MBOX_ID_LEN   (AST_MAX_EXTENSION)

Definition at line 740 of file app_voicemail.c.

◆ MAXMSG

#define MAXMSG   100

Definition at line 527 of file app_voicemail.c.

Referenced by actual_load_config(), and apply_option().

◆ MAXMSGLIMIT

#define MAXMSGLIMIT   9999

Definition at line 528 of file app_voicemail.c.

Referenced by actual_load_config(), apply_option(), and last_message_index().

◆ MINPASSWORD

#define MINPASSWORD   0

Default minimum mailbox password length

Definition at line 530 of file app_voicemail.c.

Referenced by actual_load_config().

◆ MSG_ID_LEN

#define MSG_ID_LEN   256

◆ OPERATOR_EXIT

#define OPERATOR_EXIT   300

Definition at line 564 of file app_voicemail.c.

Referenced by leave_voicemail(), vm_exec(), and vm_execmain().

◆ PWDCHANGE_EXTERNAL

#define PWDCHANGE_EXTERNAL   (1 << 2)

Definition at line 878 of file app_voicemail.c.

Referenced by actual_load_config(), vm_newuser_setup(), and vm_options().

◆ PWDCHANGE_INTERNAL

#define PWDCHANGE_INTERNAL   (1 << 1)

Definition at line 877 of file app_voicemail.c.

Referenced by actual_load_config(), vm_newuser_setup(), and vm_options().

◆ RENAME

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

Definition at line 863 of file app_voicemail.c.

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

◆ RETRIEVE

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

◆ SENDMAIL

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

Definition at line 521 of file app_voicemail.c.

Referenced by actual_load_config().

◆ SMDI_MWI_WAIT_TIMEOUT

#define SMDI_MWI_WAIT_TIMEOUT   1000 /* 1 second */

Definition at line 498 of file app_voicemail.c.

Referenced by run_externnotify().

◆ STORE

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

◆ tdesc

#define tdesc   "Comedian Mail (Voicemail System)"

Definition at line 887 of file app_voicemail.c.

Referenced by vm_msg_play().

◆ UPDATE_MSG_ID

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

Definition at line 866 of file app_voicemail.c.

Referenced by add_message_id().

◆ VALID_DTMF

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

Definition at line 517 of file app_voicemail.c.

Referenced by is_valid_dtmf().

◆ VM_ALLOCED

#define VM_ALLOCED   (1 << 13)

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

Definition at line 556 of file app_voicemail.c.

Referenced by append_mailbox(), find_user(), find_user_realtime(), free_user(), free_vm_users(), and vm_allocate_dh().

◆ VM_ATTACH

#define VM_ATTACH   (1 << 11)

Attach message to voicemail notifications?

Definition at line 554 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), append_vmu_info_astman(), apply_option(), forward_message(), notify_new_message(), sendmail(), and vmsayname_exec().

◆ VM_DELETE

#define VM_DELETE   (1 << 12)

Delete message after sending notification

Definition at line 555 of file app_voicemail.c.

Referenced by append_mailbox(), append_vmu_info_astman(), apply_option(), and notify_new_message().

◆ VM_DIRECFORWARD

#define VM_DIRECFORWARD   (1 << 10)

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

Definition at line 553 of file app_voicemail.c.

Referenced by actual_load_config(), and forward_message().

◆ VM_ENVELOPE

#define VM_ENVELOPE   (1 << 4)

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

Definition at line 547 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), append_vmu_info_astman(), apply_option(), and play_message().

◆ VM_FORCEGREET

#define VM_FORCEGREET   (1 << 8)

Have new users record their greetings

Definition at line 551 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), vm_execmain(), and vm_newuser_setup().

◆ VM_FORCENAME

#define VM_FORCENAME   (1 << 7)

Have new users record their name

Definition at line 550 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), vm_execmain(), and vm_newuser_setup().

◆ VM_FWDURGAUTO

#define VM_FWDURGAUTO   (1 << 18)

Autoset of Urgent flag on forwarded Urgent messages set globally

Definition at line 561 of file app_voicemail.c.

Referenced by actual_load_config(), and forward_message().

◆ VM_MESSAGEWRAP

#define VM_MESSAGEWRAP   (1 << 17)

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

Definition at line 560 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), vm_execmain(), vm_instructions_en(), and vm_instructions_ja().

◆ VM_MOVEHEARD

#define VM_MOVEHEARD   (1 << 16)

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

Definition at line 559 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), and close_mailbox().

◆ VM_OPERATOR

#define VM_OPERATOR   (1 << 1)

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

Definition at line 544 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), append_vmu_info_astman(), apply_option(), leave_voicemail(), and play_record_review().

◆ VM_PBXSKIP

#define VM_PBXSKIP   (1 << 9)

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

Definition at line 552 of file app_voicemail.c.

Referenced by actual_load_config(), and make_email_file().

◆ VM_REVIEW

#define VM_REVIEW   (1 << 0)

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

Definition at line 543 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), append_vmu_info_astman(), apply_option(), and play_record_review().

◆ VM_SAYCID

#define VM_SAYCID   (1 << 2)

Repeat the CallerID info during envelope playback

Definition at line 545 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), append_vmu_info_astman(), apply_option(), and play_message().

◆ VM_SAYDURATION

#define VM_SAYDURATION   (1 << 5)

Play the length of the message during envelope playback

Definition at line 548 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), and play_message().

◆ VM_SEARCH

#define VM_SEARCH   (1 << 14)

Search all contexts for a matching mailbox

Definition at line 557 of file app_voicemail.c.

Referenced by actual_load_config(), find_or_create(), find_user(), and find_user_realtime().

◆ VM_SKIPAFTERCMD

#define VM_SKIPAFTERCMD   (1 << 6)

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

Definition at line 549 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), and vm_execmain().

◆ VM_SVMAIL

#define VM_SVMAIL   (1 << 3)

Allow the user to compose a new VM from within VoicemailMain

Definition at line 546 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), and vm_execmain().

◆ VM_TEMPGREETWARN

#define VM_TEMPGREETWARN   (1 << 15)

Remind user tempgreeting is set

Definition at line 558 of file app_voicemail.c.

Referenced by actual_load_config(), append_mailbox(), apply_option(), and vm_intro().

◆ VMSTATE_MAX_MSG_ARRAY

#define VMSTATE_MAX_MSG_ARRAY   256

Definition at line 795 of file app_voicemail.c.

Referenced by vm_allocate_dh().

◆ VOICEMAIL_CONFIG

#define VOICEMAIL_CONFIG   "voicemail.conf"

Definition at line 506 of file app_voicemail.c.

Referenced by load_config(), and vm_change_password().

◆ VOICEMAIL_DIR_MODE

#define VOICEMAIL_DIR_MODE   0777

Definition at line 502 of file app_voicemail.c.

Referenced by create_dirpath(), leave_voicemail(), and msg_create_from_file().

◆ VOICEMAIL_FILE_MODE

#define VOICEMAIL_FILE_MODE   0666

Definition at line 503 of file app_voicemail.c.

Referenced by copy(), leave_voicemail(), msg_create_from_file(), and vm_mkftemp().

Enumeration Type Documentation

◆ vm_box

enum vm_box
Enumerator
NEW_FOLDER 
OLD_FOLDER 
WORK_FOLDER 
FAMILY_FOLDER 
FRIENDS_FOLDER 
GREETINGS_FOLDER 

Definition at line 566 of file app_voicemail.c.

◆ vm_option_args

Enumerator
OPT_ARG_RECORDGAIN 
OPT_ARG_PLAYFOLDER 
OPT_ARG_DTMFEXIT 
OPT_ARG_ARRAY_SIZE 

Definition at line 588 of file app_voicemail.c.

588  {
589  OPT_ARG_RECORDGAIN = 0,
590  OPT_ARG_PLAYFOLDER = 1,
591  OPT_ARG_DTMFEXIT = 2,
592  /* This *must* be the last value in this enum! */
593  OPT_ARG_ARRAY_SIZE = 3,
594 };

◆ 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 

Definition at line 575 of file app_voicemail.c.

◆ vm_passwordlocation

Enumerator
OPT_PWLOC_VOICEMAILCONF 
OPT_PWLOC_SPOOLDIR 
OPT_PWLOC_USERSCONF 

Definition at line 596 of file app_voicemail.c.

Function Documentation

◆ __has_voicemail()

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

Definition at line 6053 of file app_voicemail.c.

References ao2_find, ao2_ref, ast_strdupa, ast_strlen_zero, c, alias_mailbox_mapping::mailbox, MAX_VM_MAILBOX_LEN, OBJ_SEARCH_KEY, and separate_mailbox().

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

6054 {
6055  DIR *dir;
6056  struct dirent *de;
6057  char fn[256];
6058  int ret = 0;
6059  struct alias_mailbox_mapping *mapping;
6060  char *c;
6061  char *m;
6062 
6063  /* If no mailbox, return immediately */
6064  if (ast_strlen_zero(mailbox))
6065  return 0;
6066 
6067  if (ast_strlen_zero(folder))
6068  folder = "INBOX";
6069  if (ast_strlen_zero(context))
6070  context = "default";
6071 
6072  c = (char *)context;
6073  m = (char *)mailbox;
6074 
6076  char tmp[MAX_VM_MAILBOX_LEN];
6077 
6078  snprintf(tmp, MAX_VM_MAILBOX_LEN, "%s@%s", mailbox, context);
6080  if (mapping) {
6081  separate_mailbox(ast_strdupa(mapping->mailbox), &m, &c);
6082  ao2_ref(mapping, -1);
6083  }
6084  }
6085 
6086  snprintf(fn, sizeof(fn), "%s%s/%s/%s", VM_SPOOL_DIR, c, m, folder);
6087 
6088  if (!(dir = opendir(fn)))
6089  return 0;
6090 
6091  while ((de = readdir(dir))) {
6092  if (!strncasecmp(de->d_name, "msg", 3)) {
6093  if (shortcircuit) {
6094  ret = 1;
6095  break;
6096  } else if (!strncasecmp(de->d_name + 8, "txt", 3)) {
6097  ret++;
6098  }
6099  }
6100  }
6101 
6102  closedir(dir);
6103 
6104  return ret;
6105 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1105
static struct ao2_container * alias_mailbox_mappings
static int tmp()
Definition: bt_open.c:389
static struct test_val c
static char aliasescontext[MAX_VM_CONTEXT_LEN]
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static char VM_SPOOL_DIR[PATH_MAX]
#define ast_strlen_zero(a)
Definition: muted.c:73
static int separate_mailbox(char *mailbox_id, char **mailbox, char **context)
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
#define MAX_VM_MAILBOX_LEN

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 16592 of file app_voicemail.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 16592 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 12661 of file app_voicemail.c.

References 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, context, ast_vm_user::email, find_user(), free_user(), ast_vm_user::fullname, ast_vm_user::language, 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.

Referenced by vmsayname_exec().

12662 {
12663  struct ast_vm_user svm;
12664  struct ast_vm_user *vmu = NULL;
12665  char *parse;
12666  char *mailbox;
12667  char *context;
12668  int res = 0;
12669 
12671  AST_APP_ARG(mailbox_context);
12672  AST_APP_ARG(attribute);
12673  AST_APP_ARG(folder);
12674  );
12675 
12676  buf[0] = '\0';
12677 
12678  if (ast_strlen_zero(args)) {
12679  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12680  return -1;
12681  }
12682 
12683  parse = ast_strdupa(args);
12684  AST_STANDARD_APP_ARGS(arg, parse);
12685 
12686  if (ast_strlen_zero(arg.mailbox_context)
12687  || ast_strlen_zero(arg.attribute)
12688  || separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
12689  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12690  return -1;
12691  }
12692 
12693  memset(&svm, 0, sizeof(svm));
12694  vmu = find_user(&svm, context, mailbox);
12695 
12696  if (!strncasecmp(arg.attribute, "exists", 5)) {
12697  ast_copy_string(buf, vmu ? "1" : "0", len);
12698  free_user(vmu);
12699  return 0;
12700  }
12701 
12702  if (vmu) {
12703  if (!strncasecmp(arg.attribute, "password", 8)) {
12704  ast_copy_string(buf, vmu->password, len);
12705  } else if (!strncasecmp(arg.attribute, "fullname", 8)) {
12706  ast_copy_string(buf, vmu->fullname, len);
12707  } else if (!strncasecmp(arg.attribute, "email", 5)) {
12708  ast_copy_string(buf, vmu->email, len);
12709  } else if (!strncasecmp(arg.attribute, "pager", 5)) {
12710  ast_copy_string(buf, vmu->pager, len);
12711  } else if (!strncasecmp(arg.attribute, "language", 8)) {
12713  } else if (!strncasecmp(arg.attribute, "locale", 6)) {
12714  ast_copy_string(buf, vmu->locale, len);
12715  } else if (!strncasecmp(arg.attribute, "tz", 2)) {
12716  ast_copy_string(buf, vmu->zonetag, len);
12717  } else if (!strncasecmp(arg.attribute, "count", 5)) {
12718  char *mailbox_id;
12719 
12720  mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
12721  sprintf(mailbox_id, "%s@%s", mailbox, context);/* Safe */
12722 
12723  /* If mbxfolder is empty messagecount will default to INBOX */
12724  res = messagecount(mailbox_id, arg.folder);
12725  if (res < 0) {
12726  ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
12727  free_user(vmu);
12728  return -1;
12729  }
12730  snprintf(buf, len, "%d", res);
12731  } else {
12732  ast_log(LOG_ERROR, "Unknown attribute '%s' for VM_INFO\n", arg.attribute);
12733  free_user(vmu);
12734  return -1;
12735  }
12736  free_user(vmu);
12737  }
12738 
12739  return 0;
12740 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
static int messagecount(const char *mailbox_id, const char *folder)
char pager[80]
const char * args
char password[80]
#define NULL
Definition: resample.c:96
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define ast_log
Definition: astobj2.c:42
char locale[20]
char zonetag[80]
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static void free_user(struct ast_vm_user *vmu)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
#define LOG_ERROR
Definition: logger.h:285
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_strlen_zero(a)
Definition: muted.c:73
static struct ast_vm_user * find_user(struct ast_vm_user *ivm, const char *context, const char *mailbox)
Finds a voicemail user from the users file or the realtime engine.
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
static int separate_mailbox(char *mailbox_id, char **mailbox, char **context)
char language[MAX_LANGUAGE]
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const char * ast_channel_language(const struct ast_channel *chan)
char fullname[80]
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ actual_load_config()

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

Definition at line 13662 of file app_voicemail.c.

References 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, ast_vm_user::context, DEFAULT_LISTEN_CONTROL_FORWARD_KEY, DEFAULT_LISTEN_CONTROL_PAUSE_KEY, DEFAULT_LISTEN_CONTROL_RESTART_KEY, DEFAULT_LISTEN_CONTROL_REVERSE_KEY, DEFAULT_LISTEN_CONTROL_STOP_KEY, DEFAULT_POLL_FREQ, find_or_create(), free_vm_users(), free_vm_zones(), is_valid_dtmf(), load_aliases(), load_users(), load_zonemessages(), LOG_ERROR, ast_vm_user::mailbox, MAX_NUM_CID_CONTEXTS, MAXMSG, MAXMSGLIMIT, MINPASSWORD, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, OPT_PWLOC_SPOOLDIR, OPT_PWLOC_USERSCONF, OPT_PWLOC_VOICEMAILCONF, ast_vm_user::password, ast_vm_user::passwordlocation, PATH_MAX, populate_defaults(), PWDCHANGE_EXTERNAL, PWDCHANGE_INTERNAL, read_password_from_file(), S_OR, SENDMAIL, start_poll_thread(), stop_poll_thread(), strsep(), substitute_escapes(), THRESHOLD_SILENCE, tmp(), VM_ATTACH, VM_DIRECFORWARD, VM_ENVELOPE, VM_FORCEGREET, VM_FORCENAME, VM_FWDURGAUTO, VM_MESSAGEWRAP, VM_MOVEHEARD, VM_OPERATOR, VM_PBXSKIP, VM_REVIEW, VM_SAYCID, VM_SAYDURATION, VM_SEARCH, VM_SKIPAFTERCMD, VM_SVMAIL, and VM_TEMPGREETWARN.

Referenced by load_config().

13663 {
13664  struct ast_vm_user *current;
13665  char *cat;
13666  const char *val;
13667  char *q, *stringp, *tmp;
13668  int x;
13669  unsigned int tmpadsi[4];
13670  char secretfn[PATH_MAX] = "";
13671  long tps_queue_low;
13672  long tps_queue_high;
13673 
13674 #ifdef IMAP_STORAGE
13675  ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
13676 #endif
13677  /* set audio control prompts */
13683 
13684 #ifdef IMAP_STORAGE
13685  ast_mwi_state_callback_all(imap_close_subscribed_mailbox, NULL);
13686 #endif
13687 
13688  /* Free all the users structure */
13689  free_vm_users();
13690 
13691  /* Free all the zones structure */
13692  free_vm_zones();
13693 
13694  /* Remove all aliases */
13697 
13698  AST_LIST_LOCK(&users);
13699 
13700  memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
13701  memset(ext_pass_check_cmd, 0, sizeof(ext_pass_check_cmd));
13702 
13703  if (cfg) {
13704  /* General settings */
13705 
13706  if (!(val = ast_variable_retrieve(cfg, "general", "userscontext")))
13707  val = "default";
13708  ast_copy_string(userscontext, val, sizeof(userscontext));
13709 
13710  aliasescontext[0] = '\0';
13711  val = ast_variable_retrieve(cfg, "general", "aliasescontext");
13712  ast_copy_string(aliasescontext, S_OR(val, ""), sizeof(aliasescontext));
13713 
13714  /* Attach voice message to mail message ? */
13715  if (!(val = ast_variable_retrieve(cfg, "general", "attach")))
13716  val = "yes";
13718 
13719  if (!(val = ast_variable_retrieve(cfg, "general", "searchcontexts")))
13720  val = "no";
13722 
13723  volgain = 0.0;
13724  if ((val = ast_variable_retrieve(cfg, "general", "volgain")))
13725  sscanf(val, "%30lf", &volgain);
13726 
13727 #ifdef ODBC_STORAGE
13728  strcpy(odbc_database, "asterisk");
13729  if ((val = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
13730  ast_copy_string(odbc_database, val, sizeof(odbc_database));
13731  }
13732  strcpy(odbc_table, "voicemessages");
13733  if ((val = ast_variable_retrieve(cfg, "general", "odbctable"))) {
13734  ast_copy_string(odbc_table, val, sizeof(odbc_table));
13735  }
13736 #endif
13737  /* Mail command */
13738  strcpy(mailcmd, SENDMAIL);
13739  if ((val = ast_variable_retrieve(cfg, "general", "mailcmd")))
13740  ast_copy_string(mailcmd, val, sizeof(mailcmd)); /* User setting */
13741 
13742  maxsilence = 0;
13743  if ((val = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
13744  maxsilence = atoi(val);
13745  if (maxsilence > 0)
13746  maxsilence *= 1000;
13747  }
13748 
13749  if (!(val = ast_variable_retrieve(cfg, "general", "maxmsg"))) {
13750  maxmsg = MAXMSG;
13751  } else {
13752  maxmsg = atoi(val);
13753  if (maxmsg < 0) {
13754  ast_log(AST_LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", val, MAXMSG);
13755  maxmsg = MAXMSG;
13756  } else if (maxmsg > MAXMSGLIMIT) {
13757  ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
13758  maxmsg = MAXMSGLIMIT;
13759  }
13760  }
13761 
13762  if (!(val = ast_variable_retrieve(cfg, "general", "backupdeleted"))) {
13763  maxdeletedmsg = 0;
13764  } else {
13765  if (sscanf(val, "%30d", &x) == 1)
13766  maxdeletedmsg = x;
13767  else if (ast_true(val))
13769  else
13770  maxdeletedmsg = 0;
13771 
13772  if (maxdeletedmsg < 0) {
13773  ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox '%s'. Using default value %i\n", val, MAXMSG);
13775  } else if (maxdeletedmsg > MAXMSGLIMIT) {
13776  ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
13778  }
13779  }
13780 
13781  /* Load date format config for voicemail mail */
13782  if ((val = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
13784  }
13785 
13786  /* Load date format config for voicemail pager mail */
13787  if ((val = ast_variable_retrieve(cfg, "general", "pagerdateformat"))) {
13789  }
13790 
13791  /* External password changing command */
13792  if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) {
13793  ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd));
13795  } else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) {
13796  ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd));
13798  }
13799 
13800  /* External password validation command */
13801  if ((val = ast_variable_retrieve(cfg, "general", "externpasscheck"))) {
13803  ast_debug(1, "found externpasscheck: %s\n", ext_pass_check_cmd);
13804  }
13805 
13806 #ifdef IMAP_STORAGE
13807  /* IMAP server address */
13808  if ((val = ast_variable_retrieve(cfg, "general", "imapserver"))) {
13809  ast_copy_string(imapserver, val, sizeof(imapserver));
13810  } else {
13811  ast_copy_string(imapserver, "localhost", sizeof(imapserver));
13812  }
13813  /* IMAP server port */
13814  if ((val = ast_variable_retrieve(cfg, "general", "imapport"))) {
13815  ast_copy_string(imapport, val, sizeof(imapport));
13816  } else {
13817  ast_copy_string(imapport, "143", sizeof(imapport));
13818  }
13819  /* IMAP server flags */
13820  if ((val = ast_variable_retrieve(cfg, "general", "imapflags"))) {
13821  ast_copy_string(imapflags, val, sizeof(imapflags));
13822  }
13823  /* IMAP server master username */
13824  if ((val = ast_variable_retrieve(cfg, "general", "authuser"))) {
13825  ast_copy_string(authuser, val, sizeof(authuser));
13826  }
13827  /* IMAP server master password */
13828  if ((val = ast_variable_retrieve(cfg, "general", "authpassword"))) {
13829  ast_copy_string(authpassword, val, sizeof(authpassword));
13830  }
13831  /* Expunge on exit */
13832  if ((val = ast_variable_retrieve(cfg, "general", "expungeonhangup"))) {
13833  if (ast_false(val))
13834  expungeonhangup = 0;
13835  else
13836  expungeonhangup = 1;
13837  } else {
13838  expungeonhangup = 1;
13839  }
13840  /* IMAP voicemail folder */
13841  if ((val = ast_variable_retrieve(cfg, "general", "imapfolder"))) {
13842  ast_copy_string(imapfolder, val, sizeof(imapfolder));
13843  } else {
13844  ast_copy_string(imapfolder, "INBOX", sizeof(imapfolder));
13845  }
13846  if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) {
13847  ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder));
13848  }
13849  if ((val = ast_variable_retrieve(cfg, "general", "imapgreetings"))) {
13850  imapgreetings = ast_true(val);
13851  } else {
13852  imapgreetings = 0;
13853  }
13854  if ((val = ast_variable_retrieve(cfg, "general", "greetingfolder"))) {
13855  ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
13856  } else if ((val = ast_variable_retrieve(cfg, "general", "greetingsfolder"))) {
13857  /* Also support greetingsfolder as documented in voicemail.conf.sample */
13858  ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
13859  } else {
13860  ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder));
13861  }
13862  if ((val = ast_variable_retrieve(cfg, "general", "imap_poll_logout"))) {
13863  imap_poll_logout = ast_true(val);
13864  } else {
13865  imap_poll_logout = 0;
13866  }
13867 
13868  /* There is some very unorthodox casting done here. This is due
13869  * to the way c-client handles the argument passed in. It expects a
13870  * void pointer and casts the pointer directly to a long without
13871  * first dereferencing it. */
13872  if ((val = ast_variable_retrieve(cfg, "general", "imapreadtimeout"))) {
13873  mail_parameters(NIL, SET_READTIMEOUT, (void *) (atol(val)));
13874  } else {
13875  mail_parameters(NIL, SET_READTIMEOUT, (void *) 60L);
13876  }
13877 
13878  if ((val = ast_variable_retrieve(cfg, "general", "imapwritetimeout"))) {
13879  mail_parameters(NIL, SET_WRITETIMEOUT, (void *) (atol(val)));
13880  } else {
13881  mail_parameters(NIL, SET_WRITETIMEOUT, (void *) 60L);
13882  }
13883 
13884  if ((val = ast_variable_retrieve(cfg, "general", "imapopentimeout"))) {
13885  mail_parameters(NIL, SET_OPENTIMEOUT, (void *) (atol(val)));
13886  } else {
13887  mail_parameters(NIL, SET_OPENTIMEOUT, (void *) 60L);
13888  }
13889 
13890  if ((val = ast_variable_retrieve(cfg, "general", "imapclosetimeout"))) {
13891  mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) (atol(val)));
13892  } else {
13893  mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L);
13894  }
13895 
13896  /* Increment configuration version */
13897  imapversion++;
13898 #endif
13899  /* External voicemail notify application */
13900  if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
13901  ast_copy_string(externnotify, val, sizeof(externnotify));
13902  ast_debug(1, "found externnotify: %s\n", externnotify);
13903  } else {
13904  externnotify[0] = '\0';
13905  }
13906 
13907  /* SMDI voicemail notification */
13908  if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
13909  ast_debug(1, "Enabled SMDI voicemail notification\n");
13910  if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
13912  } else {
13913  ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
13914  smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
13915  }
13916  if (!smdi_iface) {
13917  ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
13918  }
13919  }
13920 
13921  /* Silence treshold */
13923  if ((val = ast_variable_retrieve(cfg, "general", "silencethreshold")))
13924  silencethreshold = atoi(val);
13925 
13926  if (!(val = ast_variable_retrieve(cfg, "general", "serveremail")))
13927  val = ASTERISK_USERNAME;
13928  ast_copy_string(serveremail, val, sizeof(serveremail));
13929 
13930  vmmaxsecs = 0;
13931  if ((val = ast_variable_retrieve(cfg, "general", "maxsecs"))) {
13932  if (sscanf(val, "%30d", &x) == 1) {
13933  vmmaxsecs = x;
13934  } else {
13935  ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
13936  }
13937  } else if ((val = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
13938  static int maxmessage_deprecate = 0;
13939  if (maxmessage_deprecate == 0) {
13940  maxmessage_deprecate = 1;
13941  ast_log(AST_LOG_WARNING, "Setting 'maxmessage' has been deprecated in favor of 'maxsecs'.\n");
13942  }
13943  if (sscanf(val, "%30d", &x) == 1) {
13944  vmmaxsecs = x;
13945  } else {
13946  ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
13947  }
13948  }
13949 
13950  vmminsecs = 0;
13951  if ((val = ast_variable_retrieve(cfg, "general", "minsecs"))) {
13952  if (sscanf(val, "%30d", &x) == 1) {
13953  vmminsecs = x;
13954  if (maxsilence / 1000 >= vmminsecs) {
13955  ast_log(AST_LOG_WARNING, "maxsilence should be less than minsecs or you may get empty messages\n");
13956  }
13957  } else {
13958  ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
13959  }
13960  } else if ((val = ast_variable_retrieve(cfg, "general", "minmessage"))) {
13961  static int maxmessage_deprecate = 0;
13962  if (maxmessage_deprecate == 0) {
13963  maxmessage_deprecate = 1;
13964  ast_log(AST_LOG_WARNING, "Setting 'minmessage' has been deprecated in favor of 'minsecs'.\n");
13965  }
13966  if (sscanf(val, "%30d", &x) == 1) {
13967  vmminsecs = x;
13968  if (maxsilence / 1000 >= vmminsecs) {
13969  ast_log(AST_LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
13970  }
13971  } else {
13972  ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
13973  }
13974  }
13975 
13976  val = ast_variable_retrieve(cfg, "general", "format");
13977  if (!val) {
13978  val = "wav";
13979  } else {
13980  tmp = ast_strdupa(val);
13981  val = ast_format_str_reduce(tmp);
13982  if (!val) {
13983  ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n");
13984  val = "wav";
13985  }
13986  }
13987  ast_copy_string(vmfmts, val, sizeof(vmfmts));
13988 
13989  skipms = 3000;
13990  if ((val = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
13991  if (sscanf(val, "%30d", &x) == 1) {
13992  maxgreet = x;
13993  } else {
13994  ast_log(AST_LOG_WARNING, "Invalid max message greeting length\n");
13995  }
13996  }
13997 
13998  if ((val = ast_variable_retrieve(cfg, "general", "skipms"))) {
13999  if (sscanf(val, "%30d", &x) == 1) {
14000  skipms = x;
14001  } else {
14002  ast_log(AST_LOG_WARNING, "Invalid skipms value\n");
14003  }
14004  }
14005 
14006  maxlogins = 3;
14007  if ((val = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
14008  if (sscanf(val, "%30d", &x) == 1) {
14009  maxlogins = x;
14010  } else {
14011  ast_log(AST_LOG_WARNING, "Invalid max failed login attempts\n");
14012  }
14013  }
14014 
14016  if ((val = ast_variable_retrieve(cfg, "general", "minpassword"))) {
14017  if (sscanf(val, "%30d", &x) == 1) {
14018  minpassword = x;
14019  } else {
14020  ast_log(AST_LOG_WARNING, "Invalid minimum password length. Default to %d\n", minpassword);
14021  }
14022  }
14023 
14024  /* Force new user to record name ? */
14025  if (!(val = ast_variable_retrieve(cfg, "general", "forcename")))
14026  val = "no";
14028 
14029  /* Force new user to record greetings ? */
14030  if (!(val = ast_variable_retrieve(cfg, "general", "forcegreetings")))
14031  val = "no";
14033 
14034  if ((val = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) {
14035  ast_debug(1, "VM_CID Internal context string: %s\n", val);
14036  stringp = ast_strdupa(val);
14037  for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
14038  if (!ast_strlen_zero(stringp)) {
14039  q = strsep(&stringp, ",");
14040  while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
14041  q++;
14043  ast_debug(1, "VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
14044  } else {
14045  cidinternalcontexts[x][0] = '\0';
14046  }
14047  }
14048  }
14049  if (!(val = ast_variable_retrieve(cfg, "general", "review"))){
14050  ast_debug(1, "VM Review Option disabled globally\n");
14051  val = "no";
14052  }
14054 
14055  /* Temporary greeting reminder */
14056  if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
14057  ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n");
14058  val = "no";
14059  } else {
14060  ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n");
14061  }
14063  if (!(val = ast_variable_retrieve(cfg, "general", "messagewrap"))){
14064  ast_debug(1, "VM next message wrap disabled globally\n");
14065  val = "no";
14066  }
14068 
14069  if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){
14070  ast_debug(1, "VM Operator break disabled globally\n");
14071  val = "no";
14072  }
14074 
14075  if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) {
14076  ast_debug(1, "VM CID Info before msg disabled globally\n");
14077  val = "no";
14078  }
14080 
14081  if (!(val = ast_variable_retrieve(cfg, "general", "sendvoicemail"))){
14082  ast_debug(1, "Send Voicemail msg disabled globally\n");
14083  val = "no";
14084  }
14086 
14087  if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) {
14088  ast_debug(1, "ENVELOPE before msg enabled globally\n");
14089  val = "yes";
14090  }
14092 
14093  if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) {
14094  ast_debug(1, "Move Heard enabled globally\n");
14095  val = "yes";
14096  }
14098 
14099  if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) {
14100  ast_debug(1, "Autoset of Urgent flag on forwarded Urgent messages disabled globally\n");
14101  val = "no";
14102  }
14104 
14105  if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
14106  ast_debug(1, "Duration info before msg enabled globally\n");
14107  val = "yes";
14108  }
14110 
14111  saydurationminfo = 2;
14112  if ((val = ast_variable_retrieve(cfg, "general", "saydurationm"))) {
14113  if (sscanf(val, "%30d", &x) == 1) {
14114  saydurationminfo = x;
14115  } else {
14116  ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
14117  }
14118  }
14119 
14120  if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
14121  ast_debug(1, "We are not going to skip to the next msg after save/delete\n");
14122  val = "no";
14123  }
14125 
14126  if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) {
14127  ast_copy_string(dialcontext, val, sizeof(dialcontext));
14128  ast_debug(1, "found dialout context: %s\n", dialcontext);
14129  } else {
14130  dialcontext[0] = '\0';
14131  }
14132 
14133  if ((val = ast_variable_retrieve(cfg, "general", "callback"))) {
14134  ast_copy_string(callcontext, val, sizeof(callcontext));
14135  ast_debug(1, "found callback context: %s\n", callcontext);
14136  } else {
14137  callcontext[0] = '\0';
14138  }
14139 
14140  if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
14141  ast_copy_string(exitcontext, val, sizeof(exitcontext));
14142  ast_debug(1, "found operator context: %s\n", exitcontext);
14143  } else {
14144  exitcontext[0] = '\0';
14145  }
14146 
14147  /* load password sounds configuration */
14148  if ((val = ast_variable_retrieve(cfg, "general", "vm-login")))
14149  ast_copy_string(vm_login, val, sizeof(vm_login));
14150  if ((val = ast_variable_retrieve(cfg, "general", "vm-newuser")))
14151  ast_copy_string(vm_newuser, val, sizeof(vm_newuser));
14152  if ((val = ast_variable_retrieve(cfg, "general", "vm-password")))
14153  ast_copy_string(vm_password, val, sizeof(vm_password));
14154  if ((val = ast_variable_retrieve(cfg, "general", "vm-newpassword")))
14156  if ((val = ast_variable_retrieve(cfg, "general", "vm-invalid-password")))
14158  if ((val = ast_variable_retrieve(cfg, "general", "vm-passchanged")))
14160  if ((val = ast_variable_retrieve(cfg, "general", "vm-reenterpassword")))
14162  if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
14163  ast_copy_string(vm_mismatch, val, sizeof(vm_mismatch));
14164  if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
14166  }
14167  if ((val = ast_variable_retrieve(cfg, "general", "vm-prepend-timeout"))) {
14169  }
14170  /* load configurable audio prompts */
14171  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
14173  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val))
14175  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val))
14177  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val))
14179  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val))
14181 
14182  if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory")))
14183  val = "no";
14185 
14186  if (!(val = ast_variable_retrieve(cfg, "general", "passwordlocation"))) {
14187  val = "voicemail.conf";
14188  }
14189  if (!(strcmp(val, "spooldir"))) {
14191  } else {
14193  }
14194 
14196  if ((val = ast_variable_retrieve(cfg, "general", "pollfreq"))) {
14197  if (sscanf(val, "%30u", &poll_freq) != 1) {
14199  ast_log(AST_LOG_ERROR, "'%s' is not a valid value for the pollfreq option!\n", val);
14200  }
14201  }
14202 
14203  poll_mailboxes = 0;
14204  if ((val = ast_variable_retrieve(cfg, "general", "pollmailboxes")))
14205  poll_mailboxes = ast_true(val);
14206 
14207  memset(fromstring, 0, sizeof(fromstring));
14208  memset(pagerfromstring, 0, sizeof(pagerfromstring));
14209  strcpy(charset, "ISO-8859-1");
14210  if (emailbody) {
14212  emailbody = NULL;
14213  }
14214  if (emailsubject) {
14216  emailsubject = NULL;
14217  }
14218  if (pagerbody) {
14220  pagerbody = NULL;
14221  }
14222  if (pagersubject) {
14224  pagersubject = NULL;
14225  }
14226  if ((val = ast_variable_retrieve(cfg, "general", "pbxskip")))
14228  if ((val = ast_variable_retrieve(cfg, "general", "fromstring")))
14229  ast_copy_string(fromstring, val, sizeof(fromstring));
14230  if ((val = ast_variable_retrieve(cfg, "general", "pagerfromstring")))
14232  if ((val = ast_variable_retrieve(cfg, "general", "charset")))
14233  ast_copy_string(charset, val, sizeof(charset));
14234  if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
14235  sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14236  for (x = 0; x < 4; x++) {
14237  memcpy(&adsifdn[x], &tmpadsi[x], 1);
14238  }
14239  }
14240  if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) {
14241  sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14242  for (x = 0; x < 4; x++) {
14243  memcpy(&adsisec[x], &tmpadsi[x], 1);
14244  }
14245  }
14246  if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) {
14247  if (atoi(val)) {
14248  adsiver = atoi(val);
14249  }
14250  }
14251  if ((val = ast_variable_retrieve(cfg, "general", "tz"))) {
14252  ast_copy_string(zonetag, val, sizeof(zonetag));
14253  }
14254  if ((val = ast_variable_retrieve(cfg, "general", "locale"))) {
14255  ast_copy_string(locale, val, sizeof(locale));
14256  }
14257  if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) {
14259  }
14260  if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
14262  }
14263  if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
14265  }
14266  if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
14268  }
14269 
14270  tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14271  if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_high"))) {
14272  if (sscanf(val, "%30ld", &tps_queue_high) != 1 || tps_queue_high <= 0) {
14273  ast_log(AST_LOG_WARNING, "Invalid the taskprocessor high water alert trigger level '%s'\n", val);
14274  tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14275  }
14276  }
14277  tps_queue_low = -1;
14278  if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_low"))) {
14279  if (sscanf(val, "%30ld", &tps_queue_low) != 1 ||
14280  tps_queue_low < -1 || tps_queue_high < tps_queue_low) {
14281  ast_log(AST_LOG_WARNING, "Invalid the taskprocessor low water clear alert level '%s'\n", val);
14282  tps_queue_low = -1;
14283  }
14284  }
14285  if (ast_taskprocessor_alert_set_levels(mwi_subscription_tps, tps_queue_low, tps_queue_high)) {
14286  ast_log(AST_LOG_WARNING, "Failed to set alert levels for voicemail taskprocessor.\n");
14287  }
14288 
14289  /* load mailboxes from users.conf */
14290  if (ucfg) {
14291  for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
14292  if (!strcasecmp(cat, "general")) {
14293  continue;
14294  }
14295  if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
14296  continue;
14297  if ((current = find_or_create(userscontext, cat))) {
14298  populate_defaults(current);
14299  apply_options_full(current, ast_variable_browse(ucfg, cat));
14300  ast_copy_string(current->context, userscontext, sizeof(current->context));
14301  if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) {
14303  }
14304 
14305  switch (current->passwordlocation) {
14306  case OPT_PWLOC_SPOOLDIR:
14307  snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox);
14308  read_password_from_file(secretfn, current->password, sizeof(current->password));
14309  }
14310  }
14311  }
14312  }
14313 
14314  /* load mailboxes from voicemail.conf */
14315 
14316  /*
14317  * Aliases must be loaded before users or the aliases won't be notified
14318  * if there's existing voicemail in the user mailbox.
14319  */
14320  load_aliases(cfg);
14321 
14322  load_zonemessages(cfg);
14323 
14324  load_users(cfg);
14325 
14327 
14331  stop_poll_thread();;
14332 
14333  return 0;
14334  } else {
14336  ast_log(AST_LOG_WARNING, "Failed to load configuration file.\n");
14337  return 0;
14338  }
14339 }
#define VM_TEMPGREETWARN
static int saydurationminfo
static char userscontext[AST_MAX_EXTENSION]
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
static void free_vm_zones(void)
Free the zones structure.
static char ext_pass_cmd[128]
static const char * substitute_escapes(const char *value)
static int minpassword
static void apply_options_full(struct ast_vm_user *retval, struct ast_variable *var)
Loads the options specific to a voicemail user.
static char mailcmd[160]
#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY
#define MAX_NUM_CID_CONTEXTS
static char vm_newuser[80]
static unsigned char adsifdn[4]
Definition: ast_expr2.c:325
static void free_vm_users(void)
Free the users structure.
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
static char pagerdateformat[32]
static int adsiver
#define VM_SAYDURATION
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static int maxsilence
static struct ao2_container * alias_mailbox_mappings
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
Definition: taskprocessor.h:63
static int pwdchange
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
static int maxdeletedmsg
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
static int tmp()
Definition: bt_open.c:389
#define AST_LOG_WARNING
Definition: logger.h:279
static unsigned char adsisec[4]
#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY
#define VM_MESSAGEWRAP
static int maxgreet
static pthread_t poll_thread
static char listen_control_reverse_key[12]
#define VM_ATTACH
static char locale[20]
static char aliasescontext[MAX_VM_CONTEXT_LEN]
static void load_aliases(struct ast_config *cfg)
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
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.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3328
static char externnotify[160]
char password[80]
#define NULL
Definition: resample.c:96
static int vmminsecs
static char * emailsubject
list of users found in the config file
static struct ast_smdi_interface * smdi_iface
static char fromstring[100]
char context[MAX_VM_CONTEXT_LEN]
#define VM_SAYCID
#define VM_SVMAIL
static void load_users(struct ast_config *cfg)
static char * emailbody
#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY
static char pagerfromstring[100]
static char * pagerbody
#define VM_SEARCH
#define VM_ENVELOPE
static int passwordlocation
static char exitcontext[AST_MAX_CONTEXT]
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
#define ast_log
Definition: astobj2.c:42
#define MINPASSWORD
static void load_zonemessages(struct ast_config *cfg)
#define AST_LOG_ERROR
Definition: logger.h:290
#define MAXMSG
static char dialcontext[AST_MAX_CONTEXT]
#define VM_FORCENAME
static struct ast_flags globalflags
#define DEFAULT_LISTEN_CONTROL_STOP_KEY
#define AST_PTHREADT_NULL
Definition: lock.h:66
static int silencethreshold
int passwordlocation
static char vm_reenterpassword[80]
static char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64]
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define VM_MOVEHEARD
char * ast_format_str_reduce(char *fmts)
Definition: file.c:1825
static char zonetag[80]
static double volgain
static char VM_SPOOL_DIR[PATH_MAX]
#define PWDCHANGE_INTERNAL
static char vm_mismatch[80]
static char vm_pls_try_again[80]
static struct ast_taskprocessor * mwi_subscription_tps
static char vm_invalid_password[80]
#define DEFAULT_POLL_FREQ
#define VM_PBXSKIP
#define VM_OPERATOR
static char callcontext[AST_MAX_CONTEXT]
static int skipms
#define LOG_ERROR
Definition: logger.h:285
static char ext_pass_check_cmd[128]
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1822
static unsigned int poll_mailboxes
static char listen_control_restart_key[12]
#define VM_REVIEW
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_free(a)
Definition: astmm.h:182
static char emaildateformat[32]
void ast_mwi_state_callback_all(on_mwi_state handler, void *data)
For each managed mailbox call the given handler.
Definition: mwi.c:333
static char vm_passchanged[80]
static int maxlogins
static char listen_control_pause_key[12]
charset
Definition: chan_unistim.c:336
#define SENDMAIL
static struct ao2_container * mailbox_alias_mappings
static char listen_control_forward_key[12]
static void read_password_from_file(const char *secretfn, char *password, int passwordlen)
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:694
char * strsep(char **str, const char *delims)
static int vmmaxsecs
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static void start_poll_thread(void)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static struct ast_vm_user * find_or_create(const char *context, const char *box)
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:1839
#define VM_SKIPAFTERCMD
static char * pagersubject
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:684
#define MAXMSGLIMIT
static char vm_password[80]
#define ASTERISK_USERNAME
#define VM_DIRECFORWARD
#define PWDCHANGE_EXTERNAL
static int is_valid_dtmf(const char *key)
Determines if a DTMF key entered is valid.
#define PATH_MAX
Definition: asterisk.h:40
#define VM_FWDURGAUTO
static char vm_login[80]
static int maxmsg
static char vm_newpassword[80]
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Definition: dsp.c:1959
static char vmfmts[80]
char mailbox[MAX_VM_MBOX_ID_LEN]
static char serveremail[80]
static char listen_control_stop_key[12]
#define VM_FORCEGREET
#define DEFAULT_LISTEN_CONTROL_RESTART_KEY
static unsigned int poll_freq
static void stop_poll_thread(void)
static void populate_defaults(struct ast_vm_user *vmu)
Sets default voicemail system options to a voicemail user.
static char vm_prepend_timeout[80]

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

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

Referenced by make_email_file().

5377 {
5378  char fname[PATH_MAX] = "";
5379  char sox_gain_tmpdir[PATH_MAX];
5380  char *file_to_delete = NULL, *dir_to_delete = NULL;
5381  int res;
5382  char altfname[PATH_MAX] = "";
5383  int altused = 0;
5384  char altformat[80] = "";
5385  char *c = NULL;
5386 
5387  /* Eww. We want formats to tell us their own MIME type */
5388  char *mime_type = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
5389 
5390  /* Users of multiple file formats need special attention. */
5391  snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5392  if (!ast_file_is_readable(fname)) {
5393  ast_copy_string(altformat, vmfmts, sizeof(altformat));
5394  c = strchr(altformat, '|');
5395  if (c) {
5396  *c = '\0';
5397  }
5398  ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - trying first/alternate format %s\n", fname, strerror(errno), altformat);
5399  snprintf(altfname, sizeof(altfname), "%s.%s", attach, altformat);
5400  if (!ast_file_is_readable(altfname)) {
5401  ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - alternate format %s failure\n", altfname, strerror(errno), altformat);
5402  } else {
5403  altused = 1;
5404  }
5405  }
5406 
5407  /* This 'while' loop will only execute once. We use it so that we can 'break' */
5408  while (vmu->volgain < -.001 || vmu->volgain > .001 || altused) {
5409  char tmpdir[PATH_MAX];
5410 
5411  create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
5412 
5413  res = snprintf(sox_gain_tmpdir, sizeof(sox_gain_tmpdir), "%s/vm-gain-XXXXXX", tmpdir);
5414  if (res >= sizeof(sox_gain_tmpdir)) {
5415  ast_log(LOG_ERROR, "Failed to create temporary directory path %s: Out of buffer space\n", tmpdir);
5416  break;
5417  }
5418 
5419  if (mkdtemp(sox_gain_tmpdir)) {
5420  int soxstatus = 0;
5421  char sox_gain_cmd[PATH_MAX];
5422 
5423  ast_debug(3, "sox_gain_tmpdir: %s\n", sox_gain_tmpdir);
5424 
5425  /* Save for later */
5426  dir_to_delete = sox_gain_tmpdir;
5427 
5428  res = snprintf(fname, sizeof(fname), "%s/output.%s", sox_gain_tmpdir, format);
5429  if (res >= sizeof(fname)) {
5430  ast_log(LOG_ERROR, "Failed to create filename buffer for %s/output.%s: Too long\n", sox_gain_tmpdir, format);
5431  break;
5432  }
5433 
5434  if (!altused) {
5435  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5436  vmu->volgain, attach, format, fname);
5437  } else {
5438  if (!strcasecmp(format, "wav")) {
5439  if (vmu->volgain < -.001 || vmu->volgain > .001) {
5440  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s -e signed-integer -b 16 %s",
5441  vmu->volgain, attach, altformat, fname);
5442  } else {
5443  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s -e signed-integer -b 16 %s",
5444  attach, altformat, fname);
5445  }
5446  } else {
5447  if (vmu->volgain < -.001 || vmu->volgain > .001) {
5448  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5449  vmu->volgain, attach, altformat, fname);
5450  } else {
5451  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s %s",
5452  attach, altformat, fname);
5453  }
5454  }
5455  }
5456 
5457  if (res >= sizeof(sox_gain_cmd)) {
5458  ast_log(LOG_ERROR, "Failed to generate sox command, out of buffer space\n");
5459  break;
5460  }
5461 
5462  soxstatus = ast_safe_system(sox_gain_cmd);
5463  if (!soxstatus) {
5464  /* Save for later */
5465  file_to_delete = fname;
5466  ast_debug(3, "VOLGAIN: Stored at: %s - Level: %.4f - Mailbox: %s\n", fname, vmu->volgain, mailbox);
5467  } else {
5468  ast_log(LOG_WARNING, "Sox failed to re-encode %s: %s (have you installed support for all sox file formats?)\n",
5469  fname,
5470  soxstatus == 1 ? "Problem with command line options" : "An error occurred during file processing");
5471  ast_log(LOG_WARNING, "Voicemail attachment will have no volume gain.\n");
5472  }
5473  }
5474 
5475  break;
5476  }
5477 
5478  if (!file_to_delete) {
5479  res = snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5480  if (res >= sizeof(fname)) {
5481  ast_log(LOG_ERROR, "Failed to create filename buffer for %s.%s: Too long\n", attach, format);
5482  return -1;
5483  }
5484  }
5485 
5486  fprintf(p, "--%s" ENDL, bound);
5487  if (msgnum > -1)
5488  fprintf(p, "Content-Type: %s%s; name=\"%s\"" ENDL, mime_type, format, filename);
5489  else
5490  fprintf(p, "Content-Type: %s%s; name=\"%s.%s\"" ENDL, mime_type, format, greeting_attachment, format);
5491  fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
5492  fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
5493  if (msgnum > -1)
5494  fprintf(p, "Content-Disposition: attachment; filename=\"%s\"" ENDL ENDL, filename);
5495  else
5496  fprintf(p, "Content-Disposition: attachment; filename=\"%s.%s\"" ENDL ENDL, greeting_attachment, format);
5497  base_encode(fname, p);
5498  if (last)
5499  fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound);
5500 
5501  if (file_to_delete) {
5502  unlink(file_to_delete);
5503  }
5504 
5505  if (dir_to_delete) {
5506  rmdir(dir_to_delete);
5507  }
5508 
5509  return 0;
5510 }
double volgain
static int create_dirpath(char *dest, int len, const char *context, const char *ext, const char *folder)
basically mkdir -p $dest/$context/$ext/$folder
#define LOG_WARNING
Definition: logger.h:274
int ast_file_is_readable(const char *filename)
Test that a file exists and is readable by the effective user.
Definition: main/utils.c:2726
#define AST_LOG_WARNING
Definition: logger.h:279
static struct test_val c
#define NULL
Definition: resample.c:96
char context[MAX_VM_CONTEXT_LEN]
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
#define ast_log
Definition: astobj2.c:42
struct sla_ringing_trunk * last
Definition: app_meetme.c:1092
#define ENDL
#define LOG_ERROR
Definition: logger.h:285
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)
int errno
static int base_encode(char *filename, FILE *so)
Performs a base 64 encode algorithm on the contents of a File.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define PATH_MAX
Definition: asterisk.h:40
static char vmfmts[80]
static snd_pcm_format_t format
Definition: chan_alsa.c:102
char mailbox[MAX_VM_MBOX_ID_LEN]

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

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

12339 {
12340  struct ast_variable *var;
12341  struct ast_category *cat;
12342  generate_msg_id(id);
12343 
12344  var = ast_variable_new("msg_id", id, "");
12345  if (!var) {
12346  return -1;
12347  }
12348 
12349  cat = ast_category_get(msg_cfg, "message", NULL);
12350  if (!cat) {
12351  ast_log(LOG_ERROR, "Voicemail data file %s/%d.txt has no [message] category?\n", dir, msg);
12352  ast_variables_destroy(var);
12353  return -1;
12354  }
12355 
12356  ast_variable_append(cat, var);
12357 
12358  if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
12359  ast_log(LOG_WARNING, "Unable to update %s to have a message ID\n", filename);
12360  return -1;
12361  }
12362 
12363  UPDATE_MSG_ID(dir, msg, id, vmu, msg_cfg, folder);
12364  return 0;
12365 }
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:2531
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
#define LOG_WARNING
Definition: logger.h:274
Structure for variables, used for configurations and for channel variables.
#define var
Definition: ast_expr2f.c:614
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
static void generate_msg_id(char *dst)
Sets the destination string to a uniquely identifying msg_id string.
#define ast_variable_new(name, value, filename)
#define LOG_ERROR
Definition: logger.h:285
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
Definition: extconf.c:1178
#define UPDATE_MSG_ID(a, b, c, d, e, f)
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:1022

◆ adsi_begin()

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

Definition at line 7436 of file app_voicemail.c.

References adsi_load_vmail(), ast_adsi_available(), ast_adsi_load_session(), ast_log, and AST_LOG_WARNING.

Referenced by vm_authenticate(), and vm_execmain().

7437 {
7438  int x;
7439  if (!ast_adsi_available(chan))
7440  return;
7441  x = ast_adsi_load_session(chan, adsifdn, adsiver, 1);
7442  if (x < 0)
7443  return;
7444  if (!x) {
7445  if (adsi_load_vmail(chan, useadsi)) {
7446  ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n");
7447  return;
7448  }
7449  } else
7450  *useadsi = 1;
7451 }
static unsigned char adsifdn[4]
static int adsiver
#define AST_LOG_WARNING
Definition: logger.h:279
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
#define ast_log
Definition: astobj2.c:42
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)

◆ adsi_delete()

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

Definition at line 7632 of file app_voicemail.c.

References ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_set_keys(), ast_adsi_transmit_message(), ast_adsi_voice_mode(), ast_mutex_lock, ast_mutex_unlock, vm_state::curmsg, vm_state::deleted, and vm_state::lastmsg.

Referenced by vm_execmain().

7633 {
7634  int bytes = 0;
7635  unsigned char buf[256];
7636  unsigned char keys[8];
7637 
7638  int x;
7639 
7640  if (!ast_adsi_available(chan))
7641  return;
7642 
7643  /* New meaning for keys */
7644  for (x = 0; x < 5; x++)
7645  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7646 
7647  keys[6] = 0x0;
7648  keys[7] = 0x0;
7649 
7650  if (!vms->curmsg) {
7651  /* No prev key, provide "Folder" instead */
7652  keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7653  }
7654  if (vms->curmsg >= vms->lastmsg) {
7655  /* If last message ... */
7656  if (vms->curmsg) {
7657  /* but not only message, provide "Folder" instead */
7658  keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7659  } else {
7660  /* Otherwise if only message, leave blank */
7661  keys[3] = 1;
7662  }
7663  }
7664 
7665  /* If deleted, show "undeleted" */
7666 #ifdef IMAP_STORAGE
7667  ast_mutex_lock(&vms->lock);
7668 #endif
7669  if (vms->deleted[vms->curmsg]) {
7670  keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7671  }
7672 #ifdef IMAP_STORAGE
7673  ast_mutex_unlock(&vms->lock);
7674 #endif
7675 
7676  /* Except "Exit" */
7677  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7678  bytes += ast_adsi_set_keys(buf + bytes, keys);
7679  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7680 
7681  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7682 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
int * deleted
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
#define ast_mutex_lock(a)
Definition: lock.h:187
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
#define ADSI_KEY_SKT
Definition: adsi.h:117
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
#define ADSI_KEY_APPS
Definition: adsi.h:109
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ adsi_folders()

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

Definition at line 7501 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_JUST_CENT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_display(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), and ast_adsi_voice_mode().

Referenced by vm_execmain().

7502 {
7503  unsigned char buf[256];
7504  int bytes = 0;
7505  unsigned char keys[8];
7506  int x, y;
7507 
7508  if (!ast_adsi_available(chan))
7509  return;
7510 
7511  for (x = 0; x < 5; x++) {
7512  y = ADSI_KEY_APPS + 12 + start + x;
7513  if (y > ADSI_KEY_APPS + 12 + 4)
7514  y = 0;
7515  keys[x] = ADSI_KEY_SKT | y;
7516  }
7517  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17);
7518  keys[6] = 0;
7519  keys[7] = 0;
7520 
7521  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, "");
7522  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
7523  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7524  bytes += ast_adsi_set_keys(buf + bytes, keys);
7525  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7526 
7527  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7528 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
#define ADSI_COMM_PAGE
Definition: adsi.h:107
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
#define ADSI_KEY_SKT
Definition: adsi.h:117
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
#define ADSI_JUST_CENT
Definition: adsi.h:114
#define ADSI_KEY_APPS
Definition: adsi.h:109

◆ adsi_goodbye()

static void adsi_goodbye ( struct ast_channel chan)
static

Definition at line 7787 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_JUST_CENT, ADSI_JUST_LEFT, adsi_logo(), ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_display(), ast_adsi_set_line(), ast_adsi_transmit_message(), and ast_adsi_voice_mode().

Referenced by vm_execmain().

7788 {
7789  unsigned char buf[256];
7790  int bytes = 0;
7791 
7792  if (!ast_adsi_available(chan))
7793  return;
7794  bytes += adsi_logo(buf + bytes);
7795  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
7796  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
7797  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7798  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7799 
7800  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7801 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
static int adsi_logo(unsigned char *buf)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define ADSI_JUST_LEFT
Definition: adsi.h:112
#define ADSI_COMM_PAGE
Definition: adsi.h:107
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
#define ADSI_JUST_CENT
Definition: adsi.h:114

◆ adsi_load_vmail()

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

Definition at line 7307 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_KEY_APPS, adsi_logo(), ADSI_MSG_DISPLAY, ADSI_MSG_DOWNLOAD, ast_adsi_begin_download(), ast_adsi_data_mode(), ast_adsi_display(), ast_adsi_download_disconnect(), ast_adsi_end_download(), ast_adsi_load_session(), ast_adsi_load_soft_key(), ast_adsi_set_line(), ast_adsi_transmit_message(), ast_adsi_voice_mode(), ast_debug, mbox(), and NULL.

Referenced by adsi_begin().

7308 {
7309  unsigned char buf[256];
7310  int bytes = 0;
7311  int x;
7312  char num[5];
7313 
7314  *useadsi = 0;
7315  bytes += ast_adsi_data_mode(buf + bytes);
7316  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7317 
7318  bytes = 0;
7319  bytes += adsi_logo(buf);
7320  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7321 #ifdef DISPLAY
7322  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .", "");
7323 #endif
7324  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7325  bytes += ast_adsi_data_mode(buf + bytes);
7326  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7327 
7329  bytes = 0;
7330  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", "");
7331  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7332  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7333  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7334  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7335  return 0;
7336  }
7337 
7338 #ifdef DISPLAY
7339  /* Add a dot */
7340  bytes = 0;
7341  bytes += ast_adsi_logo(buf);
7342  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7343  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ..", "");
7344  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7345  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7346 #endif
7347  bytes = 0;
7348  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1);
7349  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1);
7350  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advnced", "3", 1);
7351  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1);
7352  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1);
7353  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1);
7354  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7355 
7356 #ifdef DISPLAY
7357  /* Add another dot */
7358  bytes = 0;
7359  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ...", "");
7360  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7361 
7362  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7363  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7364 #endif
7365 
7366  bytes = 0;
7367  /* These buttons we load but don't use yet */
7368  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 6, "Previous", "Prev", "4", 1);
7369  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 8, "Repeat", "Repeat", "5", 1);
7370  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 7, "Delete", "Delete", "7", 1);
7371  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 9, "Next", "Next", "6", 1);
7372  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 10, "Save", "Save", "9", 1);
7373  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 11, "Undelete", "Restore", "7", 1);
7374  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7375 
7376 #ifdef DISPLAY
7377  /* Add another dot */
7378  bytes = 0;
7379  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ....", "");
7380  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7381  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7382 #endif
7383 
7384  bytes = 0;
7385  for (x = 0; x < 5; x++) {
7386  snprintf(num, sizeof(num), "%d", x);
7387  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(NULL, x), mbox(NULL, x), num, 1);
7388  }
7389  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + 5, "Cancel", "Cancel", "#", 1);
7390  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7391 
7392 #ifdef DISPLAY
7393  /* Add another dot */
7394  bytes = 0;
7395  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .....", "");
7396  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7397  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7398 #endif
7399 
7400  if (ast_adsi_end_download(chan)) {
7401  bytes = 0;
7402  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Download Unsuccessful.", "");
7403  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7404  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7405  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7406  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7407  return 0;
7408  }
7409  bytes = 0;
7410  bytes += ast_adsi_download_disconnect(buf + bytes);
7411  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7412  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7413 
7414  ast_debug(1, "Done downloading scripts...\n");
7415 
7416 #ifdef DISPLAY
7417  /* Add last dot */
7418  bytes = 0;
7419  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
7420  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7421 #endif
7422  ast_debug(1, "Restarting session...\n");
7423 
7424  bytes = 0;
7425  /* Load the session now */
7426  if (ast_adsi_load_session(chan, adsifdn, adsiver, 1) == 1) {
7427  *useadsi = 1;
7428  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", "");
7429  } else
7430  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Failed!", "");
7431 
7432  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7433  return 0;
7434 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
Definition: adsi.c:32
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
static unsigned char adsifdn[4]
int ast_adsi_data_mode(unsigned char *buf)
Puts CPE in data mode.
Definition: adsi.c:219
static int adsi_logo(unsigned char *buf)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int adsiver
static unsigned char adsisec[4]
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_download_disconnect(unsigned char *buf)
Disconnects (and hopefully saves) a downloaded script.
Definition: adsi.c:208
#define ADSI_JUST_LEFT
Definition: adsi.h:112
#define NULL
Definition: resample.c:96
#define ADSI_COMM_PAGE
Definition: adsi.h:107
static const char * mbox(struct ast_vm_user *vmu, int id)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
static char * addesc
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
int ast_adsi_end_download(struct ast_channel *chan)
Definition: adsi.c:43
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
#define ADSI_JUST_CENT
Definition: adsi.h:114
#define ADSI_KEY_APPS
Definition: adsi.h:109

◆ adsi_login()

static void adsi_login ( struct ast_channel chan)
static

Definition at line 7453 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_DIR_FROM_LEFT, ADSI_JUST_CENT, ADSI_JUST_LEFT, ADSI_KEY_APPS, adsi_logo(), ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_display(), ast_adsi_input_control(), ast_adsi_input_format(), ast_adsi_load_soft_key(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), and ast_adsi_voice_mode().

Referenced by vm_authenticate().

7454 {
7455  unsigned char buf[256];
7456  int bytes = 0;
7457  unsigned char keys[8];
7458  int x;
7459  if (!ast_adsi_available(chan))
7460  return;
7461 
7462  for (x = 0; x < 8; x++)
7463  keys[x] = 0;
7464  /* Set one key for next */
7465  keys[3] = ADSI_KEY_APPS + 3;
7466 
7467  bytes += adsi_logo(buf + bytes);
7468  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, " ", "");
7469  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ", "");
7470  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7471  bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Mailbox: ******", "");
7472  bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 1, 1, ADSI_JUST_LEFT);
7473  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Enter", "Enter", "#", 1);
7474  bytes += ast_adsi_set_keys(buf + bytes, keys);
7475  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7476  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7477 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
static int adsi_logo(unsigned char *buf)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
#define ADSI_JUST_LEFT
Definition: adsi.h:112
#define ADSI_COMM_PAGE
Definition: adsi.h:107
#define ADSI_DIR_FROM_LEFT
Definition: adsi.h:120
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
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
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
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
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
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
#define ADSI_JUST_CENT
Definition: adsi.h:114
#define ADSI_KEY_APPS
Definition: adsi.h:109

◆ adsi_logo()

static int adsi_logo ( unsigned char *  buf)
static

Definition at line 7299 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_JUST_CENT, and ast_adsi_display().

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

7300 {
7301  int bytes = 0;
7302  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
7303  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
7304  return bytes;
7305 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define ADSI_COMM_PAGE
Definition: adsi.h:107
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

◆ adsi_message()

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

Definition at line 7530 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_display(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), ast_adsi_voice_mode(), ast_callerid_parse(), ast_copy_string(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero, 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().

7531 {
7532  int bytes = 0;
7533  unsigned char buf[256];
7534  char buf1[256], buf2[256];
7535  char fn2[PATH_MAX];
7536 
7537  char cid[256] = "";
7538  char *val;
7539  char *name, *num;
7540  char datetime[21] = "";
7541  FILE *f;
7542 
7543  unsigned char keys[8];
7544 
7545  int x;
7546 
7547  if (!ast_adsi_available(chan))
7548  return;
7549 
7550  /* Retrieve important info */
7551  snprintf(fn2, sizeof(fn2), "%s.txt", vms->fn);
7552  f = fopen(fn2, "r");
7553  if (f) {
7554  while (!feof(f)) {
7555  if (!fgets((char *) buf, sizeof(buf), f)) {
7556  continue;
7557  }
7558  if (!feof(f)) {
7559  char *stringp = NULL;
7560  stringp = (char *) buf;
7561  strsep(&stringp, "=");
7562  val = strsep(&stringp, "=");
7563  if (!ast_strlen_zero(val)) {
7564  if (!strcmp((char *) buf, "callerid"))
7565  ast_copy_string(cid, val, sizeof(cid));
7566  if (!strcmp((char *) buf, "origdate"))
7567  ast_copy_string(datetime, val, sizeof(datetime));
7568  }
7569  }
7570  }
7571  fclose(f);
7572  }
7573  /* New meaning for keys */
7574  for (x = 0; x < 5; x++)
7575  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7576  keys[6] = 0x0;
7577  keys[7] = 0x0;
7578 
7579  if (!vms->curmsg) {
7580  /* No prev key, provide "Folder" instead */
7581  keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7582  }
7583  if (vms->curmsg >= vms->lastmsg) {
7584  /* If last message ... */
7585  if (vms->curmsg) {
7586  /* but not only message, provide "Folder" instead */
7587  keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7588  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7589 
7590  } else {
7591  /* Otherwise if only message, leave blank */
7592  keys[3] = 1;
7593  }
7594  }
7595 
7596  if (!ast_strlen_zero(cid)) {
7597  ast_callerid_parse(cid, &name, &num);
7598  if (!name)
7599  name = num;
7600  } else {
7601  name = "Unknown Caller";
7602  }
7603 
7604  /* If deleted, show "undeleted" */
7605 #ifdef IMAP_STORAGE
7606  ast_mutex_lock(&vms->lock);
7607 #endif
7608  if (vms->deleted[vms->curmsg]) {
7609  keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7610  }
7611 #ifdef IMAP_STORAGE
7612  ast_mutex_unlock(&vms->lock);
7613 #endif
7614 
7615  /* Except "Exit" */
7616  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7617  snprintf(buf1, sizeof(buf1), "%s%s", vms->curbox,
7618  strcasecmp(vms->curbox, "INBOX") ? " Messages" : "");
7619  snprintf(buf2, sizeof(buf2), "Message %d of %d", vms->curmsg + 1, vms->lastmsg + 1);
7620 
7621  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7622  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7623  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, name, "");
7624  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, datetime, "");
7625  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7626  bytes += ast_adsi_set_keys(buf + bytes, keys);
7627  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7628 
7629  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7630 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
Definition: ast_expr2.c:325
int * deleted
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
static struct ast_threadstorage buf2
#define ADSI_JUST_LEFT
Definition: adsi.h:112
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
char fn[PATH_MAX]
char curbox[80]
#define ADSI_COMM_PAGE
Definition: adsi.h:107
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
#define ADSI_KEY_SKT
Definition: adsi.h:117
static struct ast_threadstorage buf1
#define ast_strlen_zero(a)
Definition: muted.c:73
static const char name[]
Definition: cdr_mysql.c:74
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
char * strsep(char **str, const char *delims)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define PATH_MAX
Definition: asterisk.h:40
#define ADSI_KEY_APPS
Definition: adsi.h:109
#define ast_mutex_unlock(a)
Definition: lock.h:188
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
Definition: callerid.c:1008

◆ adsi_password()

static void adsi_password ( struct ast_channel chan)
static

Definition at line 7479 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_DIR_FROM_LEFT, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_input_control(), ast_adsi_input_format(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), and ast_adsi_voice_mode().

Referenced by vm_authenticate().

7480 {
7481  unsigned char buf[256];
7482  int bytes = 0;
7483  unsigned char keys[8];
7484  int x;
7485  if (!ast_adsi_available(chan))
7486  return;
7487 
7488  for (x = 0; x < 8; x++)
7489  keys[x] = 0;
7490  /* Set one key for next */
7491  keys[3] = ADSI_KEY_APPS + 3;
7492 
7493  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7494  bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
7495  bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
7496  bytes += ast_adsi_set_keys(buf + bytes, keys);
7497  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7498  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7499 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
#define ADSI_JUST_LEFT
Definition: adsi.h:112
#define ADSI_COMM_PAGE
Definition: adsi.h:107
#define ADSI_DIR_FROM_LEFT
Definition: adsi.h:120
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
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
#define ADSI_KEY_APPS
Definition: adsi.h:109

◆ adsi_status()

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

Definition at line 7684 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_display(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), ast_adsi_voice_mode(), buf1, buf2, vm_state::lastmsg, vm_state::newmessages, and vm_state::oldmessages.

Referenced by vm_execmain().

7685 {
7686  unsigned char buf[256] = "";
7687  char buf1[256] = "", buf2[256] = "";
7688  int bytes = 0;
7689  unsigned char keys[8];
7690  int x;
7691 
7692  char *newm = (vms->newmessages == 1) ? "message" : "messages";
7693  char *oldm = (vms->oldmessages == 1) ? "message" : "messages";
7694  if (!ast_adsi_available(chan))
7695  return;
7696  if (vms->newmessages) {
7697  snprintf(buf1, sizeof(buf1), "You have %d new", vms->newmessages);
7698  if (vms->oldmessages) {
7699  strncat(buf1, " and", sizeof(buf1) - strlen(buf1) - 1);
7700  snprintf(buf2, sizeof(buf2), "%d old %s.", vms->oldmessages, oldm);
7701  } else {
7702  snprintf(buf2, sizeof(buf2), "%s.", newm);
7703  }
7704  } else if (vms->oldmessages) {
7705  snprintf(buf1, sizeof(buf1), "You have %d old", vms->oldmessages);
7706  snprintf(buf2, sizeof(buf2), "%s.", oldm);
7707  } else {
7708  strcpy(buf1, "You have no messages.");
7709  buf2[0] = ' ';
7710  buf2[1] = '\0';
7711  }
7712  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7713  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7714  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7715 
7716  for (x = 0; x < 6; x++)
7717  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7718  keys[6] = 0;
7719  keys[7] = 0;
7720 
7721  /* Don't let them listen if there are none */
7722  if (vms->lastmsg < 0)
7723  keys[0] = 1;
7724  bytes += ast_adsi_set_keys(buf + bytes, keys);
7725 
7726  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7727 
7728  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7729 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
int oldmessages
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
static struct ast_threadstorage buf2
#define ADSI_JUST_LEFT
Definition: adsi.h:112
#define ADSI_COMM_PAGE
Definition: adsi.h:107
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
#define ADSI_KEY_SKT
Definition: adsi.h:117
static struct ast_threadstorage buf1
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
int newmessages
#define ADSI_KEY_APPS
Definition: adsi.h:109

◆ adsi_status2()

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

Definition at line 7731 of file app_voicemail.c.

References ADSI_COMM_PAGE, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_display(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), ast_adsi_voice_mode(), buf1, buf2, vm_state::curbox, and vm_state::lastmsg.

Referenced by vm_execmain().

7732 {
7733  unsigned char buf[256] = "";
7734  char buf1[256] = "", buf2[256] = "";
7735  int bytes = 0;
7736  unsigned char keys[8];
7737  int x;
7738 
7739  char *mess = (vms->lastmsg == 0) ? "message" : "messages";
7740 
7741  if (!ast_adsi_available(chan))
7742  return;
7743 
7744  /* Original command keys */
7745  for (x = 0; x < 6; x++)
7746  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7747 
7748  keys[6] = 0;
7749  keys[7] = 0;
7750 
7751  if ((vms->lastmsg + 1) < 1)
7752  keys[0] = 0;
7753 
7754  snprintf(buf1, sizeof(buf1), "%s%s has", vms->curbox,
7755  strcasecmp(vms->curbox, "INBOX") ? " folder" : "");
7756 
7757  if (vms->lastmsg + 1)
7758  snprintf(buf2, sizeof(buf2), "%d %s.", vms->lastmsg + 1, mess);
7759  else
7760  strcpy(buf2, "no messages.");
7761  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7762  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7763  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, "", "");
7764  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7765  bytes += ast_adsi_set_keys(buf + bytes, keys);
7766 
7767  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7768 
7769  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7770 
7771 }
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
static struct ast_threadstorage buf2
#define ADSI_JUST_LEFT
Definition: adsi.h:112
char curbox[80]
#define ADSI_COMM_PAGE
Definition: adsi.h:107
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
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
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
#define ADSI_KEY_SKT
Definition: adsi.h:117
static struct ast_threadstorage buf1
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
#define ADSI_KEY_APPS
Definition: adsi.h:109

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

References ast_callerid_parse(), ast_config_destroy(), ast_config_load, ast_log, AST_LOG_WARNING, AST_MAX_EXTENSION, ast_play_and_wait(), ast_strdupa, ast_strlen_zero, ast_test_suite_event_notify, ast_variable_retrieve(), ast_verb, ast_waitfordigit(), ast_vm_user::callback, CONFIG_FLAG_NOCACHE, context, ast_vm_user::context, vm_state::curdir, vm_state::curmsg, ast_vm_user::dialout, dialout(), DISPOSE, find_user(), vm_state::fn, free_user(), vm_state::heard, leave_voicemail(), 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().

15288 {
15289  int res = 0;
15290  char filename[PATH_MAX];
15291  struct ast_config *msg_cfg = NULL;
15292  const char *origtime, *context;
15293  char *name, *num;
15294  int retries = 0;
15295  char *cid;
15296  struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE, };
15297 
15298  vms->starting = 0;
15299 
15300  make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
15301 
15302  /* Retrieve info from VM attribute file */
15303  snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
15304  RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
15305  msg_cfg = ast_config_load(filename, config_flags);
15306  DISPOSE(vms->curdir, vms->curmsg);
15307  if (!valid_config(msg_cfg)) {
15308  ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
15309  return 0;
15310  }
15311 
15312  if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) {
15313  ast_config_destroy(msg_cfg);
15314  return 0;
15315  }
15316 
15317  cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid"));
15318 
15319  context = ast_variable_retrieve(msg_cfg, "message", "context");
15320  if (!strncasecmp("macro", context, 5)) /* Macro names in contexts are useless for our needs */
15321  context = ast_variable_retrieve(msg_cfg, "message", "macrocontext");
15322  switch (option) {
15323  case 3: /* Play message envelope */
15324  if (!res) {
15325  res = play_message_datetime(chan, vmu, origtime, filename);
15326  }
15327  if (!res) {
15328  res = play_message_callerid(chan, vms, cid, context, 0, 1);
15329  }
15330 
15331  res = 't';
15332  break;
15333 
15334  case 2: /* Call back */
15335 
15336  if (ast_strlen_zero(cid))
15337  break;
15338 
15339  ast_callerid_parse(cid, &name, &num);
15340  while ((res > -1) && (res != 't')) {
15341  switch (res) {
15342  case '1':
15343  if (num) {
15344  /* Dial the CID number */
15345  res = dialout(chan, vmu, num, vmu->callback);
15346  if (res) {
15347  ast_config_destroy(msg_cfg);
15348  return 9;
15349  }
15350  } else {
15351  res = '2';
15352  }
15353  break;
15354 
15355  case '2':
15356  /* Want to enter a different number, can only do this if there's a dialout context for this user */
15357  if (!ast_strlen_zero(vmu->dialout)) {
15358  res = dialout(chan, vmu, NULL, vmu->dialout);
15359  if (res) {
15360  ast_config_destroy(msg_cfg);
15361  return 9;
15362  }
15363  } else {
15364  ast_verb(3, "Caller can not specify callback number - no dialout context available\n");
15365  res = ast_play_and_wait(chan, "vm-sorry");
15366  }
15367  ast_config_destroy(msg_cfg);
15368  return res;
15369  case '*':
15370  res = 't';
15371  break;
15372  case '3':
15373  case '4':
15374  case '5':
15375  case '6':
15376  case '7':
15377  case '8':
15378  case '9':
15379  case '0':
15380 
15381  res = ast_play_and_wait(chan, "vm-sorry");
15382  retries++;
15383  break;
15384  default:
15385  if (num) {
15386  ast_verb(3, "Confirm CID number '%s' is number to use for callback\n", num);
15387  res = ast_play_and_wait(chan, "vm-num-i-have");
15388  if (!res)
15389  res = play_message_callerid(chan, vms, num, vmu->context, 1, 1);
15390  if (!res)
15391  res = ast_play_and_wait(chan, "vm-tocallnum");
15392  /* Only prompt for a caller-specified number if there is a dialout context specified */
15393  if (!ast_strlen_zero(vmu->dialout)) {
15394  if (!res)
15395  res = ast_play_and_wait(chan, "vm-calldiffnum");
15396  }
15397  } else {
15398  res = ast_play_and_wait(chan, "vm-nonumber");
15399  if (!ast_strlen_zero(vmu->dialout)) {
15400  if (!res)
15401  res = ast_play_and_wait(chan, "vm-toenternumber");
15402  }
15403  }
15404  if (!res) {
15405  res = ast_play_and_wait(chan, "vm-star-cancel");
15406  }
15407  if (!res) {
15408  res = ast_waitfordigit(chan, 6000);
15409  }
15410  if (!res) {
15411  retries++;
15412  if (retries > 3) {
15413  res = 't';
15414  }
15415  }
15416  ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
15417  isprint(res) ? res : '?', isprint(res) ? res : '?');
15418  break;
15419 
15420  }
15421  if (res == 't')
15422  res = 0;
15423  else if (res == '*')
15424  res = -1;
15425  }
15426  break;
15427 
15428  case 1: /* Reply */
15429  /* Send reply directly to sender */
15430  if (ast_strlen_zero(cid))
15431  break;
15432 
15433  ast_callerid_parse(cid, &name, &num);
15434  if (!num) {
15435  ast_verb(3, "No CID number available, no reply sent\n");
15436  if (!res)
15437  res = ast_play_and_wait(chan, "vm-nonumber");
15438  ast_config_destroy(msg_cfg);
15439  return res;
15440  } else {
15441  struct ast_vm_user vmu2, *vmu3;
15442  memset(&vmu2, 0, sizeof(vmu2));
15443  vmu3 = find_user(&vmu2, vmu->context, num);
15444  if (vmu3) {
15445  struct leave_vm_options leave_options;
15446  char mailbox[AST_MAX_EXTENSION * 2 + 2];
15447  snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context);
15448 
15449  ast_verb(3, "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
15450 
15451  memset(&leave_options, 0, sizeof(leave_options));
15452  leave_options.record_gain = record_gain;
15453  res = leave_voicemail(chan, mailbox, &leave_options);
15454  if (!res)
15455  res = 't';
15456  ast_config_destroy(msg_cfg);
15457  free_user(vmu3);
15458  return res;
15459  } else {
15460  /* Sender has no mailbox, can't reply */
15461  ast_verb(3, "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
15462  ast_play_and_wait(chan, "vm-nobox");
15463  res = 't';
15464  ast_config_destroy(msg_cfg);
15465  return res;
15466  }
15467  }
15468  res = 0;
15469 
15470  break;
15471  }
15472 
15473  ast_config_destroy(msg_cfg);
15474 
15475 #ifndef IMAP_STORAGE
15476  if (!res) {
15477  make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
15478  vms->heard[msg] = 1;
15479  res = wait_file(chan, vms, vms->fn);
15480  }
15481 #endif
15482  return res;
15483 }
static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback, int saycidnumber)
#define AST_LOG_WARNING
Definition: logger.h:279
char curdir[PATH_MAX]
#define NULL
Definition: resample.c:96
#define DISPOSE(a, b)
char fn[PATH_MAX]
#define ast_verb(level,...)
Definition: logger.h:455
char context[MAX_VM_CONTEXT_LEN]
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 char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define ast_log
Definition: astobj2.c:42
#define ast_config_load(filename, flags)
Load a config file.
char dialout[80]
int * heard
#define AST_MAX_EXTENSION
Definition: channel.h:135
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:1393
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static void free_user(struct ast_vm_user *vmu)
static int wait_file(struct ast_channel *chan, struct vm_state *vms, char *file)
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:196
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.
#define ast_strlen_zero(a)
Definition: muted.c:73
static struct ast_vm_user * find_user(struct ast_vm_user *ivm, const char *context, const char *mailbox)
Finds a voicemail user from the users file or the realtime engine.
static const char name[]
Definition: cdr_mysql.c:74
Structure used to handle boolean flags.
Definition: utils.h:199
Options for leaving voicemail with the voicemail() application.
Definition: app_minivm.c:650
#define RETRIEVE(a, b, c, d)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3170
signed char record_gain
Definition: app_minivm.c:652
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:694
char callback[80]
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)
#define PATH_MAX
Definition: asterisk.h:40
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
char mailbox[MAX_VM_MBOX_ID_LEN]
static int valid_config(const struct ast_config *cfg)
Check if configuration file is valid.
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
Definition: callerid.c:1008
static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *vmu, const char *origtime, const char *filename)

◆ alias_mailbox_mapping_create()

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

Definition at line 13570 of file app_voicemail.c.

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

Referenced by load_aliases().

13571 {
13572  struct alias_mailbox_mapping *mapping;
13573  size_t from_len = strlen(alias) + 1;
13574  size_t to_len = strlen(mailbox) + 1;
13575 
13576  mapping = ao2_alloc(sizeof(*mapping) + from_len + to_len, NULL);
13577  if (!mapping) {
13578  return NULL;
13579  }
13580  mapping->alias = mapping->buf;
13581  mapping->mailbox = mapping->buf + from_len;
13582  ast_copy_string(mapping->alias, alias, from_len); /* Safe */
13583  ast_copy_string(mapping->mailbox, mailbox, to_len); /* Safe */
13584 
13585  return mapping;
13586 }
#define NULL
Definition: resample.c:96
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

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

References apply_options(), ast_calloc, ast_copy_string(), ast_log, ast_set_flag, ast_strdup, ast_strdupa, ast_strlen_zero, AST_TEST_DEFINE, AST_TEST_FAIL, ast_test_flag, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_vm_user::attachfmt, ast_vm_user::callback, ast_vm_user::context, ast_vm_user::dialout, ast_vm_user::email, ast_vm_user::emailbody, ast_vm_user::emailsubject, ast_vm_user::exit, find_or_create(), free_user(), ast_vm_user::fromstring, ast_vm_user::fullname, inboxcount2(), sip_to_pjsip::info(), LOG_WARNING, ast_vm_user::mailbox, MAX_VM_MAILBOX_LEN, ast_vm_user::maxdeletedmsg, ast_vm_user::maxsecs, ast_vm_user::minsecs, 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(), ast_vm_user::saydurationm, ast_vm_user::serveremail, strsep(), TEST_EXECUTE, TEST_INIT, tmp(), VM_ALLOCED, 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, ast_vm_user::volgain, and ast_vm_user::zonetag.

Referenced by load_users().

12408 {
12409  /* Assumes lock is already held */
12410  char *tmp;
12411  char *stringp;
12412  char *s;
12413  struct ast_vm_user *vmu;
12414  char mailbox_full[MAX_VM_MAILBOX_LEN];
12415  int new = 0, old = 0, urgent = 0;
12416  char secretfn[PATH_MAX] = "";
12417 
12418  tmp = ast_strdupa(data);
12419 
12420  if (!(vmu = find_or_create(context, box)))
12421  return -1;
12422 
12423  populate_defaults(vmu);
12424 
12425  stringp = tmp;
12426  if ((s = strsep(&stringp, ","))) {
12427  if (!ast_strlen_zero(s) && s[0] == '*') {
12428  ast_log(LOG_WARNING, "Invalid password detected for mailbox %s. The password"
12429  "\n\tmust be reset in voicemail.conf.\n", box);
12430  }
12431  /* assign password regardless of validity to prevent NULL password from being assigned */
12432  ast_copy_string(vmu->password, s, sizeof(vmu->password));
12433  }
12434  if (stringp && (s = strsep(&stringp, ","))) {
12435  ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
12436  }
12437  if (stringp && (s = strsep(&stringp, ","))) {
12438  vmu->email = ast_strdup(s);
12439  }
12440  if (stringp && (s = strsep(&stringp, ","))) {
12441  ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
12442  }
12443  if (stringp) {
12444  apply_options(vmu, stringp);
12445  }
12446 
12447  switch (vmu->passwordlocation) {
12448  case OPT_PWLOC_SPOOLDIR:
12449  snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
12450  read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
12451  }
12452 
12453  snprintf(mailbox_full, MAX_VM_MAILBOX_LEN, "%s%s%s",
12454  box,
12455  ast_strlen_zero(context) ? "" : "@",
12456  context);
12457 
12458  inboxcount2(mailbox_full, &urgent, &new, &old);
12459 #ifdef IMAP_STORAGE
12460  imap_logout(mailbox_full);
12461 #endif
12462  queue_mwi_event(NULL, mailbox_full, urgent, new, old);
12463 
12464  return 0;
12465 }
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
char pager[80]
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
char password[80]
#define NULL
Definition: resample.c:96
static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Check the given mailbox&#39;s message count.
char context[MAX_VM_CONTEXT_LEN]
#define ast_log
Definition: astobj2.c:42
int passwordlocation
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static void queue_mwi_event(const char *channel_id, const char *box, int urgent, int new, int old)
static char VM_SPOOL_DIR[PATH_MAX]
static void apply_options(struct ast_vm_user *vmu, const char *options)
Destructively Parse options and apply.
#define ast_strlen_zero(a)
Definition: muted.c:73
static void read_password_from_file(const char *secretfn, char *password, int passwordlen)
char * strsep(char **str, const char *delims)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static struct ast_vm_user * find_or_create(const char *context, const char *box)
#define PATH_MAX
Definition: asterisk.h:40
char fullname[80]
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
char mailbox[MAX_VM_MBOX_ID_LEN]
#define MAX_VM_MAILBOX_LEN
static void populate_defaults(struct ast_vm_user *vmu)
Sets default voicemail system options to a voicemail user.

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

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, ast_vm_user::fullname, inboxcount(), ast_vm_user::language, LOG_ERROR, mailbox, ast_vm_user::mailbox, ast_vm_user::maxmsg, ast_vm_user::maxsecs, NULL, ast_vm_user::pager, ast_vm_user::saydurationm, ast_vm_user::serveremail, ast_vm_user::uniqueid, VM_ATTACH, VM_DELETE, VM_ENVELOPE, VM_OPERATOR, VM_REVIEW, VM_SAYCID, ast_vm_user::volgain, and ast_vm_user::zonetag.

Referenced by manager_list_voicemail_users(), and manager_status_voicemail_user().

13215 {
13216  int new;
13217  int old;
13218  char *mailbox;
13219  int ret;
13220 
13221  if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {
13222  ast_log(LOG_ERROR, "Wrong input parameter.");
13223  return 0;
13224  }
13225 
13226  /* create mailbox string */
13227  if (!ast_strlen_zero(vmu->context)) {
13228  ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);
13229  } else {
13230  ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);
13231  }
13232  if (ret == -1) {
13233  ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));
13234  return 0;
13235  }
13236 
13237  /* get mailbox count */
13238  ret = inboxcount(mailbox, &new, &old);
13239  ast_free(mailbox);
13240  if (ret == -1) {
13241  ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n",
13242  vmu->mailbox ?: "", vmu->context ?: "");
13243  return 0;
13244  }
13245 
13246  astman_append(s,
13247  "Event: %s\r\n"
13248  "%s"
13249  "VMContext: %s\r\n"
13250  "VoiceMailbox: %s\r\n"
13251  "Fullname: %s\r\n"
13252  "Email: %s\r\n"
13253  "Pager: %s\r\n"
13254  "ServerEmail: %s\r\n"
13255  "FromString: %s\r\n"
13256  "MailCommand: %s\r\n"
13257  "Language: %s\r\n"
13258  "TimeZone: %s\r\n"
13259  "Callback: %s\r\n"
13260  "Dialout: %s\r\n"
13261  "UniqueID: %s\r\n"
13262  "ExitContext: %s\r\n"
13263  "SayDurationMinimum: %d\r\n"
13264  "SayEnvelope: %s\r\n"
13265  "SayCID: %s\r\n"
13266  "AttachMessage: %s\r\n"
13267  "AttachmentFormat: %s\r\n"
13268  "DeleteMessage: %s\r\n"
13269  "VolumeGain: %.2f\r\n"
13270  "CanReview: %s\r\n"
13271  "CallOperator: %s\r\n"
13272  "MaxMessageCount: %d\r\n"
13273  "MaxMessageLength: %d\r\n"
13274  "NewMessageCount: %d\r\n"
13275  "OldMessageCount: %d\r\n"
13276 #ifdef IMAP_STORAGE
13277  "IMAPUser: %s\r\n"
13278  "IMAPServer: %s\r\n"
13279  "IMAPPort: %s\r\n"
13280  "IMAPFlags: %s\r\n"
13281 #endif
13282  "\r\n",
13283 
13284  event_name,
13285  actionid,
13286  vmu->context,
13287  vmu->mailbox,
13288  vmu->fullname,
13289  vmu->email,
13290  vmu->pager,
13293  mailcmd,
13294  vmu->language,
13295  vmu->zonetag,
13296  vmu->callback,
13297  vmu->dialout,
13298  vmu->uniqueid,
13299  vmu->exit,
13300  vmu->saydurationm,
13301  ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
13302  ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
13303  ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
13304  vmu->attachfmt,
13305  ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
13306  vmu->volgain,
13307  ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
13308  ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
13309  vmu->maxmsg,
13310  vmu->maxsecs,
13311  new,
13312  old
13313 #ifdef IMAP_STORAGE
13314  ,
13315  vmu->imapuser,
13316  vmu->imapserver,
13317  vmu->imapport,
13318  vmu->imapflags
13319 #endif
13320  );
13321 
13322  return 1;
13323 
13324 }
double volgain
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3080
static char mailcmd[160]
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define VM_ATTACH
char pager[80]
#define NULL
Definition: resample.c:96
static char fromstring[100]
char context[MAX_VM_CONTEXT_LEN]
char exit[80]
#define VM_SAYCID
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:269
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define VM_ENVELOPE
#define ast_log
Definition: astobj2.c:42
char dialout[80]
#define VM_DELETE
char zonetag[80]
char fromstring[100]
#define VM_OPERATOR
#define LOG_ERROR
Definition: logger.h:285
#define VM_REVIEW
int errno
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_free(a)
Definition: astmm.h:182
char language[MAX_LANGUAGE]
char serveremail[80]
char attachfmt[20]
char uniqueid[80]
char callback[80]
static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
char fullname[80]
char mailbox[MAX_VM_MBOX_ID_LEN]
static char serveremail[80]

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

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

1245 {
1246  int x;
1247  if (!strcasecmp(var, "attach")) {
1249  } else if (!strcasecmp(var, "attachfmt")) {
1250  ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
1251  } else if (!strcasecmp(var, "serveremail")) {
1252  ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
1253  } else if (!strcasecmp(var, "fromstring")) {
1254  ast_copy_string(vmu->fromstring, value, sizeof(vmu->fromstring));
1255  } else if (!strcasecmp(var, "emailbody")) {
1256  ast_free(vmu->emailbody);
1258  } else if (!strcasecmp(var, "emailsubject")) {
1259  ast_free(vmu->emailsubject);
1261  } else if (!strcasecmp(var, "language")) {
1262  ast_copy_string(vmu->language, value, sizeof(vmu->language));
1263  } else if (!strcasecmp(var, "tz")) {
1264  ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
1265  } else if (!strcasecmp(var, "locale")) {
1266  ast_copy_string(vmu->locale, value, sizeof(vmu->locale));
1267 #ifdef IMAP_STORAGE
1268  } else if (!strcasecmp(var, "imapuser")) {
1269  ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
1270  vmu->imapversion = imapversion;
1271  } else if (!strcasecmp(var, "imapserver")) {
1272  ast_copy_string(vmu->imapserver, value, sizeof(vmu->imapserver));
1273  vmu->imapversion = imapversion;
1274  } else if (!strcasecmp(var, "imapport")) {
1275  ast_copy_string(vmu->imapport, value, sizeof(vmu->imapport));
1276  vmu->imapversion = imapversion;
1277  } else if (!strcasecmp(var, "imapflags")) {
1278  ast_copy_string(vmu->imapflags, value, sizeof(vmu->imapflags));
1279  vmu->imapversion = imapversion;
1280  } else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
1281  ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
1282  vmu->imapversion = imapversion;
1283  } else if (!strcasecmp(var, "imapfolder")) {
1284  ast_copy_string(vmu->imapfolder, value, sizeof(vmu->imapfolder));
1285  vmu->imapversion = imapversion;
1286  } else if (!strcasecmp(var, "imapvmshareid")) {
1287  ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
1288  vmu->imapversion = imapversion;
1289 #endif
1290  } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {