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

Comedian Mail - Voicemail System. More...

#include "asterisk.h"
#include "asterisk/paths.h"
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <time.h>
#include <dirent.h>
#include "asterisk/logger.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/say.h"
#include "asterisk/module.h"
#include "asterisk/adsi.h"
#include "asterisk/app.h"
#include "asterisk/mwi.h"
#include "asterisk/manager.h"
#include "asterisk/dsp.h"
#include "asterisk/localtime.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/stringfields.h"
#include "asterisk/strings.h"
#include "asterisk/smdi.h"
#include "asterisk/astobj2.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/test.h"
#include "asterisk/format_cache.h"
Include dependency graph for app_voicemail.c:

Go to the source code of this file.

Data Structures

struct  alias_mailbox_mapping
 
struct  ast_vm_user
 
struct  baseio
 
struct  inprocess
 
struct  leave_vm_options
 Options for leaving voicemail with the voicemail() application. More...
 
struct  mailbox_alias_mapping
 
struct  test_files
 
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 CHECK(u, attr, value)
 
#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_BEEP_TONE = 3,
  OPT_ARG_ARRAY_SIZE = 4
}
 
enum  vm_option_flags {
  OPT_SILENT = (1 << 0), OPT_BUSY_GREETING = (1 << 1), OPT_UNAVAIL_GREETING = (1 << 2), OPT_RECORDGAIN = (1 << 3),
  OPT_PREPEND_MAILBOX = (1 << 4), OPT_AUTOPLAY = (1 << 6), OPT_DTMFEXIT = (1 << 7), OPT_MESSAGE_Urgent = (1 << 8),
  OPT_MESSAGE_PRIORITY = (1 << 9), OPT_EARLYM_GREETING = (1 << 10), OPT_BEEP = (1 << 11)
}
 
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...
 
 AST_TEST_DEFINE (test_voicemail_vmuser)
 
 AST_TEST_DEFINE (test_voicemail_vmsayname)
 
 AST_TEST_DEFINE (test_voicemail_msgcount)
 
 AST_TEST_DEFINE (test_voicemail_notify_endl)
 
 AST_TEST_DEFINE (test_voicemail_load_config)
 
 AST_TEST_DEFINE (test_voicemail_vm_info)
 
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_framefake_read (struct ast_channel *ast)
 
static int fake_write (struct ast_channel *ast, struct ast_frame *frame)
 
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_config_from_memory (int reload, struct ast_config *cfg, struct ast_config *ucfg)
 
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 vm_test_create_user (const char *context, const char *mailbox)
 
static int vm_test_destroy_user (const char *context, const char *mailbox)
 
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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, .optional_modules = "res_adsi,res_smdi", }
 
static char * addesc = "Comedian Mail"
 
static unsigned char adsifdn [4] = "\x00\x00\x00\x0F"
 
static unsigned char adsisec [4] = "\x9B\xDB\xF7\xAC"
 
static int adsiver = 1
 
static struct ao2_containeralias_mailbox_mappings
 
static char aliasescontext [MAX_VM_CONTEXT_LEN]
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static char callcontext [AST_MAX_CONTEXT] = ""
 
static char charset [32] = "ISO-8859-1"
 
static char cidinternalcontexts [MAX_NUM_CID_CONTEXTS][64]
 
static struct ast_cli_entry cli_voicemail []
 
static char dialcontext [AST_MAX_CONTEXT] = ""
 
static char * emailbody
 
static char emaildateformat [32] = "%A, %B %d, %Y at %r"
 
static char * emailsubject
 
static char exitcontext [AST_MAX_CONTEXT] = ""
 
static char ext_pass_check_cmd [128]
 
static char ext_pass_cmd [128]
 
static char externnotify [160]
 
static char fromstring [100]
 
static struct ast_flags globalflags = {0}
 
struct ao2_containerinprocess_container
 
static char listen_control_forward_key [12]
 
static char listen_control_pause_key [12]
 
static char listen_control_restart_key [12]
 
static char listen_control_reverse_key [12]
 
static char listen_control_stop_key [12]
 
static char locale [20]
 
static struct ao2_containermailbox_alias_mappings
 
static const char *const mailbox_folders []
 
static char mailcmd [160] = SENDMAIL
 
static int maxdeletedmsg
 
static int maxgreet
 
static int maxlogins = 3
 
static int maxmsg = MAXMSG
 
static int maxsilence
 
static int minpassword = MINPASSWORD
 
static int msg_id_incrementor
 
struct ast_mwi_observer mwi_observer
 
static struct ast_taskprocessormwi_subscription_tps
 
static int my_umask
 
static char * pagerbody
 
static char pagerdateformat [32] = "%A, %B %d, %Y at %r"
 
static char pagerfromstring [100]
 
static char * pagersubject
 
static int passwordlocation
 
static char * playmsg_app = "VoiceMailPlayMsg"
 
static ast_cond_t poll_cond = PTHREAD_COND_INITIALIZER
 
static unsigned int poll_freq = DEFAULT_POLL_FREQ
 
static ast_mutex_t poll_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static unsigned int poll_mailboxes
 
static pthread_t poll_thread = AST_PTHREADT_NULL
 
static unsigned char poll_thread_run
 
static int pwdchange = PWDCHANGE_INTERNAL
 
static int saydurationminfo = 2
 
static char * sayname_app = "VMSayName"
 
static char serveremail [80] = ASTERISK_USERNAME
 
static int silencethreshold = 128
 
static int skipms = 3000
 
static struct ast_smdi_interfacesmdi_iface = NULL
 
static struct users users = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static char userscontext [AST_MAX_EXTENSION] = "default"
 
static const struct ast_app_option vm_app_options [128] = { [ 's' ] = { .flag = OPT_SILENT }, [ 'b' ] = { .flag = OPT_BUSY_GREETING }, [ 'u' ] = { .flag = OPT_UNAVAIL_GREETING }, [ 'g' ] = { .flag = OPT_RECORDGAIN , .arg_index = OPT_ARG_RECORDGAIN + 1 }, [ 'd' ] = { .flag = OPT_DTMFEXIT , .arg_index = OPT_ARG_DTMFEXIT + 1 }, [ 'p' ] = { .flag = OPT_PREPEND_MAILBOX }, [ 'a' ] = { .flag = OPT_AUTOPLAY , .arg_index = OPT_ARG_PLAYFOLDER + 1 }, [ 'U' ] = { .flag = OPT_MESSAGE_Urgent }, [ 'P' ] = { .flag = OPT_MESSAGE_PRIORITY }, [ 'e' ] = { .flag = OPT_EARLYM_GREETING }, [ 't' ] = { .flag = OPT_BEEP , .arg_index = OPT_ARG_BEEP_TONE + 1 } }
 
static const struct ast_vm_greeter_functions vm_greeter_table
 
static struct ast_custom_function vm_info_acf
 
static char vm_invalid_password [80] = "vm-invalid-password"
 
static char vm_login [80] = "vm-login"
 
static char vm_mismatch [80] = "vm-mismatch"
 
static char vm_newpassword [80] = "vm-newpassword"
 
static char vm_newuser [80] = "vm-newuser"
 
static char vm_passchanged [80] = "vm-passchanged"
 
static char vm_password [80] = "vm-password"
 
static char vm_pls_try_again [80] = "vm-pls-try-again"
 
static char vm_prepend_timeout [80] = "vm-then-pound"
 
static char vm_reenterpassword [80] = "vm-reenterpassword"
 
static char VM_SPOOL_DIR [PATH_MAX]
 
static const struct ast_vm_functions vm_table
 
static char * vmauthenticate_app = "VMAuthenticate"
 
static char vmfmts [80] = "wav"
 
static int vmmaxsecs
 
static int vmminsecs
 
static char * voicemail_app = "VoiceMail"
 
static char * voicemailmain_app = "VoiceMailMain"
 
static double volgain
 
static struct zones zones = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static char zonetag [80]
 

Detailed Description

Comedian Mail - Voicemail System.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m unixODBC (http://www.unixodbc.org/) A source distribution of University of Washington's IMAP c-client (http://www.washington.edu/imap/)
See also
  • 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 512 of file app_voicemail.c.

Referenced by actual_load_config().

◆ BASELINELEN

#define BASELINELEN   72

Definition at line 537 of file app_voicemail.c.

Referenced by ochar().

◆ BASEMAXINLINE

#define BASEMAXINLINE   256

Definition at line 538 of file app_voicemail.c.

Referenced by base_encode(), and inbuf().

◆ CHECK

#define CHECK (   u,
  attr,
  value 
)
Value:
else if (strcmp(u->attr, value)) { \
ast_test_status_update(test, "mailbox %s should have %s '%s', but has '%s'\n", \
u->mailbox, #attr, value, u->attr); res = AST_TEST_FAIL; break; }
int value
Definition: syslog.c:37

Referenced by AST_TEST_DEFINE().

◆ CHUNKSIZE

#define CHUNKSIZE   65536

Definition at line 509 of file app_voicemail.c.

◆ COMMAND_TIMEOUT

#define COMMAND_TIMEOUT   5000

Definition at line 505 of file app_voicemail.c.

◆ COPY

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

Definition at line 872 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 517 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 519 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 520 of file app_voicemail.c.

Referenced by actual_load_config().

◆ DEFAULT_LISTEN_CONTROL_REVERSE_KEY

#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY   "*"

Definition at line 518 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 521 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 943 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 542 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 568 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 870 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 528 of file app_voicemail.c.

Referenced by leave_voicemail(), and play_record_review().

◆ MAPPING_BUCKETS

#define MAPPING_BUCKETS   511

Definition at line 966 of file app_voicemail.c.

Referenced by load_module().

◆ MAX_DATETIME_FORMAT

#define MAX_DATETIME_FORMAT   512

Definition at line 545 of file app_voicemail.c.

◆ MAX_MAIL_BODY_CONTENT_SIZE

#define MAX_MAIL_BODY_CONTENT_SIZE   134217728L

Definition at line 530 of file app_voicemail.c.

Referenced by vm_allocate_dh().

◆ MAX_NUM_CID_CONTEXTS

#define MAX_NUM_CID_CONTEXTS   10

Definition at line 546 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 749 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 751 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 748 of file app_voicemail.c.

◆ MAXMSG

#define MAXMSG   100

Definition at line 532 of file app_voicemail.c.

Referenced by actual_load_config(), and apply_option().

◆ MAXMSGLIMIT

#define MAXMSGLIMIT   9999

Definition at line 533 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 535 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 569 of file app_voicemail.c.

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

◆ PWDCHANGE_EXTERNAL

#define PWDCHANGE_EXTERNAL   (1 << 2)

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

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

◆ RENAME

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

Definition at line 871 of file app_voicemail.c.

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

◆ RETRIEVE

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

◆ SENDMAIL

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

Definition at line 526 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 503 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 895 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 874 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 522 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 561 of file app_voicemail.c.

Referenced by AST_TEST_DEFINE(), 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 559 of file app_voicemail.c.

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

◆ VM_DELETE

#define VM_DELETE   (1 << 12)

Delete message after sending notification

Definition at line 560 of file app_voicemail.c.

Referenced by append_vmu_info_astman(), apply_option(), AST_TEST_DEFINE(), 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 558 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 552 of file app_voicemail.c.

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

◆ VM_FORCEGREET

#define VM_FORCEGREET   (1 << 8)

Have new users record their greetings

Definition at line 556 of file app_voicemail.c.

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

◆ VM_FORCENAME

#define VM_FORCENAME   (1 << 7)

Have new users record their name

Definition at line 555 of file app_voicemail.c.

Referenced by actual_load_config(), apply_option(), AST_TEST_DEFINE(), 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 566 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 565 of file app_voicemail.c.

Referenced by actual_load_config(), apply_option(), AST_TEST_DEFINE(), 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 564 of file app_voicemail.c.

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

◆ VM_OPERATOR

#define VM_OPERATOR   (1 << 1)

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

Definition at line 549 of file app_voicemail.c.

Referenced by actual_load_config(), append_vmu_info_astman(), apply_option(), AST_TEST_DEFINE(), 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 557 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 548 of file app_voicemail.c.

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

◆ VM_SAYCID

#define VM_SAYCID   (1 << 2)

Repeat the CallerID info during envelope playback

Definition at line 550 of file app_voicemail.c.

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

◆ VM_SAYDURATION

#define VM_SAYDURATION   (1 << 5)

Play the length of the message during envelope playback

Definition at line 553 of file app_voicemail.c.

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

◆ VM_SEARCH

#define VM_SEARCH   (1 << 14)

Search all contexts for a matching mailbox

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

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

◆ VM_SVMAIL

#define VM_SVMAIL   (1 << 3)

Allow the user to compose a new VM from within VoicemailMain

Definition at line 551 of file app_voicemail.c.

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

◆ VM_TEMPGREETWARN

#define VM_TEMPGREETWARN   (1 << 15)

Remind user tempgreeting is set

Definition at line 563 of file app_voicemail.c.

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

◆ VMSTATE_MAX_MSG_ARRAY

#define VMSTATE_MAX_MSG_ARRAY   256

Definition at line 803 of file app_voicemail.c.

Referenced by vm_allocate_dh().

◆ VOICEMAIL_CONFIG

#define VOICEMAIL_CONFIG   "voicemail.conf"

Definition at line 511 of file app_voicemail.c.

Referenced by load_config(), and vm_change_password().

◆ VOICEMAIL_DIR_MODE

#define VOICEMAIL_DIR_MODE   0777

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

◆ vm_option_args

Enumerator
OPT_ARG_RECORDGAIN 
OPT_ARG_PLAYFOLDER 
OPT_ARG_DTMFEXIT 
OPT_ARG_BEEP_TONE 
OPT_ARG_ARRAY_SIZE 

Definition at line 594 of file app_voicemail.c.

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

◆ vm_option_flags

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

Definition at line 580 of file app_voicemail.c.

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

◆ vm_passwordlocation

Enumerator
OPT_PWLOC_VOICEMAILCONF 
OPT_PWLOC_SPOOLDIR 
OPT_PWLOC_USERSCONF 

Definition at line 603 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 6061 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().

6062 {
6063  DIR *dir;
6064  struct dirent *de;
6065  char fn[256];
6066  int ret = 0;
6067  struct alias_mailbox_mapping *mapping;
6068  char *c;
6069  char *m;
6070 
6071  /* If no mailbox, return immediately */
6072  if (ast_strlen_zero(mailbox))
6073  return 0;
6074 
6075  if (ast_strlen_zero(folder))
6076  folder = "INBOX";
6077  if (ast_strlen_zero(context))
6078  context = "default";
6079 
6080  c = (char *)context;
6081  m = (char *)mailbox;
6082 
6084  char tmp[MAX_VM_MAILBOX_LEN];
6085 
6086  snprintf(tmp, MAX_VM_MAILBOX_LEN, "%s@%s", mailbox, context);
6088  if (mapping) {
6089  separate_mailbox(ast_strdupa(mapping->mailbox), &m, &c);
6090  ao2_ref(mapping, -1);
6091  }
6092  }
6093 
6094  snprintf(fn, sizeof(fn), "%s%s/%s/%s", VM_SPOOL_DIR, c, m, folder);
6095 
6096  if (!(dir = opendir(fn)))
6097  return 0;
6098 
6099  while ((de = readdir(dir))) {
6100  if (!strncasecmp(de->d_name, "msg", 3)) {
6101  if (shortcircuit) {
6102  ret = 1;
6103  break;
6104  } else if (!strncasecmp(de->d_name + 8, "txt", 3)) {
6105  ret++;
6106  }
6107  }
6108  }
6109 
6110  closedir(dir);
6111 
6112  return ret;
6113 }
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]
#define ast_strlen_zero(foo)
Definition: strings.h:52
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]
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 16611 of file app_voicemail.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 16611 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 12679 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 AST_TEST_DEFINE().

12680 {
12681  struct ast_vm_user svm;
12682  struct ast_vm_user *vmu = NULL;
12683  char *parse;
12684  char *mailbox;
12685  char *context;
12686  int res = 0;
12687 
12689  AST_APP_ARG(mailbox_context);
12690  AST_APP_ARG(attribute);
12691  AST_APP_ARG(folder);
12692  );
12693 
12694  buf[0] = '\0';
12695 
12696  if (ast_strlen_zero(args)) {
12697  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12698  return -1;
12699  }
12700 
12701  parse = ast_strdupa(args);
12702  AST_STANDARD_APP_ARGS(arg, parse);
12703 
12704  if (ast_strlen_zero(arg.mailbox_context)
12705  || ast_strlen_zero(arg.attribute)
12706  || separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
12707  ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
12708  return -1;
12709  }
12710 
12711  memset(&svm, 0, sizeof(svm));
12712  vmu = find_user(&svm, context, mailbox);
12713 
12714  if (!strncasecmp(arg.attribute, "exists", 5)) {
12715  ast_copy_string(buf, vmu ? "1" : "0", len);
12716  free_user(vmu);
12717  return 0;
12718  }
12719 
12720  if (vmu) {
12721  if (!strncasecmp(arg.attribute, "password", 8)) {
12722  ast_copy_string(buf, vmu->password, len);
12723  } else if (!strncasecmp(arg.attribute, "fullname", 8)) {
12724  ast_copy_string(buf, vmu->fullname, len);
12725  } else if (!strncasecmp(arg.attribute, "email", 5)) {
12726  ast_copy_string(buf, vmu->email, len);
12727  } else if (!strncasecmp(arg.attribute, "pager", 5)) {
12728  ast_copy_string(buf, vmu->pager, len);
12729  } else if (!strncasecmp(arg.attribute, "language", 8)) {
12731  } else if (!strncasecmp(arg.attribute, "locale", 6)) {
12732  ast_copy_string(buf, vmu->locale, len);
12733  } else if (!strncasecmp(arg.attribute, "tz", 2)) {
12734  ast_copy_string(buf, vmu->zonetag, len);
12735  } else if (!strncasecmp(arg.attribute, "count", 5)) {
12736  char *mailbox_id;
12737 
12738  mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
12739  sprintf(mailbox_id, "%s@%s", mailbox, context);/* Safe */
12740 
12741  /* If mbxfolder is empty messagecount will default to INBOX */
12742  res = messagecount(mailbox_id, arg.folder);
12743  if (res < 0) {
12744  ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
12745  free_user(vmu);
12746  return -1;
12747  }
12748  snprintf(buf, len, "%d", res);
12749  } else {
12750  ast_log(LOG_ERROR, "Unknown attribute '%s' for VM_INFO\n", arg.attribute);
12751  free_user(vmu);
12752  return -1;
12753  }
12754  free_user(vmu);
12755  }
12756 
12757  return 0;
12758 }
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
#define ast_strlen_zero(foo)
Definition: strings.h:52
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)
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 13680 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(), and load_config_from_memory().

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

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

12357 {
12358  struct ast_variable *var;
12359  struct ast_category *cat;
12360  generate_msg_id(id);
12361 
12362  var = ast_variable_new("msg_id", id, "");
12363  if (!var) {
12364  return -1;
12365  }
12366 
12367  cat = ast_category_get(msg_cfg, "message", NULL);
12368  if (!cat) {
12369  ast_log(LOG_ERROR, "Voicemail data file %s/%d.txt has no [message] category?\n", dir, msg);
12370  ast_variables_destroy(var);
12371  return -1;
12372  }
12373 
12374  ast_variable_append(cat, var);
12375 
12376  if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
12377  ast_log(LOG_WARNING, "Unable to update %s to have a message ID\n", filename);
12378  return -1;
12379  }
12380 
12381  UPDATE_MSG_ID(dir, msg, id, vmu, msg_cfg, folder);
12382  return 0;
12383 }
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 7448 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().

7449 {
7450  int x;
7451  if (!ast_adsi_available(chan))
7452  return;
7453  x = ast_adsi_load_session(chan, adsifdn, adsiver, 1);
7454  if (x < 0)
7455  return;
7456  if (!x) {
7457  if (adsi_load_vmail(chan, useadsi)) {
7458  ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n");
7459  return;
7460  }
7461  } else
7462  *useadsi = 1;
7463 }
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 7644 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().

7645 {
7646  int bytes = 0;
7647  unsigned char buf[256];
7648  unsigned char keys[8];
7649 
7650  int x;
7651 
7652  if (!ast_adsi_available(chan))
7653  return;
7654 
7655  /* New meaning for keys */
7656  for (x = 0; x < 5; x++)
7657  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7658 
7659  keys[6] = 0x0;
7660  keys[7] = 0x0;
7661 
7662  if (!vms->curmsg) {
7663  /* No prev key, provide "Folder" instead */
7664  keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7665  }
7666  if (vms->curmsg >= vms->lastmsg) {
7667  /* If last message ... */
7668  if (vms->curmsg) {
7669  /* but not only message, provide "Folder" instead */
7670  keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7671  } else {
7672  /* Otherwise if only message, leave blank */
7673  keys[3] = 1;
7674  }
7675  }
7676 
7677  /* If deleted, show "undeleted" */
7678 #ifdef IMAP_STORAGE
7679  ast_mutex_lock(&vms->lock);
7680 #endif
7681  if (vms->deleted[vms->curmsg]) {
7682  keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7683  }
7684 #ifdef IMAP_STORAGE
7685  ast_mutex_unlock(&vms->lock);
7686 #endif
7687 
7688  /* Except "Exit" */
7689  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7690  bytes += ast_adsi_set_keys(buf + bytes, keys);
7691  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7692 
7693  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7694 }
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 7513 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().

7514 {
7515  unsigned char buf[256];
7516  int bytes = 0;
7517  unsigned char keys[8];
7518  int x, y;
7519 
7520  if (!ast_adsi_available(chan))
7521  return;
7522 
7523  for (x = 0; x < 5; x++) {
7524  y = ADSI_KEY_APPS + 12 + start + x;
7525  if (y > ADSI_KEY_APPS + 12 + 4)
7526  y = 0;
7527  keys[x] = ADSI_KEY_SKT | y;
7528  }
7529  keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17);
7530  keys[6] = 0;
7531  keys[7] = 0;
7532 
7533  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, "");
7534  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
7535  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7536  bytes += ast_adsi_set_keys(buf + bytes, keys);
7537  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7538 
7539  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7540 }
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 7799 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().

7800 {
7801  unsigned char buf[256];
7802  int bytes = 0;
7803 
7804  if (!ast_adsi_available(chan))
7805  return;
7806  bytes += adsi_logo(buf + bytes);
7807  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
7808  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
7809  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7810  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7811 
7812  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7813 }
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 7319 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().

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

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

7312 {
7313  int bytes = 0;
7314  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
7315  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
7316  return bytes;
7317 }
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 7542 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().

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

7492 {
7493  unsigned char buf[256];
7494  int bytes = 0;
7495  unsigned char keys[8];
7496  int x;
7497  if (!ast_adsi_available(chan))
7498  return;
7499 
7500  for (x = 0; x < 8; x++)
7501  keys[x] = 0;
7502  /* Set one key for next */
7503  keys[3] = ADSI_KEY_APPS + 3;
7504 
7505  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7506  bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
7507  bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
7508  bytes += ast_adsi_set_keys(buf + bytes, keys);
7509  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7510  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7511 }
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 7696 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().

7697 {
7698  unsigned char buf[256] = "";
7699  char buf1[256] = "", buf2[256] = "";
7700  int bytes = 0;
7701  unsigned char keys[8];
7702  int x;
7703 
7704  char *newm = (vms->newmessages == 1) ? "message" : "messages";
7705  char *oldm = (vms->oldmessages == 1) ? "message" : "messages";
7706  if (!ast_adsi_available(chan))
7707  return;
7708  if (vms->newmessages) {
7709  snprintf(buf1, sizeof(buf1), "You have %d new", vms->newmessages);
7710  if (vms->oldmessages) {
7711  strncat(buf1, " and", sizeof(buf1) - strlen(buf1) - 1);
7712  snprintf(buf2, sizeof(buf2), "%d old %s.", vms->oldmessages, oldm);
7713  } else {
7714  snprintf(buf2, sizeof(buf2), "%s.", newm);
7715  }
7716  } else if (vms->oldmessages) {
7717  snprintf(buf1, sizeof(buf1), "You have %d old", vms->oldmessages);
7718  snprintf(buf2, sizeof(buf2), "%s.", oldm);
7719  } else {
7720  strcpy(buf1, "You have no messages.");
7721  buf2[0] = ' ';
7722  buf2[1] = '\0';
7723  }
7724  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7725  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7726  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7727 
7728  for (x = 0; x < 6; x++)
7729  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7730  keys[6] = 0;
7731  keys[7] = 0;
7732 
7733  /* Don't let them listen if there are none */
7734  if (vms->lastmsg < 0)
7735  keys[0] = 1;
7736  bytes += ast_adsi_set_keys(buf + bytes, keys);
7737 
7738  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7739 
7740  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7741 }
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 7743 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().

7744 {
7745  unsigned char buf[256] = "";
7746  char buf1[256] = "", buf2[256] = "";
7747  int bytes = 0;
7748  unsigned char keys[8];
7749  int x;
7750 
7751  char *mess = (vms->lastmsg == 0) ? "message" : "messages";
7752 
7753  if (!ast_adsi_available(chan))
7754  return;
7755 
7756  /* Original command keys */
7757  for (x = 0; x < 6; x++)
7758  keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
7759 
7760  keys[6] = 0;
7761  keys[7] = 0;
7762 
7763  if ((vms->lastmsg + 1) < 1)
7764  keys[0] = 0;
7765 
7766  snprintf(buf1, sizeof(buf1), "%s%s has", vms->curbox,
7767  strcasecmp(vms->curbox, "INBOX") ? " folder" : "");
7768 
7769  if (vms->lastmsg + 1)
7770  snprintf(buf2, sizeof(buf2), "%d %s.", vms->lastmsg + 1, mess);
7771  else
7772  strcpy(buf2, "no messages.");
7773  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
7774  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
7775  bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, "", "");
7776  bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7777  bytes += ast_adsi_set_keys(buf + bytes, keys);
7778 
7779  bytes += ast_adsi_voice_mode(buf + bytes, 0);
7780 
7781  ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
7782 
7783 }
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 15305 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(), leave_vm_options::beeptone, 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().

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

13589 {
13590  struct alias_mailbox_mapping *mapping;
13591  size_t from_len = strlen(alias) + 1;
13592  size_t to_len = strlen(mailbox) + 1;
13593 
13594  mapping = ao2_alloc(sizeof(*mapping) + from_len + to_len, NULL);
13595  if (!mapping) {
13596  return NULL;
13597  }
13598  mapping->alias = mapping->buf;
13599  mapping->mailbox = mapping->buf + from_len;
13600  ast_copy_string(mapping->alias, alias, from_len); /* Safe */
13601  ast_copy_string(mapping->mailbox, mailbox, to_len); /* Safe */
13602 
13603  return mapping;
13604 }
#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 12425 of file app_voicemail.c.

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

Referenced by load_users().

12426 {
12427  /* Assumes lock is already held */
12428  char *tmp;
12429  char *stringp;
12430  char *s;
12431  struct ast_vm_user *vmu;
12432  char mailbox_full[MAX_VM_MAILBOX_LEN];
12433  int new = 0, old = 0, urgent = 0;
12434  char secretfn[PATH_MAX] = "";
12435 
12436  tmp = ast_strdupa(data);
12437 
12438  if (!(vmu = find_or_create(context, box)))
12439  return -1;
12440 
12441  populate_defaults(vmu);
12442 
12443  stringp = tmp;
12444  if ((s = strsep(&stringp, ","))) {
12445  if (!ast_strlen_zero(s) && s[0] == '*') {
12446  ast_log(LOG_WARNING, "Invalid password detected for mailbox %s. The password"
12447  "\n\tmust be reset in voicemail.conf.\n", box);
12448  }
12449  /* assign password regardless of validity to prevent NULL password from being assigned */
12450  ast_copy_string(vmu->password, s, sizeof(vmu->password));
12451  }
12452  if (stringp && (s = strsep(&stringp, ","))) {
12453  ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
12454  }
12455  if (stringp && (s = strsep(&stringp, ","))) {
12456  vmu->email = ast_strdup(s);
12457  }
12458  if (stringp && (s = strsep(&stringp, ","))) {
12459  ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
12460  }
12461  if (stringp) {
12462  apply_options(vmu, stringp);
12463  }
12464 
12465  switch (vmu->passwordlocation) {
12466  case OPT_PWLOC_SPOOLDIR:
12467  snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
12468  read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
12469  }
12470 
12471  snprintf(mailbox_full, MAX_VM_MAILBOX_LEN, "%s%s%s",
12472  box,
12473  ast_strlen_zero(context) ? "" : "@",
12474  context);
12475 
12476  inboxcount2(mailbox_full, &urgent, &new, &old);
12477 #ifdef IMAP_STORAGE
12478  imap_logout(mailbox_full);
12479 #endif
12480  queue_mwi_event(NULL, mailbox_full, urgent, new, old);
12481 
12482  return 0;
12483 }
#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_strlen_zero(foo)
Definition: strings.h:52
#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.
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 13227 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().

13233 {
13234  int new;
13235  int old;
13236  char *mailbox;
13237  int ret;
13238 
13239  if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {
13240  ast_log(LOG_ERROR, "Wrong input parameter.");
13241  return 0;
13242  }
13243 
13244  /* create mailbox string */
13245  if (!ast_strlen_zero(vmu->context)) {
13246  ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);
13247  } else {
13248  ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);
13249  }
13250  if (ret == -1) {
13251  ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));
13252  return 0;
13253  }
13254 
13255  /* get mailbox count */
13256  ret = inboxcount(mailbox, &new, &old);
13257  ast_free(mailbox);
13258  if (ret == -1) {
13259  ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n",
13260  vmu->mailbox ?: "", vmu->context ?: "");
13261  return 0;
13262  }
13263 
13264  astman_append(s,
13265  "Event: %s\r\n"
13266  "%s"
13267  "VMContext: %s\r\n"
13268  "VoiceMailbox: %s\r\n"
13269  "Fullname: %s\r\n"
13270  "Email: %s\r\n"
13271  "Pager: %s\r\n"
13272  "ServerEmail: %s\r\n"
13273  "FromString: %s\r\n"
13274  "MailCommand: %s\r\n"
13275  "Language: %s\r\n"
13276  "TimeZone: %s\r\n"
13277  "Callback: %s\r\n"
13278  "Dialout: %s\r\n"
13279  "UniqueID: %s\r\n"
13280  "ExitContext: %s\r\n"
13281  "SayDurationMinimum: %d\r\n"
13282  "SayEnvelope: %s\r\n"
13283  "SayCID: %s\r\n"
13284  "AttachMessage: %s\r\n"
13285  "AttachmentFormat: %s\r\n"
13286  "DeleteMessage: %s\r\n"
13287  "VolumeGain: %.2f\r\n"
13288  "CanReview: %s\r\n"
13289  "CallOperator: %s\r\n"
13290  "MaxMessageCount: %d\r\n"
13291  "MaxMessageLength: %d\r\n"
13292  "NewMessageCount: %d\r\n"
13293  "OldMessageCount: %d\r\n"
13294 #ifdef IMAP_STORAGE
13295  "IMAPUser: %s\r\n"
13296  "IMAPServer: %s\r\n"
13297  "IMAPPort: %s\r\n"
13298  "IMAPFlags: %s\r\n"
13299 #endif
13300  "\r\n",
13301 
13302  event_name,
13303  actionid,
13304  vmu->context,
13305  vmu->mailbox,
13306  vmu->fullname,
13307  vmu->email,
13308  vmu->pager,
13311  mailcmd,
13312  vmu->language,
13313  vmu->zonetag,
13314  vmu->callback,
13315  vmu->dialout,
13316  vmu->uniqueid,
13317  vmu->exit,
13318  vmu->saydurationm,
13319  ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
13320  ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
13321  ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
13322  vmu->attachfmt,
13323  ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
13324  vmu->volgain,
13325  ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
13326  ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
13327  vmu->maxmsg,
13328  vmu->maxsecs,
13329  new,
13330  old
13331 #ifdef IMAP_STORAGE
13332  ,
13333  vmu->imapuser,
13334  vmu->imapserver,
13335  vmu->imapport,
13336  vmu->imapflags
13337 #endif
13338  );
13339 
13340  return 1;
13341 
13342 }
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
#define ast_strlen_zero(foo)
Definition: strings.h:52
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_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 1252 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().

1253 {
1254  int x;
1255  if (!strcasecmp(var, "attach")) {
1257  } else if (!strcasecmp(var, "attachfmt")) {
1258  ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
1259  } else if (!strcasecmp(var, "serveremail")) {
1260  ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
1261  } else if (!strcasecmp(var, "fromstring")) {
1262  ast_copy_string(vmu->fromstring, value, sizeof(vmu->fromstring));
1263  } else if (!strcasecmp(var, "emailbody")) {
1264  ast_free(vmu->emailbody);
1266  } else if (!strcasecmp(var, "emailsubject")) {
1267  ast_free(vmu->emailsubject);
1269  } else if (!strcasecmp(var, "language")) {
1270  ast_copy_string(vmu->language, value, sizeof(vmu->language));
1271  } else if (!strcasecmp(var, "tz")) {
1272  ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
1273  } else if (!strcasecmp(var, "locale")) {
1274  ast_copy_string(vmu->locale, value, sizeof(vmu->locale));
1275 #ifdef IMAP_STORAGE
1276  } else if (!strcasecmp(var, "imapuser")) {
1277  ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
1278  vmu->imapversion = imapversion;
1279  } else if (!strcasecmp(var, "imapserver")) {
1280  ast_copy_string(vmu->imapserver, value, sizeof(vmu->imapserver));
1281  vmu->imapversion = imapversion;
1282  } else if (!strcasecmp(var, "imapport")) {
1283  ast_copy_string(vmu->imapport, value, sizeof(vmu->imapport));
1284  vmu->imapversion = imapversion;
1285  } else if (!strcasecmp(var, "imapflags")) {
1286  ast_copy_string(vmu->imapflags, value, sizeof(vmu->imapflags));
1287  vmu->imapversion = imapversion;
1288  } else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
1289  ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
1290  vmu->imapversion = imapversion;
1291  } else if (!strcasecmp(var, "imapfolder")) {
1292  ast_copy_string(vmu->imapfolder, value, sizeof(vmu->imapfolder));
1293  vmu->imapversion = imapversion;
1294  } else if (!strcasecmp(var, "imapvmshareid")) {
1295  ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
1296  vmu->imapversion = imapversion;
1297 #endif
1298  } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
1300  } else if (!strcasecmp(var, "saycid")){
1302  } else if (!strcasecmp(var, "sendvoicemail")){
1304  } else if (!strcasecmp(var, "review")){
1306  } else if (!strcasecmp(var, "tempgreetwarn")){
1308  } else if (!strcasecmp(var, "messagewrap")){
1310  } else if (!strcasecmp(var, "operator")) {
1312  } else if (!strcasecmp(var, "envelope")){
1314  } else if (!strcasecmp(var, "moveheard")){
1316  } else if (!strcasecmp(var, "sayduration")){
1318  } else