Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
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)
}
 
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 } }
 
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 500 of file app_voicemail.c.

Referenced by actual_load_config().

◆ BASELINELEN

#define BASELINELEN   72

Definition at line 525 of file app_voicemail.c.

Referenced by ochar().

◆ BASEMAXINLINE

#define BASEMAXINLINE   256

Definition at line 526 of file app_voicemail.c.

Referenced by base_encode(), and inbuf().

◆ CHUNKSIZE

#define CHUNKSIZE   65536

Definition at line 497 of file app_voicemail.c.

◆ COMMAND_TIMEOUT

#define COMMAND_TIMEOUT   5000

Definition at line 493 of file app_voicemail.c.

◆ COPY

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

Definition at line 855 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 505 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 507 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 508 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DEFAULT_LISTEN_CONTROL_REVERSE_KEY

#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY   "*"

Definition at line 506 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 509 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 926 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 530 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 556 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 853 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 516 of file app_voicemail.c.

Referenced by leave_voicemail(), and play_record_review().

◆ MAPPING_BUCKETS

#define MAPPING_BUCKETS   511

Definition at line 949 of file app_voicemail.c.

Referenced by load_module().

◆ MAX_DATETIME_FORMAT

#define MAX_DATETIME_FORMAT   512

Definition at line 533 of file app_voicemail.c.

◆ MAX_MAIL_BODY_CONTENT_SIZE

#define MAX_MAIL_BODY_CONTENT_SIZE   134217728L

Definition at line 518 of file app_voicemail.c.

Referenced by vm_allocate_dh().

◆ MAX_NUM_CID_CONTEXTS

#define MAX_NUM_CID_CONTEXTS   10

Definition at line 534 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 732 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 734 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 731 of file app_voicemail.c.

◆ MAXMSG

#define MAXMSG   100

Definition at line 520 of file app_voicemail.c.

Referenced by actual_load_config(), and apply_option().

◆ MAXMSGLIMIT

#define MAXMSGLIMIT   9999

Definition at line 521 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 523 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 557 of file app_voicemail.c.

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

◆ PWDCHANGE_EXTERNAL

#define PWDCHANGE_EXTERNAL   (1 << 2)

Definition at line 869 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 868 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));

◆ RETRIEVE

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

◆ SENDMAIL

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

Definition at line 514 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 491 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 878 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 857 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 510 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 549 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 547 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 548 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 546 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 540 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 544 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 543 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 554 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 553 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 552 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 537 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 545 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 536 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 538 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 541 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 550 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 542 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 539 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 551 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 786 of file app_voicemail.c.

Referenced by vm_allocate_dh().

◆ VOICEMAIL_CONFIG

#define VOICEMAIL_CONFIG   "voicemail.conf"

Definition at line 499 of file app_voicemail.c.

Referenced by load_config(), and vm_change_password().

◆ VOICEMAIL_DIR_MODE

#define VOICEMAIL_DIR_MODE   0777

Definition at line 495 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 496 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 559 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 580 of file app_voicemail.c.

580  {
581  OPT_ARG_RECORDGAIN = 0,
582  OPT_ARG_PLAYFOLDER = 1,
583  OPT_ARG_DTMFEXIT = 2,
584  /* This *must* be the last value in this enum! */
585  OPT_ARG_ARRAY_SIZE = 3,
586 };

◆ 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 

Definition at line 568 of file app_voicemail.c.

◆ vm_passwordlocation

Enumerator
OPT_PWLOC_VOICEMAILCONF 
OPT_PWLOC_SPOOLDIR 
OPT_PWLOC_USERSCONF 

Definition at line 588 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 6036 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().

6037 {
6038  DIR *dir;
6039  struct dirent *de;
6040  char fn[256];
6041  int ret = 0;
6042  struct alias_mailbox_mapping *mapping;
6043  char *c;
6044  char *m;
6045 
6046  /* If no mailbox, return immediately */
6047  if (ast_strlen_zero(mailbox))
6048  return 0;
6049 
6050  if (ast_strlen_zero(folder))
6051  folder = "INBOX";
6052  if (ast_strlen_zero(context))
6053  context = "default";
6054 
6055  c = (char *)context;
6056  m = (char *)mailbox;
6057 
6059  char tmp[MAX_VM_MAILBOX_LEN];
6060 
6061  snprintf(tmp, MAX_VM_MAILBOX_LEN, "%s@%s", mailbox, context);
6063  if (mapping) {
6064  separate_mailbox(ast_strdupa(mapping->mailbox), &m, &c);
6065  ao2_ref(mapping, -1);
6066  }
6067  }
6068 
6069  snprintf(fn, sizeof(fn), "%s%s/%s/%s", VM_SPOOL_DIR, c, m, folder);
6070 
6071  if (!(dir = opendir(fn)))
6072  return 0;
6073 
6074  while ((de = readdir(dir))) {
6075  if (!strncasecmp(de->d_name, "msg", 3)) {
6076  if (shortcircuit) {
6077  ret = 1;
6078  break;
6079  } else if (!strncasecmp(de->d_name + 8, "txt", 3)) {
6080  ret++;
6081  }
6082  }
6083  }
6084 
6085  closedir(dir);
6086 
6087  return ret;
6088 }
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 16579 of file app_voicemail.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 16579 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 12648 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().

12649 {
12650  struct ast_vm_user svm;
12651  struct ast_vm_user *vmu = NULL;
12652  char *parse;
12653  char *mailbox;
12654  char *context;
12655  int res = 0;
12656 
12658  AST_APP_ARG(mailbox_context);
12659  AST_APP_ARG(attribute);
12660  AST_APP_ARG(folder);
12661  );
12662 
12663  buf[0] = '\0';
12664 
12665  if (ast_strlen_zero(args)) {
12666  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12667  return -1;
12668  }
12669 
12670  parse = ast_strdupa(args);
12671  AST_STANDARD_APP_ARGS(arg, parse);
12672 
12673  if (ast_strlen_zero(arg.mailbox_context)
12674  || ast_strlen_zero(arg.attribute)
12675  || separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
12676  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12677  return -1;
12678  }
12679 
12680  memset(&svm, 0, sizeof(svm));
12681  vmu = find_user(&svm, context, mailbox);
12682 
12683  if (!strncasecmp(arg.attribute, "exists", 5)) {
12684  ast_copy_string(buf, vmu ? "1" : "0", len);
12685  free_user(vmu);
12686  return 0;
12687  }
12688 
12689  if (vmu) {
12690  if (!strncasecmp(arg.attribute, "password", 8)) {
12691  ast_copy_string(buf, vmu->password, len);
12692  } else if (!strncasecmp(arg.attribute, "fullname", 8)) {
12693  ast_copy_string(buf, vmu->fullname, len);
12694  } else if (!strncasecmp(arg.attribute, "email", 5)) {
12695  ast_copy_string(buf, vmu->email, len);
12696  } else if (!strncasecmp(arg.attribute, "pager", 5)) {
12697  ast_copy_string(buf, vmu->pager, len);
12698  } else if (!strncasecmp(arg.attribute, "language", 8)) {
12700  } else if (!strncasecmp(arg.attribute, "locale", 6)) {
12701  ast_copy_string(buf, vmu->locale, len);
12702  } else if (!strncasecmp(arg.attribute, "tz", 2)) {
12703  ast_copy_string(buf, vmu->zonetag, len);
12704  } else if (!strncasecmp(arg.attribute, "count", 5)) {
12705  char *mailbox_id;
12706 
12707  mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
12708  sprintf(mailbox_id, "%s@%s", mailbox, context);/* Safe */
12709 
12710  /* If mbxfolder is empty messagecount will default to INBOX */
12711  res = messagecount(mailbox_id, arg.folder);
12712  if (res < 0) {
12713  ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
12714  free_user(vmu);
12715  return -1;
12716  }
12717  snprintf(buf, len, "%d", res);
12718  } else {
12719  ast_log(LOG_ERROR, "Unknown attribute '%s' for VM_INFO\n", arg.attribute);
12720  free_user(vmu);
12721  return -1;
12722  }
12723  free_user(vmu);
12724  }
12725 
12726  return 0;
12727 }
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 13649 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().

13650 {
13651  struct ast_vm_user *current;
13652  char *cat;
13653  const char *val;
13654  char *q, *stringp, *tmp;
13655  int x;
13656  unsigned int tmpadsi[4];
13657  char secretfn[PATH_MAX] = "";
13658  long tps_queue_low;
13659  long tps_queue_high;
13660 
13661 #ifdef IMAP_STORAGE
13662  ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
13663 #endif
13664  /* set audio control prompts */
13670 
13671 #ifdef IMAP_STORAGE
13672  ast_mwi_state_callback_all(imap_close_subscribed_mailbox, NULL);
13673 #endif
13674 
13675  /* Free all the users structure */
13676  free_vm_users();
13677 
13678  /* Free all the zones structure */
13679  free_vm_zones();
13680 
13681  /* Remove all aliases */
13684 
13685  AST_LIST_LOCK(&users);
13686 
13687  memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
13688  memset(ext_pass_check_cmd, 0, sizeof(ext_pass_check_cmd));
13689 
13690  if (cfg) {
13691  /* General settings */
13692 
13693  if (!(val = ast_variable_retrieve(cfg, "general", "userscontext")))
13694  val = "default";
13695  ast_copy_string(userscontext, val, sizeof(userscontext));
13696 
13697  aliasescontext[0] = '\0';
13698  val = ast_variable_retrieve(cfg, "general", "aliasescontext");
13699  ast_copy_string(aliasescontext, S_OR(val, ""), sizeof(aliasescontext));
13700 
13701  /* Attach voice message to mail message ? */
13702  if (!(val = ast_variable_retrieve(cfg, "general", "attach")))
13703  val = "yes";
13705 
13706  if (!(val = ast_variable_retrieve(cfg, "general", "searchcontexts")))
13707  val = "no";
13709 
13710  volgain = 0.0;
13711  if ((val = ast_variable_retrieve(cfg, "general", "volgain")))
13712  sscanf(val, "%30lf", &volgain);
13713 
13714 #ifdef ODBC_STORAGE
13715  strcpy(odbc_database, "asterisk");
13716  if ((val = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
13717  ast_copy_string(odbc_database, val, sizeof(odbc_database));
13718  }
13719  strcpy(odbc_table, "voicemessages");
13720  if ((val = ast_variable_retrieve(cfg, "general", "odbctable"))) {
13721  ast_copy_string(odbc_table, val, sizeof(odbc_table));
13722  }
13723 #endif
13724  /* Mail command */
13725  strcpy(mailcmd, SENDMAIL);
13726  if ((val = ast_variable_retrieve(cfg, "general", "mailcmd")))
13727  ast_copy_string(mailcmd, val, sizeof(mailcmd)); /* User setting */
13728 
13729  maxsilence = 0;
13730  if ((val = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
13731  maxsilence = atoi(val);
13732  if (maxsilence > 0)
13733  maxsilence *= 1000;
13734  }
13735 
13736  if (!(val = ast_variable_retrieve(cfg, "general", "maxmsg"))) {
13737  maxmsg = MAXMSG;
13738  } else {
13739  maxmsg = atoi(val);
13740  if (maxmsg < 0) {
13741  ast_log(AST_LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", val, MAXMSG);
13742  maxmsg = MAXMSG;
13743  } else if (maxmsg > MAXMSGLIMIT) {
13744  ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
13745  maxmsg = MAXMSGLIMIT;
13746  }
13747  }
13748 
13749  if (!(val = ast_variable_retrieve(cfg, "general", "backupdeleted"))) {
13750  maxdeletedmsg = 0;
13751  } else {
13752  if (sscanf(val, "%30d", &x) == 1)
13753  maxdeletedmsg = x;
13754  else if (ast_true(val))
13756  else
13757  maxdeletedmsg = 0;
13758 
13759  if (maxdeletedmsg < 0) {
13760  ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox '%s'. Using default value %i\n", val, MAXMSG);
13762  } else if (maxdeletedmsg > MAXMSGLIMIT) {
13763  ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
13765  }
13766  }
13767 
13768  /* Load date format config for voicemail mail */
13769  if ((val = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
13771  }
13772 
13773  /* Load date format config for voicemail pager mail */
13774  if ((val = ast_variable_retrieve(cfg, "general", "pagerdateformat"))) {
13776  }
13777 
13778  /* External password changing command */
13779  if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) {
13780  ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd));
13782  } else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) {
13783  ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd));
13785  }
13786 
13787  /* External password validation command */
13788  if ((val = ast_variable_retrieve(cfg, "general", "externpasscheck"))) {
13790  ast_debug(1, "found externpasscheck: %s\n", ext_pass_check_cmd);
13791  }
13792 
13793 #ifdef IMAP_STORAGE
13794  /* IMAP server address */
13795  if ((val = ast_variable_retrieve(cfg, "general", "imapserver"))) {
13796  ast_copy_string(imapserver, val, sizeof(imapserver));
13797  } else {
13798  ast_copy_string(imapserver, "localhost", sizeof(imapserver));
13799  }
13800  /* IMAP server port */
13801  if ((val = ast_variable_retrieve(cfg, "general", "imapport"))) {
13802  ast_copy_string(imapport, val, sizeof(imapport));
13803  } else {
13804  ast_copy_string(imapport, "143", sizeof(imapport));
13805  }
13806  /* IMAP server flags */
13807  if ((val = ast_variable_retrieve(cfg, "general", "imapflags"))) {
13808  ast_copy_string(imapflags, val, sizeof(imapflags));
13809  }
13810  /* IMAP server master username */
13811  if ((val = ast_variable_retrieve(cfg, "general", "authuser"))) {
13812  ast_copy_string(authuser, val, sizeof(authuser));
13813  }
13814  /* IMAP server master password */
13815  if ((val = ast_variable_retrieve(cfg, "general", "authpassword"))) {
13816  ast_copy_string(authpassword, val, sizeof(authpassword));
13817  }
13818  /* Expunge on exit */
13819  if ((val = ast_variable_retrieve(cfg, "general", "expungeonhangup"))) {
13820  if (ast_false(val))
13821  expungeonhangup = 0;
13822  else
13823  expungeonhangup = 1;
13824  } else {
13825  expungeonhangup = 1;
13826  }
13827  /* IMAP voicemail folder */
13828  if ((val = ast_variable_retrieve(cfg, "general", "imapfolder"))) {
13829  ast_copy_string(imapfolder, val, sizeof(imapfolder));
13830  } else {
13831  ast_copy_string(imapfolder, "INBOX", sizeof(imapfolder));
13832  }
13833  if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) {
13834  ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder));
13835  }
13836  if ((val = ast_variable_retrieve(cfg, "general", "imapgreetings"))) {
13837  imapgreetings = ast_true(val);
13838  } else {
13839  imapgreetings = 0;
13840  }
13841  if ((val = ast_variable_retrieve(cfg, "general", "greetingfolder"))) {
13842  ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
13843  } else if ((val = ast_variable_retrieve(cfg, "general", "greetingsfolder"))) {
13844  /* Also support greetingsfolder as documented in voicemail.conf.sample */
13845  ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
13846  } else {
13847  ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder));
13848  }
13849  if ((val = ast_variable_retrieve(cfg, "general", "imap_poll_logout"))) {
13850  imap_poll_logout = ast_true(val);
13851  } else {
13852  imap_poll_logout = 0;
13853  }
13854 
13855  /* There is some very unorthodox casting done here. This is due
13856  * to the way c-client handles the argument passed in. It expects a
13857  * void pointer and casts the pointer directly to a long without
13858  * first dereferencing it. */
13859  if ((val = ast_variable_retrieve(cfg, "general", "imapreadtimeout"))) {
13860  mail_parameters(NIL, SET_READTIMEOUT, (void *) (atol(val)));
13861  } else {
13862  mail_parameters(NIL, SET_READTIMEOUT, (void *) 60L);
13863  }
13864 
13865  if ((val = ast_variable_retrieve(cfg, "general", "imapwritetimeout"))) {
13866  mail_parameters(NIL, SET_WRITETIMEOUT, (void *) (atol(val)));
13867  } else {
13868  mail_parameters(NIL, SET_WRITETIMEOUT, (void *) 60L);
13869  }
13870 
13871  if ((val = ast_variable_retrieve(cfg, "general", "imapopentimeout"))) {
13872  mail_parameters(NIL, SET_OPENTIMEOUT, (void *) (atol(val)));
13873  } else {
13874  mail_parameters(NIL, SET_OPENTIMEOUT, (void *) 60L);
13875  }
13876 
13877  if ((val = ast_variable_retrieve(cfg, "general", "imapclosetimeout"))) {
13878  mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) (atol(val)));
13879  } else {
13880  mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L);
13881  }
13882 
13883  /* Increment configuration version */
13884  imapversion++;
13885 #endif
13886  /* External voicemail notify application */
13887  if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
13888  ast_copy_string(externnotify, val, sizeof(externnotify));
13889  ast_debug(1, "found externnotify: %s\n", externnotify);
13890  } else {
13891  externnotify[0] = '\0';
13892  }
13893 
13894  /* SMDI voicemail notification */
13895  if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
13896  ast_debug(1, "Enabled SMDI voicemail notification\n");
13897  if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
13899  } else {
13900  ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
13901  smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
13902  }
13903  if (!smdi_iface) {
13904  ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
13905  }
13906  }
13907 
13908  /* Silence treshold */
13910  if ((val = ast_variable_retrieve(cfg, "general", "silencethreshold")))
13911  silencethreshold = atoi(val);
13912 
13913  if (!(val = ast_variable_retrieve(cfg, "general", "serveremail")))
13914  val = ASTERISK_USERNAME;
13915  ast_copy_string(serveremail, val, sizeof(serveremail));
13916 
13917  vmmaxsecs = 0;
13918  if ((val = ast_variable_retrieve(cfg, "general", "maxsecs"))) {
13919  if (sscanf(val, "%30d", &x) == 1) {
13920  vmmaxsecs = x;
13921  } else {
13922  ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
13923  }
13924  } else if ((val = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
13925  static int maxmessage_deprecate = 0;
13926  if (maxmessage_deprecate == 0) {
13927  maxmessage_deprecate = 1;
13928  ast_log(AST_LOG_WARNING, "Setting 'maxmessage' has been deprecated in favor of 'maxsecs'.\n");
13929  }
13930  if (sscanf(val, "%30d", &x) == 1) {
13931  vmmaxsecs = x;
13932  } else {
13933  ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
13934  }
13935  }
13936 
13937  vmminsecs = 0;
13938  if ((val = ast_variable_retrieve(cfg, "general", "minsecs"))) {
13939  if (sscanf(val, "%30d", &x) == 1) {
13940  vmminsecs = x;
13941  if (maxsilence / 1000 >= vmminsecs) {
13942  ast_log(AST_LOG_WARNING, "maxsilence should be less than minsecs or you may get empty messages\n");
13943  }
13944  } else {
13945  ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
13946  }
13947  } else if ((val = ast_variable_retrieve(cfg, "general", "minmessage"))) {
13948  static int maxmessage_deprecate = 0;
13949  if (maxmessage_deprecate == 0) {
13950  maxmessage_deprecate = 1;
13951  ast_log(AST_LOG_WARNING, "Setting 'minmessage' has been deprecated in favor of 'minsecs'.\n");
13952  }
13953  if (sscanf(val, "%30d", &x) == 1) {
13954  vmminsecs = x;
13955  if (maxsilence / 1000 >= vmminsecs) {
13956  ast_log(AST_LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
13957  }
13958  } else {
13959  ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
13960  }
13961  }
13962 
13963  val = ast_variable_retrieve(cfg, "general", "format");
13964  if (!val) {
13965  val = "wav";
13966  } else {
13967  tmp = ast_strdupa(val);
13968  val = ast_format_str_reduce(tmp);
13969  if (!val) {
13970  ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n");
13971  val = "wav";
13972  }
13973  }
13974  ast_copy_string(vmfmts, val, sizeof(vmfmts));
13975 
13976  skipms = 3000;
13977  if ((val = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
13978  if (sscanf(val, "%30d", &x) == 1) {
13979  maxgreet = x;
13980  } else {
13981  ast_log(AST_LOG_WARNING, "Invalid max message greeting length\n");
13982  }
13983  }
13984 
13985  if ((val = ast_variable_retrieve(cfg, "general", "skipms"))) {
13986  if (sscanf(val, "%30d", &x) == 1) {
13987  skipms = x;
13988  } else {
13989  ast_log(AST_LOG_WARNING, "Invalid skipms value\n");
13990  }
13991  }
13992 
13993  maxlogins = 3;
13994  if ((val = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
13995  if (sscanf(val, "%30d", &x) == 1) {
13996  maxlogins = x;
13997  } else {
13998  ast_log(AST_LOG_WARNING, "Invalid max failed login attempts\n");
13999  }
14000  }
14001 
14003  if ((val = ast_variable_retrieve(cfg, "general", "minpassword"))) {
14004  if (sscanf(val, "%30d", &x) == 1) {
14005  minpassword = x;
14006  } else {
14007  ast_log(AST_LOG_WARNING, "Invalid minimum password length. Default to %d\n", minpassword);
14008  }
14009  }
14010 
14011  /* Force new user to record name ? */
14012  if (!(val = ast_variable_retrieve(cfg, "general", "forcename")))
14013  val = "no";
14015 
14016  /* Force new user to record greetings ? */
14017  if (!(val = ast_variable_retrieve(cfg, "general", "forcegreetings")))
14018  val = "no";
14020 
14021  if ((val = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) {
14022  ast_debug(1, "VM_CID Internal context string: %s\n", val);
14023  stringp = ast_strdupa(val);
14024  for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
14025  if (!ast_strlen_zero(stringp)) {
14026  q = strsep(&stringp, ",");
14027  while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
14028  q++;
14030  ast_debug(1, "VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
14031  } else {
14032  cidinternalcontexts[x][0] = '\0';
14033  }
14034  }
14035  }
14036  if (!(val = ast_variable_retrieve(cfg, "general", "review"))){
14037  ast_debug(1, "VM Review Option disabled globally\n");
14038  val = "no";
14039  }
14041 
14042  /* Temporary greeting reminder */
14043  if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
14044  ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n");
14045  val = "no";
14046  } else {
14047  ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n");
14048  }
14050  if (!(val = ast_variable_retrieve(cfg, "general", "messagewrap"))){
14051  ast_debug(1, "VM next message wrap disabled globally\n");
14052  val = "no";
14053  }
14055 
14056  if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){
14057  ast_debug(1, "VM Operator break disabled globally\n");
14058  val = "no";
14059  }
14061 
14062  if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) {
14063  ast_debug(1, "VM CID Info before msg disabled globally\n");
14064  val = "no";
14065  }
14067 
14068  if (!(val = ast_variable_retrieve(cfg, "general", "sendvoicemail"))){
14069  ast_debug(1, "Send Voicemail msg disabled globally\n");
14070  val = "no";
14071  }
14073 
14074  if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) {
14075  ast_debug(1, "ENVELOPE before msg enabled globally\n");
14076  val = "yes";
14077  }
14079 
14080  if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) {
14081  ast_debug(1, "Move Heard enabled globally\n");
14082  val = "yes";
14083  }
14085 
14086  if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) {
14087  ast_debug(1, "Autoset of Urgent flag on forwarded Urgent messages disabled globally\n");
14088  val = "no";
14089  }
14091 
14092  if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
14093  ast_debug(1, "Duration info before msg enabled globally\n");
14094  val = "yes";
14095  }
14097 
14098  saydurationminfo = 2;
14099  if ((val = ast_variable_retrieve(cfg, "general", "saydurationm"))) {
14100  if (sscanf(val, "%30d", &x) == 1) {
14101  saydurationminfo = x;
14102  } else {
14103  ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
14104  }
14105  }
14106 
14107  if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
14108  ast_debug(1, "We are not going to skip to the next msg after save/delete\n");
14109  val = "no";
14110  }
14112 
14113  if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) {
14114  ast_copy_string(dialcontext, val, sizeof(dialcontext));
14115  ast_debug(1, "found dialout context: %s\n", dialcontext);
14116  } else {
14117  dialcontext[0] = '\0';
14118  }
14119 
14120  if ((val = ast_variable_retrieve(cfg, "general", "callback"))) {
14121  ast_copy_string(callcontext, val, sizeof(callcontext));
14122  ast_debug(1, "found callback context: %s\n", callcontext);
14123  } else {
14124  callcontext[0] = '\0';
14125  }
14126 
14127  if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
14128  ast_copy_string(exitcontext, val, sizeof(exitcontext));
14129  ast_debug(1, "found operator context: %s\n", exitcontext);
14130  } else {
14131  exitcontext[0] = '\0';
14132  }
14133 
14134  /* load password sounds configuration */
14135  if ((val = ast_variable_retrieve(cfg, "general", "vm-login")))
14136  ast_copy_string(vm_login, val, sizeof(vm_login));
14137  if ((val = ast_variable_retrieve(cfg, "general", "vm-newuser")))
14138  ast_copy_string(vm_newuser, val, sizeof(vm_newuser));
14139  if ((val = ast_variable_retrieve(cfg, "general", "vm-password")))
14140  ast_copy_string(vm_password, val, sizeof(vm_password));
14141  if ((val = ast_variable_retrieve(cfg, "general", "vm-newpassword")))
14143  if ((val = ast_variable_retrieve(cfg, "general", "vm-invalid-password")))
14145  if ((val = ast_variable_retrieve(cfg, "general", "vm-passchanged")))
14147  if ((val = ast_variable_retrieve(cfg, "general", "vm-reenterpassword")))
14149  if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
14150  ast_copy_string(vm_mismatch, val, sizeof(vm_mismatch));
14151  if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
14153  }
14154  if ((val = ast_variable_retrieve(cfg, "general", "vm-prepend-timeout"))) {
14156  }
14157  /* load configurable audio prompts */
14158  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
14160  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val))
14162  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val))
14164  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val))
14166  if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val))
14168 
14169  if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory")))
14170  val = "no";
14172 
14173  if (!(val = ast_variable_retrieve(cfg, "general", "passwordlocation"))) {
14174  val = "voicemail.conf";
14175  }
14176  if (!(strcmp(val, "spooldir"))) {
14178  } else {
14180  }
14181 
14183  if ((val = ast_variable_retrieve(cfg, "general", "pollfreq"))) {
14184  if (sscanf(val, "%30u", &poll_freq) != 1) {
14186  ast_log(AST_LOG_ERROR, "'%s' is not a valid value for the pollfreq option!\n", val);
14187  }
14188  }
14189 
14190  poll_mailboxes = 0;
14191  if ((val = ast_variable_retrieve(cfg, "general", "pollmailboxes")))
14192  poll_mailboxes = ast_true(val);
14193 
14194  memset(fromstring, 0, sizeof(fromstring));
14195  memset(pagerfromstring, 0, sizeof(pagerfromstring));
14196  strcpy(charset, "ISO-8859-1");
14197  if (emailbody) {
14199  emailbody = NULL;
14200  }
14201  if (emailsubject) {
14203  emailsubject = NULL;
14204  }
14205  if (pagerbody) {
14207  pagerbody = NULL;
14208  }
14209  if (pagersubject) {
14211  pagersubject = NULL;
14212  }
14213  if ((val = ast_variable_retrieve(cfg, "general", "pbxskip")))
14215  if ((val = ast_variable_retrieve(cfg, "general", "fromstring")))
14216  ast_copy_string(fromstring, val, sizeof(fromstring));
14217  if ((val = ast_variable_retrieve(cfg, "general", "pagerfromstring")))
14219  if ((val = ast_variable_retrieve(cfg, "general", "charset")))
14220  ast_copy_string(charset, val, sizeof(charset));
14221  if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
14222  sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14223  for (x = 0; x < 4; x++) {
14224  memcpy(&adsifdn[x], &tmpadsi[x], 1);
14225  }
14226  }
14227  if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) {
14228  sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14229  for (x = 0; x < 4; x++) {
14230  memcpy(&adsisec[x], &tmpadsi[x], 1);
14231  }
14232  }
14233  if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) {
14234  if (atoi(val)) {
14235  adsiver = atoi(val);
14236  }
14237  }
14238  if ((val = ast_variable_retrieve(cfg, "general", "tz"))) {
14239  ast_copy_string(zonetag, val, sizeof(zonetag));
14240  }
14241  if ((val = ast_variable_retrieve(cfg, "general", "locale"))) {
14242  ast_copy_string(locale, val, sizeof(locale));
14243  }
14244  if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) {
14246  }
14247  if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
14249  }
14250  if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
14252  }
14253  if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
14255  }
14256 
14257  tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14258  if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_high"))) {
14259  if (sscanf(val, "%30ld", &tps_queue_high) != 1 || tps_queue_high <= 0) {
14260  ast_log(AST_LOG_WARNING, "Invalid the taskprocessor high water alert trigger level '%s'\n", val);
14261  tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14262  }
14263  }
14264  tps_queue_low = -1;
14265  if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_low"))) {
14266  if (sscanf(val, "%30ld", &tps_queue_low) != 1 ||
14267  tps_queue_low < -1 || tps_queue_high < tps_queue_low) {
14268  ast_log(AST_LOG_WARNING, "Invalid the taskprocessor low water clear alert level '%s'\n", val);
14269  tps_queue_low = -1;
14270  }
14271  }
14272  if (ast_taskprocessor_alert_set_levels(mwi_subscription_tps, tps_queue_low, tps_queue_high)) {
14273  ast_log(AST_LOG_WARNING, "Failed to set alert levels for voicemail taskprocessor.\n");
14274  }
14275 
14276  /* load mailboxes from users.conf */
14277  if (ucfg) {
14278  for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
14279  if (!strcasecmp(cat, "general")) {
14280  continue;
14281  }
14282  if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
14283  continue;
14284  if ((current = find_or_create(userscontext, cat))) {
14285  populate_defaults(current);
14286  apply_options_full(current, ast_variable_browse(ucfg, cat));
14287  ast_copy_string(current->context, userscontext, sizeof(current->context));
14288  if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) {
14290  }
14291 
14292  switch (current->passwordlocation) {
14293  case OPT_PWLOC_SPOOLDIR:
14294  snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox);
14295  read_password_from_file(secretfn, current->password, sizeof(current->password));
14296  }
14297  }
14298  }
14299  }
14300 
14301  /* load mailboxes from voicemail.conf */
14302 
14303  /*
14304  * Aliases must be loaded before users or the aliases won't be notified
14305  * if there's existing voicemail in the user mailbox.
14306  */
14307  load_aliases(cfg);
14308 
14309  load_zonemessages(cfg);
14310 
14311  load_users(cfg);
14312 
14314 
14318  stop_poll_thread();;
14319 
14320  return 0;
14321  } else {
14323  ast_log(AST_LOG_WARNING, "Failed to load configuration file.\n");
14324  return 0;
14325  }
14326 }
#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:1821
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:1838
#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 5359 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().

5360 {
5361  char fname[PATH_MAX] = "";
5362  char sox_gain_tmpdir[PATH_MAX];
5363  char *file_to_delete = NULL, *dir_to_delete = NULL;
5364  int res;
5365  char altfname[PATH_MAX] = "";
5366  int altused = 0;
5367  char altformat[80] = "";
5368  char *c = NULL;
5369 
5370  /* Eww. We want formats to tell us their own MIME type */
5371  char *mime_type = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
5372 
5373  /* Users of multiple file formats need special attention. */
5374  snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5375  if (!ast_file_is_readable(fname)) {
5376  ast_copy_string(altformat, vmfmts, sizeof(altformat));
5377  c = strchr(altformat, '|');
5378  if (c) {
5379  *c = '\0';
5380  }
5381  ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - trying first/alternate format %s\n", fname, strerror(errno), altformat);
5382  snprintf(altfname, sizeof(altfname), "%s.%s", attach, altformat);
5383  if (!ast_file_is_readable(altfname)) {
5384  ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - alternate format %s failure\n", altfname, strerror(errno), altformat);
5385  } else {
5386  altused = 1;
5387  }
5388  }
5389 
5390  /* This 'while' loop will only execute once. We use it so that we can 'break' */
5391  while (vmu->volgain < -.001 || vmu->volgain > .001 || altused) {
5392  char tmpdir[PATH_MAX];
5393 
5394  create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
5395 
5396  res = snprintf(sox_gain_tmpdir, sizeof(sox_gain_tmpdir), "%s/vm-gain-XXXXXX", tmpdir);
5397  if (res >= sizeof(sox_gain_tmpdir)) {
5398  ast_log(LOG_ERROR, "Failed to create temporary directory path %s: Out of buffer space\n", tmpdir);
5399  break;
5400  }
5401 
5402  if (mkdtemp(sox_gain_tmpdir)) {
5403  int soxstatus = 0;
5404  char sox_gain_cmd[PATH_MAX];
5405 
5406  ast_debug(3, "sox_gain_tmpdir: %s\n", sox_gain_tmpdir);
5407 
5408  /* Save for later */
5409  dir_to_delete = sox_gain_tmpdir;
5410 
5411  res = snprintf(fname, sizeof(fname), "%s/output.%s", sox_gain_tmpdir, format);
5412  if (res >= sizeof(fname)) {
5413  ast_log(LOG_ERROR, "Failed to create filename buffer for %s/output.%s: Too long\n", sox_gain_tmpdir, format);
5414  break;
5415  }
5416 
5417  if (!altused) {
5418  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5419  vmu->volgain, attach, format, fname);
5420  } else {
5421  if (!strcasecmp(format, "wav")) {
5422  if (vmu->volgain < -.001 || vmu->volgain > .001) {
5423  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s -e signed-integer -b 16 %s",
5424  vmu->volgain, attach, altformat, fname);
5425  } else {
5426  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s -e signed-integer -b 16 %s",
5427  attach, altformat, fname);
5428  }
5429  } else {
5430  if (vmu->volgain < -.001 || vmu->volgain > .001) {
5431  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5432  vmu->volgain, attach, altformat, fname);
5433  } else {
5434  res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s %s",
5435  attach, altformat, fname);
5436  }
5437  }
5438  }
5439 
5440  if (res >= sizeof(sox_gain_cmd)) {
5441  ast_log(LOG_ERROR, "Failed to generate sox command, out of buffer space\n");
5442  break;
5443  }
5444 
5445  soxstatus = ast_safe_system(sox_gain_cmd);
5446  if (!soxstatus) {
5447  /* Save for later */
5448  file_to_delete = fname;
5449  ast_debug(3, "VOLGAIN: Stored at: %s - Level: %.4f - Mailbox: %s\n", fname, vmu->volgain, mailbox);
5450  } else {
5451  ast_log(LOG_WARNING, "Sox failed to re-encode %s: %s (have you installed support for all sox file formats?)\n",
5452  fname,
5453  soxstatus == 1 ? "Problem with command line options" : "An error occurred during file processing");
5454  ast_log(LOG_WARNING, "Voicemail attachment will have no volume gain.\n");
5455  }
5456  }
5457 
5458  break;
5459  }
5460 
5461  if (!file_to_delete) {
5462  res = snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5463  if (res >= sizeof(fname)) {
5464  ast_log(LOG_ERROR, "Failed to create filename buffer for %s.%s: Too long\n", attach, format);
5465  return -1;
5466  }
5467  }
5468 
5469  fprintf(p, "--%s" ENDL, bound);
5470  if (msgnum > -1)
5471  fprintf(p, "Content-Type: %s%s; name=\"%s\"" ENDL, mime_type, format, filename);
5472  else
5473  fprintf(p, "Content-Type: %s%s; name=\"%s.%s\"" ENDL, mime_type, format, greeting_attachment, format);
5474  fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
5475  fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
5476  if (msgnum > -1)
5477  fprintf(p, "Content-Disposition: attachment; filename=\"%s\"" ENDL ENDL, filename);
5478  else
5479  fprintf(p, "Content-Disposition: attachment; filename=\"%s.%s\"" ENDL ENDL, greeting_attachment, format);
5480  base_encode(fname, p);
5481  if (last)
5482  fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound);
5483 
5484  if (file_to_delete) {
5485  unlink(file_to_delete);
5486  }
5487 
5488  if (dir_to_delete) {
5489  rmdir(dir_to_delete);
5490  }
5491 
5492  return 0;
5493 }
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:2725
#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 12325 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().

12326 {
12327  struct ast_variable *var;
12328  struct ast_category *cat;
12329  generate_msg_id(id);
12330 
12331  var = ast_variable_new("msg_id", id, "");
12332  if (!var) {
12333  return -1;
12334  }
12335 
12336  cat = ast_category_get(msg_cfg, "message", NULL);
12337  if (!cat) {
12338  ast_log(LOG_ERROR, "Voicemail data file %s/%d.txt has no [message] category?\n", dir, msg);
12339  ast_variables_destroy(var);
12340  return -1;
12341  }
12342 
12343  ast_variable_append(cat, var);
12344 
12345  if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
12346  ast_log(LOG_WARNING, "Unable to update %s to have a message ID\n", filename);
12347  return -1;
12348  }
12349 
12350  UPDATE_MSG_ID(dir, msg, id, vmu, msg_cfg, folder);
12351  return 0;
12352 }
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 7428 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().

7429 {
7430  int x;
7431  if (!ast_adsi_available(chan))
7432  return;
7433  x = ast_adsi_load_session(chan, adsifdn, adsiver, 1);
7434  if (x < 0)
7435  return;
7436  if (!x) {
7437  if (adsi_load_vmail(chan, useadsi)) {
7438  ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n");
7439  return;
7440  }
7441  } else
7442  *useadsi = 1;
7443 }
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 7624 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().

7625 {
7626  int bytes = 0;
7627  unsigned char buf[256];
7628  unsigned char keys[8];
7629 
7630  int x;
7631 
7632  if (!ast_adsi_available(chan))
7633  return;
7634 
7635  /* New meaning for keys */
7636  for (x = 0; x < 5; x++)
7637  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7638 
7639  keys[6] = 0x0;
7640  keys[7] = 0x0;
7641 
7642  if (!vms->curmsg) {
7643  /* No prev key, provide "Folder" instead */
7644  keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7645  }
7646  if (vms->curmsg >= vms->lastmsg) {
7647  /* If last message ... */
7648  if (vms->curmsg) {
7649  /* but not only message, provide "Folder" instead */
7650  keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7651  } else {
7652  /* Otherwise if only message, leave blank */
7653  keys[3] = 1;
7654  }
7655  }
7656 
7657  /* If deleted, show "undeleted" */
7658 #ifdef IMAP_STORAGE
7659  ast_mutex_lock(&vms->lock);
7660 #endif
7661  if (vms->deleted[vms->curmsg]) {
7662  keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7663  }
7664 #ifdef IMAP_STORAGE
7665  ast_mutex_unlock(&vms->lock);
7666 #endif
7667 
7668  /* Except "Exit" */
7669  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7670  bytes += ast_adsi_set_keys(buf + bytes, keys);
7671  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7672 
7673  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7674 }
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 7493 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().

7494 {
7495  unsigned char buf[256];
7496  int bytes = 0;
7497  unsigned char keys[8];
7498  int x, y;
7499 
7500  if (!ast_adsi_available(chan))
7501  return;
7502 
7503  for (x = 0; x < 5; x++) {
7504  y = ADSI_KEY_APPS + 12 + start + x;
7505  if (y > ADSI_KEY_APPS + 12 + 4)
7506  y = 0;
7507  keys[x] = ADSI_KEY_SKT | y;
7508  }
7509  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17);
7510  keys[6] = 0;
7511  keys[7] = 0;
7512 
7513  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, "");
7514  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
7515  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7516  bytes += ast_adsi_set_keys(buf + bytes, keys);
7517  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7518 
7519  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7520 }
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 7779 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().

7780 {
7781  unsigned char buf[256];
7782  int bytes = 0;
7783 
7784  if (!ast_adsi_available(chan))
7785  return;
7786  bytes += adsi_logo(buf + bytes);
7787  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
7788  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
7789  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7790  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7791 
7792  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7793 }
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 7299 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().

7300 {
7301  unsigned char buf[256];
7302  int bytes = 0;
7303  int x;
7304  char num[5];
7305 
7306  *useadsi = 0;
7307  bytes += ast_adsi_data_mode(buf + bytes);
7308  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7309 
7310  bytes = 0;
7311  bytes += adsi_logo(buf);
7312  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7313 #ifdef DISPLAY
7314  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .", "");
7315 #endif
7316  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7317  bytes += ast_adsi_data_mode(buf + bytes);
7318  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7319 
7321  bytes = 0;
7322  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", "");
7323  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7324  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7325  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7326  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7327  return 0;
7328  }
7329 
7330 #ifdef DISPLAY
7331  /* Add a dot */
7332  bytes = 0;
7333  bytes += ast_adsi_logo(buf);
7334  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7335  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ..", "");
7336  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7337  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7338 #endif
7339  bytes = 0;
7340  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1);
7341  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1);
7342  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advnced", "3", 1);
7343  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1);
7344  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1);
7345  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1);
7346  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7347 
7348 #ifdef DISPLAY
7349  /* Add another dot */
7350  bytes = 0;
7351  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ...", "");
7352  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7353 
7354  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7355  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7356 #endif
7357 
7358  bytes = 0;
7359  /* These buttons we load but don't use yet */
7360  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 6, "Previous", "Prev", "4", 1);
7361  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 8, "Repeat", "Repeat", "5", 1);
7362  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 7, "Delete", "Delete", "7", 1);
7363  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 9, "Next", "Next", "6", 1);
7364  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 10, "Save", "Save", "9", 1);
7365  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 11, "Undelete", "Restore", "7", 1);
7366  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7367 
7368 #ifdef DISPLAY
7369  /* Add another dot */
7370  bytes = 0;
7371  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ....", "");
7372  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7373  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7374 #endif
7375 
7376  bytes = 0;
7377  for (x = 0; x < 5; x++) {
7378  snprintf(num, sizeof(num), "%d", x);
7379  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(NULL, x), mbox(NULL, x), num, 1);
7380  }
7381  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + 5, "Cancel", "Cancel", "#", 1);
7382  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7383 
7384 #ifdef DISPLAY
7385  /* Add another dot */
7386  bytes = 0;
7387  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .....", "");
7388  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7389  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7390 #endif
7391 
7392  if (ast_adsi_end_download(chan)) {
7393  bytes = 0;
7394  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Download Unsuccessful.", "");
7395  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7396  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7397  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7398  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7399  return 0;
7400  }
7401  bytes = 0;
7402  bytes += ast_adsi_download_disconnect(buf + bytes);
7403  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7404  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
7405 
7406  ast_debug(1, "Done downloading scripts...\n");
7407 
7408 #ifdef DISPLAY
7409  /* Add last dot */
7410  bytes = 0;
7411  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
7412  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7413 #endif
7414  ast_debug(1, "Restarting session...\n");
7415 
7416  bytes = 0;
7417  /* Load the session now */
7418  if (ast_adsi_load_session(chan, adsifdn, adsiver, 1) == 1) {
7419  *useadsi = 1;
7420  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", "");
7421  } else
7422  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Failed!", "");
7423 
7424  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7425  return 0;
7426 }
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 7445 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().

7446 {
7447  unsigned char buf[256];
7448  int bytes = 0;
7449  unsigned char keys[8];
7450  int x;
7451  if (!ast_adsi_available(chan))
7452  return;
7453 
7454  for (x = 0; x < 8; x++)
7455  keys[x] = 0;
7456  /* Set one key for next */
7457  keys[3] = ADSI_KEY_APPS + 3;
7458 
7459  bytes += adsi_logo(buf + bytes);
7460  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, " ", "");
7461  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ", "");
7462  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7463  bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Mailbox: ******", "");
7464  bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 1, 1, ADSI_JUST_LEFT);
7465  bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Enter", "Enter", "#", 1);
7466  bytes += ast_adsi_set_keys(buf + bytes, keys);
7467  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7468  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7469 }
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 7291 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().

7292 {
7293  int bytes = 0;
7294  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
7295  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
7296  return bytes;
7297 }
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 7522 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().

7523 {
7524  int bytes = 0;
7525  unsigned char buf[256];
7526  char buf1[256], buf2[256];
7527  char fn2[PATH_MAX];
7528 
7529  char cid[256] = "";
7530  char *val;
7531  char *name, *num;
7532  char datetime[21] = "";
7533  FILE *f;
7534 
7535  unsigned char keys[8];
7536 
7537  int x;
7538 
7539  if (!ast_adsi_available(chan))
7540  return;
7541 
7542  /* Retrieve important info */
7543  snprintf(fn2, sizeof(fn2), "%s.txt", vms->fn);
7544  f = fopen(fn2, "r");
7545  if (f) {
7546  while (!feof(f)) {
7547  if (!fgets((char *) buf, sizeof(buf), f)) {
7548  continue;
7549  }
7550  if (!feof(f)) {
7551  char *stringp = NULL;
7552  stringp = (char *) buf;
7553  strsep(&stringp, "=");
7554  val = strsep(&stringp, "=");
7555  if (!ast_strlen_zero(val)) {
7556  if (!strcmp((char *) buf, "callerid"))
7557  ast_copy_string(cid, val, sizeof(cid));
7558  if (!strcmp((char *) buf, "origdate"))
7559  ast_copy_string(datetime, val, sizeof(datetime));
7560  }
7561  }
7562  }
7563  fclose(f);
7564  }
7565  /* New meaning for keys */
7566  for (x = 0; x < 5; x++)
7567  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7568  keys[6] = 0x0;
7569  keys[7] = 0x0;
7570 
7571  if (!vms->curmsg) {
7572  /* No prev key, provide "Folder" instead */
7573  keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7574  }
7575  if (vms->curmsg >= vms->lastmsg) {
7576  /* If last message ... */
7577  if (vms->curmsg) {
7578  /* but not only message, provide "Folder" instead */
7579  keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7580  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7581 
7582  } else {
7583  /* Otherwise if only message, leave blank */
7584  keys[3] = 1;
7585  }
7586  }
7587 
7588  if (!ast_strlen_zero(cid)) {
7589  ast_callerid_parse(cid, &name, &num);
7590  if (!name)
7591  name = num;
7592  } else {
7593  name = "Unknown Caller";
7594  }
7595 
7596  /* If deleted, show "undeleted" */
7597 #ifdef IMAP_STORAGE
7598  ast_mutex_lock(&vms->lock);
7599 #endif
7600  if (vms->deleted[vms->curmsg]) {
7601  keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7602  }
7603 #ifdef IMAP_STORAGE
7604  ast_mutex_unlock(&vms->lock);
7605 #endif
7606 
7607  /* Except "Exit" */
7608  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7609  snprintf(buf1, sizeof(buf1), "%s%s", vms->curbox,
7610  strcasecmp(vms->curbox, "INBOX") ? " Messages" : "");
7611  snprintf(buf2, sizeof(buf2), "Message %d of %d", vms->curmsg + 1, vms->lastmsg + 1);
7612 
7613  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7614  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7615  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, name, "");
7616  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, datetime, "");
7617  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7618  bytes += ast_adsi_set_keys(buf + bytes, keys);
7619  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7620 
7621  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7622 }
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 7471 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().

7472 {
7473  unsigned char buf[256];
7474  int bytes = 0;
7475  unsigned char keys[8];
7476  int x;
7477  if (!ast_adsi_available(chan))
7478  return;
7479 
7480  for (x = 0; x < 8; x++)
7481  keys[x] = 0;
7482  /* Set one key for next */
7483  keys[3] = ADSI_KEY_APPS + 3;
7484 
7485  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7486  bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
7487  bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
7488  bytes += ast_adsi_set_keys(buf + bytes, keys);
7489  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7490  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7491 }
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 7676 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().

7677 {
7678  unsigned char buf[256] = "";
7679  char buf1[256] = "", buf2[256] = "";
7680  int bytes = 0;
7681  unsigned char keys[8];
7682  int x;
7683 
7684  char *newm = (vms->newmessages == 1) ? "message" : "messages";
7685  char *oldm = (vms->oldmessages == 1) ? "message" : "messages";
7686  if (!ast_adsi_available(chan))
7687  return;
7688  if (vms->newmessages) {
7689  snprintf(buf1, sizeof(buf1), "You have %d new", vms->newmessages);
7690  if (vms->oldmessages) {
7691  strncat(buf1, " and", sizeof(buf1) - strlen(buf1) - 1);
7692  snprintf(buf2, sizeof(buf2), "%d old %s.", vms->oldmessages, oldm);
7693  } else {
7694  snprintf(buf2, sizeof(buf2), "%s.", newm);
7695  }
7696  } else if (vms->oldmessages) {
7697  snprintf(buf1, sizeof(buf1), "You have %d old", vms->oldmessages);
7698  snprintf(buf2, sizeof(buf2), "%s.", oldm);
7699  } else {
7700  strcpy(buf1, "You have no messages.");
7701  buf2[0] = ' ';
7702  buf2[1] = '\0';
7703  }
7704  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7705  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7706  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7707 
7708  for (x = 0; x < 6; x++)
7709  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7710  keys[6] = 0;
7711  keys[7] = 0;
7712 
7713  /* Don't let them listen if there are none */
7714  if (vms->lastmsg < 0)
7715  keys[0] = 1;
7716  bytes += ast_adsi_set_keys(buf + bytes, keys);
7717 
7718  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7719 
7720  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7721 }
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 7723 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().

7724 {
7725  unsigned char buf[256] = "";
7726  char buf1[256] = "", buf2[256] = "";
7727  int bytes = 0;
7728  unsigned char keys[8];
7729  int x;
7730 
7731  char *mess = (vms->lastmsg == 0) ? "message" : "messages";
7732 
7733  if (!ast_adsi_available(chan))
7734  return;
7735 
7736  /* Original command keys */
7737  for (x = 0; x < 6; x++)
7738  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7739 
7740  keys[6] = 0;
7741  keys[7] = 0;
7742 
7743  if ((vms->lastmsg + 1) < 1)
7744  keys[0] = 0;
7745 
7746  snprintf(buf1, sizeof(buf1), "%s%s has", vms->curbox,
7747  strcasecmp(vms->curbox, "INBOX") ? " folder" : "");
7748 
7749  if (vms->lastmsg + 1)
7750  snprintf(buf2, sizeof(buf2), "%d %s.", vms->lastmsg + 1, mess);
7751  else
7752  strcpy(buf2, "no messages.");
7753  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7754  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7755  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, "", "");
7756  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7757  bytes += ast_adsi_set_keys(buf + bytes, keys);
7758 
7759  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7760 
7761  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7762 
7763 }
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 15274 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().

15275 {
15276  int res = 0;
15277  char filename[PATH_MAX];
15278  struct ast_config *msg_cfg = NULL;
15279  const char *origtime, *context;
15280  char *name, *num;
15281  int retries = 0;
15282  char *cid;
15283  struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE, };
15284 
15285  vms->starting = 0;
15286 
15287  make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
15288 
15289  /* Retrieve info from VM attribute file */
15290  snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
15291  RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
15292  msg_cfg = ast_config_load(filename, config_flags);
15293  DISPOSE(vms->curdir, vms->curmsg);
15294  if (!valid_config(msg_cfg)) {
15295  ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
15296  return 0;
15297  }
15298 
15299  if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) {
15300  ast_config_destroy(msg_cfg);
15301  return 0;
15302  }
15303 
15304  cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid"));
15305 
15306  context = ast_variable_retrieve(msg_cfg, "message", "context");
15307  if (!strncasecmp("macro", context, 5)) /* Macro names in contexts are useless for our needs */
15308  context = ast_variable_retrieve(msg_cfg, "message", "macrocontext");
15309  switch (option) {
15310  case 3: /* Play message envelope */
15311  if (!res) {
15312  res = play_message_datetime(chan, vmu, origtime, filename);
15313  }
15314  if (!res) {
15315  res = play_message_callerid(chan, vms, cid, context, 0, 1);
15316  }
15317 
15318  res = 't';
15319  break;
15320 
15321  case 2: /* Call back */
15322 
15323  if (ast_strlen_zero(cid))
15324  break;
15325 
15326  ast_callerid_parse(cid, &name, &num);
15327  while ((res > -1) && (res != 't')) {
15328  switch (res) {
15329  case '1':
15330  if (num) {
15331  /* Dial the CID number */
15332  res = dialout(chan, vmu, num, vmu->callback);
15333  if (res) {
15334  ast_config_destroy(msg_cfg);
15335  return 9;
15336  }
15337  } else {
15338  res = '2';
15339  }
15340  break;
15341 
15342  case '2':
15343  /* Want to enter a different number, can only do this if there's a dialout context for this user */
15344  if (!ast_strlen_zero(vmu->dialout)) {
15345  res = dialout(chan, vmu, NULL, vmu->dialout);
15346  if (res) {
15347  ast_config_destroy(msg_cfg);
15348  return 9;
15349  }
15350  } else {
15351  ast_verb(3, "Caller can not specify callback number - no dialout context available\n");
15352  res = ast_play_and_wait(chan, "vm-sorry");
15353  }
15354  ast_config_destroy(msg_cfg);
15355  return res;
15356  case '*':
15357  res = 't';
15358  break;
15359  case '3':
15360  case '4':
15361  case '5':
15362  case '6':
15363  case '7':
15364  case '8':
15365  case '9':
15366  case '0':
15367 
15368  res = ast_play_and_wait(chan, "vm-sorry");
15369  retries++;
15370  break;
15371  default:
15372  if (num) {
15373  ast_verb(3, "Confirm CID number '%s' is number to use for callback\n", num);
15374  res = ast_play_and_wait(chan, "vm-num-i-have");
15375  if (!res)
15376  res = play_message_callerid(chan, vms, num, vmu->context, 1, 1);
15377  if (!res)
15378  res = ast_play_and_wait(chan, "vm-tocallnum");
15379  /* Only prompt for a caller-specified number if there is a dialout context specified */
15380  if (!ast_strlen_zero(vmu->dialout)) {
15381  if (!res)
15382  res = ast_play_and_wait(chan, "vm-calldiffnum");
15383  }
15384  } else {
15385  res = ast_play_and_wait(chan, "vm-nonumber");
15386  if (!ast_strlen_zero(vmu->dialout)) {
15387  if (!res)
15388  res = ast_play_and_wait(chan, "vm-toenternumber");
15389  }
15390  }
15391  if (!res) {
15392  res = ast_play_and_wait(chan, "vm-star-cancel");
15393  }
15394  if (!res) {
15395  res = ast_waitfordigit(chan, 6000);
15396  }
15397  if (!res) {
15398  retries++;
15399  if (retries > 3) {
15400  res = 't';
15401  }
15402  }
15403  ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
15404  isprint(res) ? res : '?', isprint(res) ? res : '?');
15405  break;
15406 
15407  }
15408  if (res == 't')
15409  res = 0;
15410  else if (res == '*')
15411  res = -1;
15412  }
15413  break;
15414 
15415  case 1: /* Reply */
15416  /* Send reply directly to sender */
15417  if (ast_strlen_zero(cid))
15418  break;
15419 
15420  ast_callerid_parse(cid, &name, &num);
15421  if (!num) {
15422  ast_verb(3, "No CID number available, no reply sent\n");
15423  if (!res)
15424  res = ast_play_and_wait(chan, "vm-nonumber");
15425  ast_config_destroy(msg_cfg);
15426  return res;
15427  } else {
15428  struct ast_vm_user vmu2, *vmu3;
15429  memset(&vmu2, 0, sizeof(vmu2));
15430  vmu3 = find_user(&vmu2, vmu->context, num);
15431  if (vmu3) {
15432  struct leave_vm_options leave_options;
15433  char mailbox[AST_MAX_EXTENSION * 2 + 2];
15434  snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context);
15435 
15436  ast_verb(3, "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
15437 
15438  memset(&leave_options, 0, sizeof(leave_options));
15439  leave_options.record_gain = record_gain;
15440  res = leave_voicemail(chan, mailbox, &leave_options);
15441  if (!res)
15442  res = 't';
15443  ast_config_destroy(msg_cfg);
15444  free_user(vmu3);
15445  return res;
15446  } else {
15447  /* Sender has no mailbox, can't reply */
15448  ast_verb(3, "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
15449  ast_play_and_wait(chan, "vm-nobox");
15450  res = 't';
15451  ast_config_destroy(msg_cfg);
15452  return res;
15453  }
15454  }
15455  res = 0;
15456 
15457  break;
15458  }
15459 
15460  ast_config_destroy(msg_cfg);
15461 
15462 #ifndef IMAP_STORAGE
15463  if (!res) {
15464  make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
15465  vms->heard[msg] = 1;
15466  res = wait_file(chan, vms, vms->fn);
15467  }
15468 #endif
15469  return res;
15470 }
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:3150
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 13557 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().

13558 {
13559  struct alias_mailbox_mapping *mapping;
13560  size_t from_len = strlen(alias) + 1;
13561  size_t to_len = strlen(mailbox) + 1;
13562 
13563  mapping = ao2_alloc(sizeof(*mapping) + from_len + to_len, NULL);
13564  if (!mapping) {
13565  return NULL;
13566  }
13567  mapping->alias = mapping->buf;
13568  mapping->mailbox = mapping->buf + from_len;
13569  ast_copy_string(mapping->alias, alias, from_len); /* Safe */
13570  ast_copy_string(mapping->mailbox, mailbox, to_len); /* Safe */
13571 
13572  return mapping;
13573 }
#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 12394 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().

12395 {
12396  /* Assumes lock is already held */
12397  char *tmp;
12398  char *stringp;
12399  char *s;
12400  struct ast_vm_user *vmu;
12401  char mailbox_full[MAX_VM_MAILBOX_LEN];
12402  int new = 0, old = 0, urgent = 0;
12403  char secretfn[PATH_MAX] = "";
12404 
12405  tmp = ast_strdupa(data);
12406 
12407  if (!(vmu = find_or_create(context, box)))
12408  return -1;
12409 
12410  populate_defaults(vmu);
12411 
12412  stringp = tmp;
12413  if ((s = strsep(&stringp, ","))) {
12414  if (!ast_strlen_zero(s) && s[0] == '*') {
12415  ast_log(LOG_WARNING, "Invalid password detected for mailbox %s. The password"
12416  "\n\tmust be reset in voicemail.conf.\n", box);
12417  }
12418  /* assign password regardless of validity to prevent NULL password from being assigned */
12419  ast_copy_string(vmu->password, s, sizeof(vmu->password));
12420  }
12421  if (stringp && (s = strsep(&stringp, ","))) {
12422  ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
12423  }
12424  if (stringp && (s = strsep(&stringp, ","))) {
12425  vmu->email = ast_strdup(s);
12426  }
12427  if (stringp && (s = strsep(&stringp, ","))) {
12428  ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
12429  }
12430  if (stringp) {
12431  apply_options(vmu, stringp);
12432  }
12433 
12434  switch (vmu->passwordlocation) {
12435  case OPT_PWLOC_SPOOLDIR:
12436  snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
12437  read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
12438  }
12439 
12440  snprintf(mailbox_full, MAX_VM_MAILBOX_LEN, "%s%s%s",
12441  box,
12442  ast_strlen_zero(context) ? "" : "@",
12443  context);
12444 
12445  inboxcount2(mailbox_full, &urgent, &new, &old);
12446 #ifdef IMAP_STORAGE
12447  imap_logout(mailbox_full);
12448 #endif
12449  queue_mwi_event(NULL, mailbox_full, urgent, new, old);
12450 
12451  return 0;
12452 }
#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 13196 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().

13202 {
13203  int new;
13204  int old;
13205  char *mailbox;
13206  int ret;
13207 
13208  if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {
13209  ast_log(LOG_ERROR, "Wrong input parameter.");
13210  return 0;
13211  }
13212 
13213  /* create mailbox string */
13214  if (!ast_strlen_zero(vmu->context)) {
13215  ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);
13216  } else {
13217  ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);
13218  }
13219  if (ret == -1) {
13220  ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));
13221  return 0;
13222  }
13223 
13224  /* get mailbox count */
13225  ret = inboxcount(mailbox, &new, &old);
13226  ast_free(mailbox);
13227  if (ret == -1) {
13228  ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n",
13229  vmu->mailbox ?: "", vmu->context ?: "");
13230  return 0;
13231  }
13232 
13233  astman_append(s,
13234  "Event: %s\r\n"
13235  "%s"
13236  "VMContext: %s\r\n"
13237  "VoiceMailbox: %s\r\n"
13238  "Fullname: %s\r\n"
13239  "Email: %s\r\n"
13240  "Pager: %s\r\n"
13241  "ServerEmail: %s\r\n"
13242  "FromString: %s\r\n"
13243  "MailCommand: %s\r\n"
13244  "Language: %s\r\n"
13245  "TimeZone: %s\r\n"
13246  "Callback: %s\r\n"
13247  "Dialout: %s\r\n"
13248  "UniqueID: %s\r\n"
13249  "ExitContext: %s\r\n"
13250  "SayDurationMinimum: %d\r\n"
13251  "SayEnvelope: %s\r\n"
13252  "SayCID: %s\r\n"
13253  "AttachMessage: %s\r\n"
13254  "AttachmentFormat: %s\r\n"
13255  "DeleteMessage: %s\r\n"
13256  "VolumeGain: %.2f\r\n"
13257  "CanReview: %s\r\n"
13258  "CallOperator: %s\r\n"
13259  "MaxMessageCount: %d\r\n"
13260  "MaxMessageLength: %d\r\n"
13261  "NewMessageCount: %d\r\n"
13262  "OldMessageCount: %d\r\n"
13263 #ifdef IMAP_STORAGE
13264  "IMAPUser: %s\r\n"
13265  "IMAPServer: %s\r\n"
13266  "IMAPPort: %s\r\n"
13267  "IMAPFlags: %s\r\n"
13268 #endif
13269  "\r\n",
13270 
13271  event_name,
13272  actionid,
13273  vmu->context,
13274  vmu->mailbox,
13275  vmu->fullname,
13276  vmu->email,
13277  vmu->pager,
13280  mailcmd,
13281  vmu->language,
13282  vmu->zonetag,
13283  vmu->callback,
13284  vmu->dialout,
13285  vmu->uniqueid,
13286  vmu->exit,
13287  vmu->saydurationm,
13288  ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
13289  ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
13290  ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
13291  vmu->attachfmt,
13292  ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
13293  vmu->volgain,
13294  ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
13295  ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
13296  vmu->maxmsg,
13297  vmu->maxsecs,
13298  new,
13299  old
13300 #ifdef IMAP_STORAGE
13301  ,
13302  vmu->imapuser,
13303  vmu->imapserver,
13304  vmu->imapport,
13305  vmu->imapflags
13306 #endif
13307  );
13308 
13309  return 1;
13310 
13311 }
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 1235 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().

1236 {
1237  int x;
1238  if (!strcasecmp(var, "attach")) {
1240  } else if (!strcasecmp(var, "attachfmt")) {
1241  ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
1242  } else if (!strcasecmp(var, "serveremail")) {
1243  ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
1244  } else if (!strcasecmp(var, "fromstring")) {
1245  ast_copy_string(vmu->fromstring, value, sizeof(vmu->fromstring));
1246  } else if (!strcasecmp(var, "emailbody")) {
1247  ast_free(vmu->emailbody);
1249  } else if (!strcasecmp(var, "emailsubject")) {
1250  ast_free(vmu->emailsubject);
1252  } else if (!strcasecmp(var, "language")) {
1253  ast_copy_string(vmu->language, value, sizeof(vmu->language));
1254  } else if (!strcasecmp(var, "tz")) {
1255  ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
1256  } else if (!strcasecmp(var, "locale")) {
1257  ast_copy_string(vmu->locale, value, sizeof(vmu->locale));
1258 #ifdef IMAP_STORAGE
1259  } else if (!strcasecmp(var, "imapuser")) {
1260  ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
1261  vmu->imapversion = imapversion;
1262  } else if (!strcasecmp(var, "imapserver")) {
1263  ast_copy_string(vmu->imapserver, value, sizeof(vmu->imapserver));
1264  vmu->imapversion = imapversion;
1265  } else if (!strcasecmp(var, "imapport")) {
1266  ast_copy_string(vmu->imapport, value, sizeof(vmu->imapport));
1267  vmu->imapversion = imapversion;
1268  } else if (!strcasecmp(var, "imapflags")) {
1269  ast_copy_string(vmu->imapflags, value, sizeof(vmu->imapflags));
1270  vmu->imapversion = imapversion;
1271  } else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
1272  ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
1273  vmu->imapversion = imapversion;
1274  } else if (!strcasecmp(var, "imapfolder")) {
1275  ast_copy_string(vmu->imapfolder, value, sizeof(vmu->imapfolder));
1276  vmu->imapversion = imapversion;
1277  } else if (!strcasecmp(var, "imapvmshareid")) {
1278  ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
1279  vmu->imapversion = imapversion;
1280 #endif
1281  } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
1283  } else if (!strcasecmp(var, "saycid")){
1284  ast_set2_flag(vmu, ast_true(