Asterisk - The Open Source Telephony Project GIT-master-f3e88d3
Data Structures | Macros | Enumerations | Functions | Variables
app_voicemail_imap.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_imap.c:

Go to the source code of this file.

Data Structures

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

Macros

#define ALIASES_OUTPUT_FORMAT   "%-32s %-32s\n"
 
#define ASTERISK_USERNAME   "asterisk"
 
#define CHUNKSIZE   65536
 
#define COMMAND_TIMEOUT   5000
 
#define COPY(a, b, c, d, e, f, g, h)   (copy_plain_file(g,h));
 
#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY   "#"
 
#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY   "0"
 
#define DEFAULT_LISTEN_CONTROL_RESTART_KEY   "2"
 
#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY   "*"
 
#define DEFAULT_LISTEN_CONTROL_STOP_KEY   "13456789"
 
#define DEFAULT_POLL_FREQ   30
 
#define DELETE(a, b, c, d)   (vm_delete(c))
 
#define DISPOSE(a, b)
 
#define ENDL   "\n"
 
#define ERROR_LOCK_PATH   -100
 
#define ERROR_MAX_MSGS   -101
 
#define EXISTS(a, b, c, d)   (ast_fileexists(c,NULL,d) > 0)
 
#define force_reload_config()   load_config_force(1, 1)
 Forcibly reload voicemail.conf, even if it has not changed. This is necessary after running unit tests. More...
 
#define HVSU_OUTPUT_FORMAT   "%-10s %-5s %-25s %-10s %6s\n"
 
#define HVSZ_OUTPUT_FORMAT   "%-15s %-20s %-45s\n"
 
#define INTRO   "vm-intro"
 
#define MAPPING_BUCKETS   511
 
#define MAX_DATETIME_FORMAT   512
 
#define MAX_MAIL_BODY_CONTENT_SIZE   134217728L
 
#define MAX_NUM_CID_CONTEXTS   10
 
#define MAX_VM_CONTEXT_LEN   (AST_MAX_CONTEXT)
 
#define MAX_VM_MAILBOX_LEN   (MAX_VM_MBOX_ID_LEN + MAX_VM_CONTEXT_LEN)
 
#define MAX_VM_MBOX_ID_LEN   (AST_MAX_EXTENSION)
 
#define MAXMSG   100
 
#define MAXMSGLIMIT   9999
 
#define MINPASSWORD   0
 
#define MSG_ID_LEN   256
 
#define OPERATOR_EXIT   300
 
#define PWDCHANGE_EXTERNAL   (1 << 2)
 
#define PWDCHANGE_INTERNAL   (1 << 1)
 
#define RENAME(a, b, c, d, e, f, g, h)   (rename_file(g,h));
 
#define RETRIEVE(a, b, c, d)
 
#define SENDMAIL   "/usr/sbin/sendmail -t"
 
#define SMDI_MWI_WAIT_TIMEOUT   1000 /* 1 second */
 
#define STORE(a, b, c, d, e, f, g, h, i, j, k)
 
#define tdesc   "Comedian Mail (Voicemail System)"
 
#define UPDATE_MSG_ID(a, b, c, d, e, f)
 
#define VALID_DTMF   "1234567890*#" /* Yes ABCD are valid dtmf but what phones have those? */
 
#define VM_ALLOCED   (1 << 13)
 
#define VM_ATTACH   (1 << 11)
 
#define VM_DELETE   (1 << 12)
 
#define VM_DIRECTFORWARD   (1 << 10)
 
#define VM_EMAIL_EXT_RECS   (1 << 19)
 
#define VM_ENVELOPE   (1 << 4)
 
#define VM_FORCEGREET   (1 << 8)
 
#define VM_FORCENAME   (1 << 7)
 
#define VM_FWDURGAUTO   (1 << 18)
 
#define VM_MARK_URGENT   (1 << 20)
 
#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_STRING_HEADER_FORMAT   "%-8.8s %-32.32s %-32.32s %-9.9s %-6.6s %-30.30s\n"
 
#define VM_SVMAIL   (1 << 3)
 
#define VM_TEMPGREETWARN   (1 << 15)
 
#define VMBOX_STRING_DATA_FORMAT   "%-32.32s %-32.32s %-16.16s %-16.16s %-16.16s %-16.16s\n"
 
#define VMBOX_STRING_HEADER_FORMAT   "%-32.32s %-32.32s %-16.16s %-16.16s %-16.16s %-16.16s\n"
 
#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 , NEW_FOLDER = 0 , OLD_FOLDER = 1 ,
  WORK_FOLDER = 2 , FAMILY_FOLDER = 3 , FRIENDS_FOLDER = 4 , GREETINGS_FOLDER = -1 ,
  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 , OPT_ARG_RECORDGAIN = 0 , OPT_ARG_PLAYFOLDER = 1 , OPT_ARG_DTMFEXIT = 2 ,
  OPT_ARG_BEEP_TONE = 3 , OPT_ARG_ARRAY_SIZE = 4 , OPT_ARG_RECORDGAIN = 0 , OPT_ARG_PLAYFOLDER = 1 ,
  OPT_ARG_DTMFEXIT = 2 , OPT_ARG_BEEP_TONE = 3 , OPT_ARG_ARRAY_SIZE = 4
}
 
enum  vm_option_flags {
  OPT_SILENT = (1 << 0) , OPT_BUSY_GREETING = (1 << 1) , OPT_UNAVAIL_GREETING = (1 << 2) , OPT_RECORDGAIN = (1 << 3) ,
  OPT_PREPEND_MAILBOX = (1 << 4) , OPT_AUTOPLAY = (1 << 6) , OPT_DTMFEXIT = (1 << 7) , OPT_MESSAGE_Urgent = (1 << 8) ,
  OPT_MESSAGE_PRIORITY = (1 << 9) , OPT_EARLYM_GREETING = (1 << 10) , OPT_BEEP = (1 << 11) , OPT_SILENT_IF_GREET = (1 << 12) ,
  OPT_READONLY = (1 << 13) , OPT_SILENT = (1 << 0) , OPT_BUSY_GREETING = (1 << 1) , OPT_UNAVAIL_GREETING = (1 << 2) ,
  OPT_RECORDGAIN = (1 << 3) , OPT_PREPEND_MAILBOX = (1 << 4) , OPT_AUTOPLAY = (1 << 6) , OPT_DTMFEXIT = (1 << 7) ,
  OPT_MESSAGE_Urgent = (1 << 8) , OPT_MESSAGE_PRIORITY = (1 << 9) , OPT_EARLYM_GREETING = (1 << 10) , OPT_BEEP = (1 << 11) ,
  OPT_SILENT_IF_GREET = (1 << 12) , OPT_READONLY = (1 << 13) , OPT_SILENT = (1 << 0) , OPT_BUSY_GREETING = (1 << 1) ,
  OPT_UNAVAIL_GREETING = (1 << 2) , OPT_RECORDGAIN = (1 << 3) , OPT_PREPEND_MAILBOX = (1 << 4) , OPT_AUTOPLAY = (1 << 6) ,
  OPT_DTMFEXIT = (1 << 7) , OPT_MESSAGE_Urgent = (1 << 8) , OPT_MESSAGE_PRIORITY = (1 << 9) , OPT_EARLYM_GREETING = (1 << 10) ,
  OPT_BEEP = (1 << 11) , OPT_SILENT_IF_GREET = (1 << 12) , OPT_READONLY = (1 << 13)
}
 
enum  vm_passwordlocation {
  OPT_PWLOC_VOICEMAILCONF = 0 , OPT_PWLOC_SPOOLDIR = 1 , OPT_PWLOC_USERSCONF = 2 , OPT_PWLOC_VOICEMAILCONF = 0 ,
  OPT_PWLOC_SPOOLDIR = 1 , OPT_PWLOC_USERSCONF = 2 , 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_vmbox_info_astman (struct mansession *s, const struct message *m, struct ast_vm_user *vmu, const char *event_name, const char *actionid)
 Append vmbox info string into given astman with event_name. More...
 
static int append_vmu_info_astman (struct mansession *s, struct ast_vm_user *vmu, const char *event_name, const char *actionid)
 Append vmu info string into given astman with event_name. More...
 
static void apply_option (struct ast_vm_user *vmu, const char *var, const char *value)
 Sets a specific property value. More...
 
static void apply_options (struct ast_vm_user *vmu, const char *options)
 Destructively Parse options and apply. More...
 
static void apply_options_full (struct ast_vm_user *retval, struct ast_variable *var)
 Loads the options specific to a voicemail user. More...
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static const char * ast_str_encode_mime (struct ast_str **end, ssize_t maxlen, const char *start, size_t preamble, size_t postamble)
 Encode a string according to the MIME rules for encoding strings that are not 7-bit clean or contain control characters. More...
 
static const char * ast_str_quote (struct ast_str **buf, ssize_t maxlen, const char *from)
 Wraps a character sequence in double quotes, escaping occurences of quotes within the string. More...
 
static int change_password_realtime (struct ast_vm_user *vmu, const char *password)
 Performs a change of the voicemail passowrd in the realtime engine. More...
 
static int check_mime (const char *str)
 Check if the string would need encoding within the MIME standard, to avoid confusing certain mail software that expects messages to be 7-bit clean. More...
 
static int check_password (struct ast_vm_user *vmu, char *password)
 Check that password meets minimum required length. More...
 
static int close_mailbox (struct vm_state *vms, struct ast_vm_user *vmu)
 
static char * complete_voicemail_move_message (struct ast_cli_args *a, int maxpos)
 
static char * complete_voicemail_show_mailbox (struct ast_cli_args *a)
 
static char * complete_voicemail_show_users (const char *line, const char *word, int pos, int state)
 
static int copy (char *infile, char *outfile)
 Utility function to copy a file. More...
 
static int copy_message (struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt, char *dir, const char *flag, const char *dest_folder)
 Copies a message from one mailbox to another. More...
 
static void copy_plain_file (char *frompath, char *topath)
 Copies a voicemail information (envelope) file. More...
 
static int count_messages (struct ast_vm_user *vmu, char *dir)
 Find all .txt files - even if they are not in sequence from 0000. More...
 
static int create_dirpath (char *dest, int len, const char *context, const char *ext, const char *folder)
 basically mkdir -p $dest/$context/$ext/$folder More...
 
static int dialout (struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)
 
static struct ast_vm_userfind_or_create (const char *context, const char *box)
 
static struct ast_vm_userfind_user (struct ast_vm_user *ivm, const char *context, const char *mailbox)
 Finds a voicemail user from the users file or the realtime engine. More...
 
static struct ast_vm_userfind_user_realtime (struct ast_vm_user *ivm, const char *context, const char *mailbox)
 Finds a voicemail user from the realtime engine. More...
 
static int forward_message (struct ast_channel *chan, char *context, struct vm_state *vms, struct ast_vm_user *sender, char *fmt, int is_new_message, signed char record_gain, int urgent)
 Sends a voicemail message to a mailbox recipient. More...
 
static int forward_message_from_mailbox (struct ast_cli_args *a)
 
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_forward_message (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_voicemail_move_message (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
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_remove_message (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
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_mailbox (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_voicemail_show_users (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show a list of voicemail users in the CLI. More...
 
static char * handle_voicemail_show_zones (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show a list of voicemail zones in the CLI. More...
 
static int has_voicemail (const char *mailbox, const char *folder)
 Determines if the given folder has messages. More...
 
static int inboxcount (const char *mailbox, int *newmsgs, int *oldmsgs)
 
static int inboxcount2 (const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
 Check the given mailbox's message count. More...
 
static int inprocess_cmp_fn (void *obj, void *arg, int flags)
 
static int inprocess_count (const char *context, const char *mailbox, int delta)
 
static int inprocess_hash_fn (const void *obj, const int flags)
 
static int invent_message (struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes)
 
static int is_valid_dtmf (const char *key)
 Determines if a DTMF key entered is valid. More...
 
static int last_message_index (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_force (int reload, int force)
 Reload voicemail.conf. More...
 
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_get_mailbox_summary (struct mansession *s, const struct message *m)
 
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_forward (struct mansession *s, const struct message *m)
 
static int manager_voicemail_move (struct mansession *s, const struct message *m)
 
static int manager_voicemail_refresh (struct mansession *s, const struct message *m)
 
static int manager_voicemail_remove (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 move_message_from_mailbox (struct ast_cli_args *a)
 
static int msg_create_from_file (struct ast_vm_recording_data *recdata)
 
static void mwi_handle_subscribe (const char *id, struct ast_mwi_subscriber *sub)
 
static int mwi_handle_subscribe2 (void *data)
 
static void mwi_handle_unsubscribe (const char *id, struct ast_mwi_subscriber *sub)
 
static int mwi_handle_unsubscribe2 (void *data)
 
static int notify_new_message (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msgnum, long duration, char *fmt, char *cidnum, char *cidname, const char *flag)
 Sends email notification that a user has a new voicemail waiting for them. More...
 
static void notify_new_state (struct ast_vm_user *vmu)
 
static int open_mailbox (struct vm_state *vms, struct ast_vm_user *vmu, int box)
 
static int play_message (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
 
static int play_message_by_id (struct ast_channel *chan, const char *mailbox, const char *context, const char *msg_id)
 Finds a message in a specific mailbox by msg_id and plays it to the channel. More...
 
static int play_message_by_id_helper (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, const char *msg_id)
 
static int play_message_callerid (struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback, int saycidnumber)
 
static int play_message_category (struct ast_channel *chan, const char *category)
 
static int play_message_datetime (struct ast_channel *chan, struct ast_vm_user *vmu, const char *origtime, const char *filename)
 
static int play_message_duration (struct ast_channel *chan, struct vm_state *vms, const char *duration, int minduration)
 
static int play_record_review (struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, int *sound_duration, const char *unlockdir, signed char record_gain, struct vm_state *vms, char *flag, const char *msg_id, int forwardintro)
 
static int poll_subscribed_mailbox (struct ast_mwi_state *mwi_state, void *data)
 
static void populate_defaults (struct ast_vm_user *vmu)
 Sets default voicemail system options to a voicemail user. More...
 
static void prep_email_sub_vars (struct ast_channel *ast, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *dur, char *date, const char *category, const char *flag)
 
static void print_mappings (void *v_obj, void *where, ao2_prnt_fn *prnt)
 
static void queue_mwi_event (const char *channel_id, const char *box, int urgent, int new, int old)
 
static void read_password_from_file (const char *secretfn, char *password, int passwordlen)
 
static int reload (void)
 
static int remove_message_from_mailbox (struct ast_cli_args *a)
 
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 int show_mailbox_details (struct ast_cli_args *a)
 
static int show_mailbox_snapshot (struct ast_cli_args *a)
 
static int show_messages_for_mailbox (struct ast_cli_args *a)
 
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, int nodelete)
 
static int vm_instructions_en (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int skipadvanced, int in_urgent, int nodelete)
 
static int vm_instructions_ja (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int skipadvanced, int in_urgent, int nodelete)
 
static int vm_instructions_zh (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int skipadvanced, int in_urgent, int nodelete)
 
static int vm_intro (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
 
static int vm_intro_cs (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_da (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_de (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_en (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_es (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_fr (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_gr (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_he (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_is (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_it (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_ja (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_multilang (struct ast_channel *chan, struct vm_state *vms, const char message_gender[])
 
static int vm_intro_nl (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_no (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_pl (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_pt (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_pt_BR (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_se (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_vi (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_intro_zh (struct ast_channel *chan, struct vm_state *vms)
 
static int vm_lock_path (const char *path)
 Lock file path only return failure if ast_lock_path returns 'timeout', not if the path does not exist or any other reason. More...
 
static struct ast_vm_mailbox_snapshotvm_mailbox_snapshot_create (const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
 
static struct ast_vm_mailbox_snapshotvm_mailbox_snapshot_destroy (struct ast_vm_mailbox_snapshot *mailbox_snapshot)
 
static int vm_msg_forward (const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
 
static int vm_msg_move (const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
 
static int vm_msg_play (struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb cb)
 
static int vm_msg_remove (const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
 
static struct ast_vm_msg_snapshotvm_msg_snapshot_alloc (void)
 
static int vm_msg_snapshot_create (struct ast_vm_user *vmu, struct vm_state *vms, struct ast_vm_mailbox_snapshot *mailbox_snapshot, int snapshot_index, int mailbox_index, int descending, enum ast_vm_snapshot_sort_val sort_val)
 Create and store off all the msgs in an open mailbox. More...
 
static struct ast_vm_msg_snapshotvm_msg_snapshot_destroy (struct ast_vm_msg_snapshot *msg_snapshot)
 
static int vm_newuser_setup (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
 
static int vm_options (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
 
static int vm_play_folder_name (struct ast_channel *chan, char *mbox)
 
static int vm_play_folder_name_gr (struct ast_channel *chan, char *box)
 
static int vm_play_folder_name_ja (struct ast_channel *chan, char *box)
 
static int vm_play_folder_name_pl (struct ast_channel *chan, char *box)
 
static int vm_play_folder_name_ua (struct ast_channel *chan, char *box)
 
static int vm_playmsgexec (struct ast_channel *chan, const char *data)
 
static int vm_sayname (struct ast_channel *chan, const char *mailbox_id)
 
static int vm_tempgreeting (struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
 The handler for 'record a temporary greeting'. More...
 
static int vmauthenticate (struct ast_channel *chan, const char *data)
 
static int vmsayname_exec (struct ast_channel *chan, const char *data)
 
static const struct ast_tmvmu_tm (const struct ast_vm_user *vmu, struct ast_tm *tm)
 fill in *tm for current time according to the proper timezone, if any. More...
 
static int wait_file (struct ast_channel *chan, struct vm_state *vms, char *file)
 
static int wait_file2 (struct ast_channel *chan, struct vm_state *vms, char *file)
 
static int write_password_to_file (const char *secretfn, const char *password)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Comedian Mail (Voicemail System)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, .optional_modules = "res_adsi,res_smdi", }
 
static char * addesc = "Comedian Mail"
 
static unsigned char adsifdn [4] = "\x00\x00\x00\x0F"
 
static unsigned char adsisec [4] = "\x9B\xDB\xF7\xAC"
 
static int adsiver = 1
 
static struct ao2_containeralias_mailbox_mappings
 
static char aliasescontext [MAX_VM_CONTEXT_LEN]
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static char callcontext [AST_MAX_CONTEXT] = ""
 
static char charset [32] = "ISO-8859-1"
 
static char cidinternalcontexts [MAX_NUM_CID_CONTEXTS][64]
 
static struct ast_cli_entry cli_voicemail []
 
static char dialcontext [AST_MAX_CONTEXT] = ""
 
static char * emailbody
 
static char emaildateformat [32] = "%A, %B %d, %Y at %r"
 
static char * emailsubject
 
static char exitcontext [AST_MAX_CONTEXT] = ""
 
static char ext_pass_check_cmd [128]
 
static char ext_pass_cmd [128]
 
static char externnotify [160]
 
static char fromstring [100]
 
static struct ast_flags globalflags = {0}
 
struct ao2_containerinprocess_container
 
static char listen_control_forward_key [12]
 
static char listen_control_pause_key [12]
 
static char listen_control_restart_key [12]
 
static char listen_control_reverse_key [12]
 
static char listen_control_stop_key [12]
 
static char locale [20]
 
static struct ao2_containermailbox_alias_mappings
 
static const char *const mailbox_folders []
 
static char mailcmd [160] = SENDMAIL
 
static int maxdeletedmsg
 
static int maxgreet
 
static int maxlogins = 3
 
static int maxmsg = MAXMSG
 
static int maxsilence
 
static int minpassword = MINPASSWORD
 
static int msg_id_incrementor
 
struct ast_mwi_observer mwi_observer
 
static struct ast_taskprocessormwi_subscription_tps
 
static int my_umask
 
static char * pagerbody
 
static char pagerdateformat [32] = "%A, %B %d, %Y at %r"
 
static char pagerfromstring [100]
 
static char * pagersubject
 
static int passwordlocation
 
static char * playmsg_app = "VoiceMailPlayMsg"
 
static ast_cond_t poll_cond = PTHREAD_COND_INITIALIZER
 
static unsigned int poll_freq = DEFAULT_POLL_FREQ
 
static ast_mutex_t poll_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static unsigned int poll_mailboxes
 
static pthread_t poll_thread = AST_PTHREADT_NULL
 
static unsigned char poll_thread_run
 
static int pwdchange = PWDCHANGE_INTERNAL
 
static int saydurationminfo = 2
 
static char * sayname_app = "VMSayName"
 
static char serveremail [80] = ASTERISK_USERNAME
 
static int silencethreshold = 128
 
static int skipms = 3000
 
static struct ast_smdi_interfacesmdi_iface = NULL
 
static struct users users = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static char userscontext [AST_MAX_EXTENSION] = "default"
 
static const struct ast_app_option vm_app_options [128] = { [ 's' ] = { .flag = OPT_SILENT }, [ 'S' ] = { .flag = OPT_SILENT_IF_GREET }, [ 'b' ] = { .flag = OPT_BUSY_GREETING }, [ 'u' ] = { .flag = OPT_UNAVAIL_GREETING }, [ 'g' ] = { .flag = OPT_RECORDGAIN , .arg_index = OPT_ARG_RECORDGAIN + 1 }, [ 'd' ] = { .flag = OPT_DTMFEXIT , .arg_index = OPT_ARG_DTMFEXIT + 1 }, [ 'p' ] = { .flag = OPT_PREPEND_MAILBOX }, [ 'a' ] = { .flag = OPT_AUTOPLAY , .arg_index = OPT_ARG_PLAYFOLDER + 1 }, [ 'U' ] = { .flag = OPT_MESSAGE_Urgent }, [ 'P' ] = { .flag = OPT_MESSAGE_PRIORITY }, [ 'e' ] = { .flag = OPT_EARLYM_GREETING }, [ 't' ] = { .flag = OPT_BEEP , .arg_index = OPT_ARG_BEEP_TONE + 1 }, [ 'r' ] = { .flag = OPT_READONLY }, }
 
static const struct ast_vm_greeter_functions vm_greeter_table
 
static struct ast_custom_function vm_info_acf
 
static char vm_invalid_password [80] = "vm-invalid-password"
 
static char vm_login [80] = "vm-login"
 
static char vm_mismatch [80] = "vm-mismatch"
 
static char vm_newpassword [80] = "vm-newpassword"
 
static char vm_newuser [80] = "vm-newuser"
 
static char vm_passchanged [80] = "vm-passchanged"
 
static char vm_password [80] = "vm-password"
 
static char vm_pls_try_again [80] = "vm-pls-try-again"
 
static char vm_prepend_timeout [80] = "vm-then-pound"
 
static char vm_reenterpassword [80] = "vm-reenterpassword"
 
static char VM_SPOOL_DIR [PATH_MAX]
 
static const struct ast_vm_functions vm_table
 
static char * vmauthenticate_app = "VMAuthenticate"
 
static char vmfmts [80] = "wav"
 
static int vmmaxsecs
 
static int vmminsecs
 
static char * voicemail_app = "VoiceMail"
 
static char * voicemailmain_app = "VoiceMailMain"
 
static double volgain
 
static struct zones zones = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static char zonetag [80]
 

Detailed Description

Comedian Mail - Voicemail System.

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

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

See also
Note
For information about voicemail IMAP storage, https://docs.asterisk.org/Configuration/Applications/Voicemail/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_imap.c.

Macro Definition Documentation

◆ ALIASES_OUTPUT_FORMAT

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

◆ ASTERISK_USERNAME

#define ASTERISK_USERNAME   "asterisk"

Definition at line 638 of file app_voicemail_imap.c.

◆ CHUNKSIZE

#define CHUNKSIZE   65536

Definition at line 635 of file app_voicemail_imap.c.

◆ COMMAND_TIMEOUT

#define COMMAND_TIMEOUT   5000

Definition at line 631 of file app_voicemail_imap.c.

◆ COPY

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

Definition at line 1005 of file app_voicemail_imap.c.

◆ DEFAULT_LISTEN_CONTROL_FORWARD_KEY

#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY   "#"

Definition at line 643 of file app_voicemail_imap.c.

◆ DEFAULT_LISTEN_CONTROL_PAUSE_KEY

#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY   "0"

Definition at line 645 of file app_voicemail_imap.c.

◆ DEFAULT_LISTEN_CONTROL_RESTART_KEY

#define DEFAULT_LISTEN_CONTROL_RESTART_KEY   "2"

Definition at line 646 of file app_voicemail_imap.c.

◆ DEFAULT_LISTEN_CONTROL_REVERSE_KEY

#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY   "*"

Definition at line 644 of file app_voicemail_imap.c.

◆ DEFAULT_LISTEN_CONTROL_STOP_KEY

#define DEFAULT_LISTEN_CONTROL_STOP_KEY   "13456789"

Definition at line 647 of file app_voicemail_imap.c.

◆ DEFAULT_POLL_FREQ

#define DEFAULT_POLL_FREQ   30

By default, poll every 30 seconds

Definition at line 1076 of file app_voicemail_imap.c.

◆ DELETE

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

Definition at line 1006 of file app_voicemail_imap.c.

◆ DISPOSE

#define DISPOSE (   a,
  b 
)

Definition at line 1001 of file app_voicemail_imap.c.

◆ ENDL

#define ENDL   "\n"

Definition at line 665 of file app_voicemail_imap.c.

◆ ERROR_LOCK_PATH

#define ERROR_LOCK_PATH   -100

Definition at line 692 of file app_voicemail_imap.c.

◆ ERROR_MAX_MSGS

#define ERROR_MAX_MSGS   -101

Definition at line 693 of file app_voicemail_imap.c.

◆ EXISTS

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

Definition at line 1003 of file app_voicemail_imap.c.

◆ force_reload_config

#define force_reload_config ( )    load_config_force(1, 1)

Forcibly reload voicemail.conf, even if it has not changed. This is necessary after running unit tests.

Definition at line 781 of file app_voicemail_imap.c.

◆ HVSU_OUTPUT_FORMAT

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

◆ HVSZ_OUTPUT_FORMAT

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

◆ INTRO

#define INTRO   "vm-intro"

Definition at line 653 of file app_voicemail_imap.c.

◆ MAPPING_BUCKETS

#define MAPPING_BUCKETS   511

Definition at line 1099 of file app_voicemail_imap.c.

◆ MAX_DATETIME_FORMAT

#define MAX_DATETIME_FORMAT   512

Definition at line 668 of file app_voicemail_imap.c.

◆ MAX_MAIL_BODY_CONTENT_SIZE

#define MAX_MAIL_BODY_CONTENT_SIZE   134217728L

Definition at line 655 of file app_voicemail_imap.c.

◆ MAX_NUM_CID_CONTEXTS

#define MAX_NUM_CID_CONTEXTS   10

Definition at line 669 of file app_voicemail_imap.c.

◆ MAX_VM_CONTEXT_LEN

#define MAX_VM_CONTEXT_LEN   (AST_MAX_CONTEXT)

Definition at line 882 of file app_voicemail_imap.c.

◆ MAX_VM_MAILBOX_LEN

#define MAX_VM_MAILBOX_LEN   (MAX_VM_MBOX_ID_LEN + MAX_VM_CONTEXT_LEN)

Definition at line 884 of file app_voicemail_imap.c.

◆ MAX_VM_MBOX_ID_LEN

#define MAX_VM_MBOX_ID_LEN   (AST_MAX_EXTENSION)

Definition at line 881 of file app_voicemail_imap.c.

◆ MAXMSG

#define MAXMSG   100

Definition at line 657 of file app_voicemail_imap.c.

◆ MAXMSGLIMIT

#define MAXMSGLIMIT   9999

Definition at line 658 of file app_voicemail_imap.c.

◆ MINPASSWORD

#define MINPASSWORD   0

Default minimum mailbox password length

Definition at line 660 of file app_voicemail_imap.c.

◆ MSG_ID_LEN

#define MSG_ID_LEN   256

Definition at line 3878 of file app_voicemail_imap.c.

◆ OPERATOR_EXIT

#define OPERATOR_EXIT   300

Definition at line 694 of file app_voicemail_imap.c.

◆ PWDCHANGE_EXTERNAL

#define PWDCHANGE_EXTERNAL   (1 << 2)

Definition at line 1019 of file app_voicemail_imap.c.

◆ PWDCHANGE_INTERNAL

#define PWDCHANGE_INTERNAL   (1 << 1)

Definition at line 1018 of file app_voicemail_imap.c.

◆ RENAME

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

Definition at line 1004 of file app_voicemail_imap.c.

◆ RETRIEVE

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

Definition at line 1000 of file app_voicemail_imap.c.

◆ SENDMAIL

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

Definition at line 652 of file app_voicemail_imap.c.

◆ SMDI_MWI_WAIT_TIMEOUT

#define SMDI_MWI_WAIT_TIMEOUT   1000 /* 1 second */

Definition at line 629 of file app_voicemail_imap.c.

◆ STORE

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

Definition at line 1002 of file app_voicemail_imap.c.

◆ tdesc

#define tdesc   "Comedian Mail (Voicemail System)"

Definition at line 1028 of file app_voicemail_imap.c.

◆ UPDATE_MSG_ID

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

Definition at line 1007 of file app_voicemail_imap.c.

◆ VALID_DTMF

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

Definition at line 648 of file app_voicemail_imap.c.

◆ VM_ALLOCED

#define VM_ALLOCED   (1 << 13)

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

Definition at line 684 of file app_voicemail_imap.c.

◆ VM_ATTACH

#define VM_ATTACH   (1 << 11)

Attach message to voicemail notifications?

Definition at line 682 of file app_voicemail_imap.c.

◆ VM_DELETE

#define VM_DELETE   (1 << 12)

Delete message after sending notification

Definition at line 683 of file app_voicemail_imap.c.

◆ VM_DIRECTFORWARD

#define VM_DIRECTFORWARD   (1 << 10)

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

Definition at line 681 of file app_voicemail_imap.c.

◆ VM_EMAIL_EXT_RECS

#define VM_EMAIL_EXT_RECS   (1 << 19)

Send voicemail emails when an external recording is added to a mailbox

Definition at line 690 of file app_voicemail_imap.c.

◆ VM_ENVELOPE

#define VM_ENVELOPE   (1 << 4)

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

Definition at line 675 of file app_voicemail_imap.c.

◆ VM_FORCEGREET

#define VM_FORCEGREET   (1 << 8)

Have new users record their greetings

Definition at line 679 of file app_voicemail_imap.c.

◆ VM_FORCENAME

#define VM_FORCENAME   (1 << 7)

Have new users record their name

Definition at line 678 of file app_voicemail_imap.c.

◆ VM_FWDURGAUTO

#define VM_FWDURGAUTO   (1 << 18)

Autoset of Urgent flag on forwarded Urgent messages set globally

Definition at line 689 of file app_voicemail_imap.c.

◆ VM_MARK_URGENT

#define VM_MARK_URGENT   (1 << 20)

After recording, permit the caller to mark the message as urgent

Definition at line 691 of file app_voicemail_imap.c.

◆ VM_MESSAGEWRAP

#define VM_MESSAGEWRAP   (1 << 17)

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

Definition at line 688 of file app_voicemail_imap.c.

◆ VM_MOVEHEARD

#define VM_MOVEHEARD   (1 << 16)

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

Definition at line 687 of file app_voicemail_imap.c.

◆ VM_OPERATOR

#define VM_OPERATOR   (1 << 1)

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

Definition at line 672 of file app_voicemail_imap.c.

◆ VM_PBXSKIP

#define VM_PBXSKIP   (1 << 9)

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

Definition at line 680 of file app_voicemail_imap.c.

◆ VM_REVIEW

#define VM_REVIEW   (1 << 0)

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

Definition at line 671 of file app_voicemail_imap.c.

◆ VM_SAYCID

#define VM_SAYCID   (1 << 2)

Repeat the CallerID info during envelope playback

Definition at line 673 of file app_voicemail_imap.c.

◆ VM_SAYDURATION

#define VM_SAYDURATION   (1 << 5)

Play the length of the message during envelope playback

Definition at line 676 of file app_voicemail_imap.c.

◆ VM_SEARCH

#define VM_SEARCH   (1 << 14)

Search all contexts for a matching mailbox

Definition at line 685 of file app_voicemail_imap.c.

◆ VM_SKIPAFTERCMD

#define VM_SKIPAFTERCMD   (1 << 6)

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

Definition at line 677 of file app_voicemail_imap.c.

◆ VM_STRING_HEADER_FORMAT

#define VM_STRING_HEADER_FORMAT   "%-8.8s %-32.32s %-32.32s %-9.9s %-6.6s %-30.30s\n"

◆ VM_SVMAIL

#define VM_SVMAIL   (1 << 3)

Allow the user to compose a new VM from within VoicemailMain

Definition at line 674 of file app_voicemail_imap.c.

◆ VM_TEMPGREETWARN

#define VM_TEMPGREETWARN   (1 << 15)

Remind user tempgreeting is set

Definition at line 686 of file app_voicemail_imap.c.

◆ VMBOX_STRING_DATA_FORMAT

#define VMBOX_STRING_DATA_FORMAT   "%-32.32s %-32.32s %-16.16s %-16.16s %-16.16s %-16.16s\n"

◆ VMBOX_STRING_HEADER_FORMAT

#define VMBOX_STRING_HEADER_FORMAT   "%-32.32s %-32.32s %-16.16s %-16.16s %-16.16s %-16.16s\n"

◆ VMSTATE_MAX_MSG_ARRAY

#define VMSTATE_MAX_MSG_ARRAY   256

Definition at line 936 of file app_voicemail_imap.c.

◆ VOICEMAIL_CONFIG

#define VOICEMAIL_CONFIG   "voicemail.conf"

Definition at line 637 of file app_voicemail_imap.c.

◆ VOICEMAIL_DIR_MODE

#define VOICEMAIL_DIR_MODE   0777

Definition at line 633 of file app_voicemail_imap.c.

◆ VOICEMAIL_FILE_MODE

#define VOICEMAIL_FILE_MODE   0666

Definition at line 634 of file app_voicemail_imap.c.

Enumeration Type Documentation

◆ vm_box

enum vm_box
Enumerator
NEW_FOLDER 
OLD_FOLDER 
WORK_FOLDER 
FAMILY_FOLDER 
FRIENDS_FOLDER 
GREETINGS_FOLDER 
NEW_FOLDER 
OLD_FOLDER 
WORK_FOLDER 
FAMILY_FOLDER 
FRIENDS_FOLDER 
GREETINGS_FOLDER 
NEW_FOLDER 
OLD_FOLDER 
WORK_FOLDER 
FAMILY_FOLDER 
FRIENDS_FOLDER 
GREETINGS_FOLDER 

Definition at line 696 of file app_voicemail_imap.c.

696 {
697 NEW_FOLDER = 0,
698 OLD_FOLDER = 1,
699 WORK_FOLDER = 2,
700 FAMILY_FOLDER = 3,
701 FRIENDS_FOLDER = 4,
703};
@ FRIENDS_FOLDER
@ NEW_FOLDER
@ GREETINGS_FOLDER
@ FAMILY_FOLDER
@ WORK_FOLDER
@ OLD_FOLDER

◆ vm_option_args

Enumerator
OPT_ARG_RECORDGAIN 
OPT_ARG_PLAYFOLDER 
OPT_ARG_DTMFEXIT 
OPT_ARG_BEEP_TONE 
OPT_ARG_ARRAY_SIZE 
OPT_ARG_RECORDGAIN 
OPT_ARG_PLAYFOLDER 
OPT_ARG_DTMFEXIT 
OPT_ARG_BEEP_TONE 
OPT_ARG_ARRAY_SIZE 
OPT_ARG_RECORDGAIN 
OPT_ARG_PLAYFOLDER 
OPT_ARG_DTMFEXIT 
OPT_ARG_BEEP_TONE 
OPT_ARG_ARRAY_SIZE 

Definition at line 721 of file app_voicemail_imap.c.

721 {
726 /* This *must* be the last value in this enum! */
728};
@ OPT_ARG_RECORDGAIN
@ OPT_ARG_PLAYFOLDER
@ OPT_ARG_BEEP_TONE
@ OPT_ARG_ARRAY_SIZE
@ OPT_ARG_DTMFEXIT

◆ vm_option_flags

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

Definition at line 705 of file app_voicemail_imap.c.

705 {
706 OPT_SILENT = (1 << 0),
707 OPT_BUSY_GREETING = (1 << 1),
708 OPT_UNAVAIL_GREETING = (1 << 2),
709 OPT_RECORDGAIN = (1 << 3),
710 OPT_PREPEND_MAILBOX = (1 << 4),
711 OPT_AUTOPLAY = (1 << 6),
712 OPT_DTMFEXIT = (1 << 7),
713 OPT_MESSAGE_Urgent = (1 << 8),
714 OPT_MESSAGE_PRIORITY = (1 << 9),
715 OPT_EARLYM_GREETING = (1 << 10),
716 OPT_BEEP = (1 << 11),
717 OPT_SILENT_IF_GREET = (1 << 12),
718 OPT_READONLY = (1 << 13),
719};
@ OPT_MESSAGE_PRIORITY
@ OPT_PREPEND_MAILBOX
@ OPT_BEEP
@ OPT_BUSY_GREETING
@ OPT_RECORDGAIN
@ OPT_EARLYM_GREETING
@ OPT_SILENT_IF_GREET
@ OPT_UNAVAIL_GREETING
@ OPT_READONLY
@ OPT_SILENT
@ OPT_DTMFEXIT
@ OPT_MESSAGE_Urgent
@ OPT_AUTOPLAY

◆ vm_passwordlocation

Enumerator
OPT_PWLOC_VOICEMAILCONF 
OPT_PWLOC_SPOOLDIR 
OPT_PWLOC_USERSCONF 
OPT_PWLOC_VOICEMAILCONF 
OPT_PWLOC_SPOOLDIR 
OPT_PWLOC_USERSCONF 
OPT_PWLOC_VOICEMAILCONF 
OPT_PWLOC_SPOOLDIR 
OPT_PWLOC_USERSCONF 

Definition at line 730 of file app_voicemail_imap.c.

730 {
734};
@ OPT_PWLOC_USERSCONF
@ OPT_PWLOC_SPOOLDIR
@ OPT_PWLOC_VOICEMAILCONF

Function Documentation

◆ __has_voicemail()

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

Definition at line 6057 of file app_voicemail_imap.c.

6058{
6059 DIR *dir;
6060 struct dirent *de;
6061 char fn[256];
6062 int ret = 0;
6063 struct alias_mailbox_mapping *mapping;
6064 char *c;
6065 char *m;
6066
6067 /* If no mailbox, return immediately */
6069 return 0;
6070
6071 if (ast_strlen_zero(folder))
6072 folder = "INBOX";
6074 context = "default";
6075
6076 c = (char *)context;
6077 m = (char *)mailbox;
6078
6080 char tmp[MAX_VM_MAILBOX_LEN];
6081
6082 snprintf(tmp, MAX_VM_MAILBOX_LEN, "%s@%s", mailbox, context);
6084 if (mapping) {
6085 separate_mailbox(ast_strdupa(mapping->mailbox), &m, &c);
6086 ao2_ref(mapping, -1);
6087 }
6088 }
6089
6090 snprintf(fn, sizeof(fn), "%s%s/%s/%s", VM_SPOOL_DIR, c, m, folder);
6091
6092 if (!(dir = opendir(fn)))
6093 return 0;
6094
6095 while ((de = readdir(dir))) {
6096 if (!strncasecmp(de->d_name, "msg", 3)) {
6097 if (shortcircuit) {
6098 ret = 1;
6099 break;
6100 } else if (!strncasecmp(de->d_name + 8, "txt", 3)) {
6101 ret++;
6102 }
6103 }
6104 }
6105
6106 closedir(dir);
6107
6108 return ret;
6109}
static int separate_mailbox(char *mailbox_id, char **mailbox, char **context)
static char aliasescontext[MAX_VM_CONTEXT_LEN]
#define MAX_VM_MAILBOX_LEN
static char VM_SPOOL_DIR[PATH_MAX]
static struct ao2_container * alias_mailbox_mappings
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
static int tmp()
Definition: bt_open.c:389
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
static struct test_val c

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

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

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 17323 of file app_voicemail_imap.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 17323 of file app_voicemail_imap.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 13130 of file app_voicemail_imap.c.

13131{
13132 struct ast_vm_user svm;
13133 struct ast_vm_user *vmu = NULL;
13134 char *parse;
13135 char *mailbox;
13136 char *context;
13137 int res = 0;
13138
13140 AST_APP_ARG(mailbox_context);
13141 AST_APP_ARG(attribute);
13142 AST_APP_ARG(folder);
13143 );
13144
13145 buf[0] = '\0';
13146
13147 if (ast_strlen_zero(args)) {
13148 ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
13149 return -1;
13150 }
13151
13152 parse = ast_strdupa(args);
13153 AST_STANDARD_APP_ARGS(arg, parse);
13154
13155 if (ast_strlen_zero(arg.mailbox_context)
13156 || ast_strlen_zero(arg.attribute)
13157 || separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
13158 ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
13159 return -1;
13160 }
13161
13162 memset(&svm, 0, sizeof(svm));
13163 vmu = find_user(&svm, context, mailbox);
13164
13165 if (!strncasecmp(arg.attribute, "exists", 5)) {
13166 ast_copy_string(buf, vmu ? "1" : "0", len);
13167 free_user(vmu);
13168 return 0;
13169 }
13170
13171 if (vmu) {
13172 if (!strncasecmp(arg.attribute, "password", 8)) {
13174 } else if (!strncasecmp(arg.attribute, "fullname", 8)) {
13176 } else if (!strncasecmp(arg.attribute, "email", 5)) {
13177 ast_copy_string(buf, vmu->email, len);
13178 } else if (!strncasecmp(arg.attribute, "pager", 5)) {
13179 ast_copy_string(buf, vmu->pager, len);
13180 } else if (!strncasecmp(arg.attribute, "language", 8)) {
13182 } else if (!strncasecmp(arg.attribute, "locale", 6)) {
13183 ast_copy_string(buf, vmu->locale, len);
13184 } else if (!strncasecmp(arg.attribute, "tz", 2)) {
13186 } else if (!strncasecmp(arg.attribute, "count", 5)) {
13187 char *mailbox_id;
13188
13189 mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
13190 sprintf(mailbox_id, "%s@%s", mailbox, context);/* Safe */
13191
13192 /* If mbxfolder is empty messagecount will default to INBOX */
13193 res = messagecount(mailbox_id, arg.folder);
13194 if (res < 0) {
13195 ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
13196 free_user(vmu);
13197 return -1;
13198 }
13199 snprintf(buf, len, "%d", res);
13200 } else {
13201 ast_log(LOG_ERROR, "Unknown attribute '%s' for VM_INFO\n", arg.attribute);
13202 free_user(vmu);
13203 return -1;
13204 }
13205 free_user(vmu);
13206 }
13207
13208 return 0;
13209}
static void free_user(struct ast_vm_user *vmu)
static int messagecount(const char *mailbox_id, const char *folder)
static struct ast_vm_user * find_user(struct ast_vm_user *ivm, const char *context, const char *mailbox)
Finds a voicemail user from the users file or the realtime engine.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define ast_log
Definition: astobj2.c:42
const char * ast_channel_language(const struct ast_channel *chan)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define LOG_ERROR
#define NULL
Definition: resample.c:96
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
char pager[80]
char password[80]
char zonetag[80]
char locale[20]
char language[MAX_LANGUAGE]
char fullname[80]
const char * args

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

◆ actual_load_config()

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

Definition at line 14365 of file app_voicemail_imap.c.

14366{
14367 struct ast_vm_user *current;
14368 char *cat;
14369 const char *val;
14370 char *q, *stringp, *tmp;
14371 int x;
14372 unsigned int tmpadsi[4];
14373 char secretfn[PATH_MAX] = "";
14374 long tps_queue_low;
14375 long tps_queue_high;
14376
14377#ifdef IMAP_STORAGE
14378 ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
14379#endif
14380 /* set audio control prompts */
14386
14387#ifdef IMAP_STORAGE
14388 ast_mwi_state_callback_all(imap_close_subscribed_mailbox, NULL);
14389#endif
14390
14391 /* Free all the users structure */
14392 free_vm_users();
14393
14394 /* Free all the zones structure */
14395 free_vm_zones();
14396
14397 /* Remove all aliases */
14400
14402
14403 memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
14404 memset(ext_pass_check_cmd, 0, sizeof(ext_pass_check_cmd));
14405
14406 if (cfg) {
14407 /* General settings */
14408
14409 if (!(val = ast_variable_retrieve(cfg, "general", "userscontext")))
14410 val = "default";
14412
14413 aliasescontext[0] = '\0';
14414 val = ast_variable_retrieve(cfg, "general", "aliasescontext");
14416
14417 /* Attach voice message to mail message ? */
14418 if (!(val = ast_variable_retrieve(cfg, "general", "attach")))
14419 val = "yes";
14421
14422 if (!(val = ast_variable_retrieve(cfg, "general", "searchcontexts")))
14423 val = "no";
14425
14426 volgain = 0.0;
14427 if ((val = ast_variable_retrieve(cfg, "general", "volgain")))
14428 sscanf(val, "%30lf", &volgain);
14429
14430#ifdef ODBC_STORAGE
14431 strcpy(odbc_database, "asterisk");
14432 if ((val = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
14433 ast_copy_string(odbc_database, val, sizeof(odbc_database));
14434 }
14435 strcpy(odbc_table, "voicemessages");
14436 if ((val = ast_variable_retrieve(cfg, "general", "odbctable"))) {
14437 ast_copy_string(odbc_table, val, sizeof(odbc_table));
14438 }
14439#endif
14440 /* Mail command */
14441 strcpy(mailcmd, SENDMAIL);
14442 if ((val = ast_variable_retrieve(cfg, "general", "mailcmd")))
14443 ast_copy_string(mailcmd, val, sizeof(mailcmd)); /* User setting */
14444
14445 maxsilence = 0;
14446 if ((val = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
14447 maxsilence = atoi(val);
14448 if (maxsilence > 0)
14449 maxsilence *= 1000;
14450 }
14451
14452 if (!(val = ast_variable_retrieve(cfg, "general", "maxmsg"))) {
14453 maxmsg = MAXMSG;
14454 } else {
14455 maxmsg = atoi(val);
14456 if (maxmsg < 0) {
14457 ast_log(AST_LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", val, MAXMSG);
14458 maxmsg = MAXMSG;
14459 } else if (maxmsg > MAXMSGLIMIT) {
14460 ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
14462 }
14463 }
14464
14465 if (!(val = ast_variable_retrieve(cfg, "general", "backupdeleted"))) {
14466 maxdeletedmsg = 0;
14467 } else {
14468 if (sscanf(val, "%30d", &x) == 1)
14469 maxdeletedmsg = x;
14470 else if (ast_true(val))
14472 else
14473 maxdeletedmsg = 0;
14474
14475 if (maxdeletedmsg < 0) {
14476 ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox '%s'. Using default value %i\n", val, MAXMSG);
14478 } else if (maxdeletedmsg > MAXMSGLIMIT) {
14479 ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
14481 }
14482 }
14483
14484 /* Load date format config for voicemail mail */
14485 if ((val = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
14487 }
14488
14489 /* Load date format config for voicemail pager mail */
14490 if ((val = ast_variable_retrieve(cfg, "general", "pagerdateformat"))) {
14492 }
14493
14494 /* External password changing command */
14495 if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) {
14498 } else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) {
14501 }
14502
14503 /* External password validation command */
14504 if ((val = ast_variable_retrieve(cfg, "general", "externpasscheck"))) {
14506 ast_debug(1, "found externpasscheck: %s\n", ext_pass_check_cmd);
14507 }
14508
14509#ifdef IMAP_STORAGE
14510 /* IMAP server address */
14511 if ((val = ast_variable_retrieve(cfg, "general", "imapserver"))) {
14512 ast_copy_string(imapserver, val, sizeof(imapserver));
14513 } else {
14514 ast_copy_string(imapserver, "localhost", sizeof(imapserver));
14515 }
14516 /* IMAP server port */
14517 if ((val = ast_variable_retrieve(cfg, "general", "imapport"))) {
14518 ast_copy_string(imapport, val, sizeof(imapport));
14519 } else {
14520 ast_copy_string(imapport, "143", sizeof(imapport));
14521 }
14522 /* IMAP server flags */
14523 if ((val = ast_variable_retrieve(cfg, "general", "imapflags"))) {
14524 ast_copy_string(imapflags, val, sizeof(imapflags));
14525 }
14526 /* IMAP server master username */
14527 if ((val = ast_variable_retrieve(cfg, "general", "authuser"))) {
14528 ast_copy_string(authuser, val, sizeof(authuser));
14529 }
14530 /* IMAP server master password */
14531 if ((val = ast_variable_retrieve(cfg, "general", "authpassword"))) {
14532 ast_copy_string(authpassword, val, sizeof(authpassword));
14533 }
14534 /* Expunge on exit */
14535 if ((val = ast_variable_retrieve(cfg, "general", "expungeonhangup"))) {
14536 if (ast_false(val))
14537 expungeonhangup = 0;
14538 else
14539 expungeonhangup = 1;
14540 } else {
14541 expungeonhangup = 1;
14542 }
14543 /* IMAP voicemail folder */
14544 if ((val = ast_variable_retrieve(cfg, "general", "imapfolder"))) {
14545 ast_copy_string(imapfolder, val, sizeof(imapfolder));
14546 } else {
14547 ast_copy_string(imapfolder, "INBOX", sizeof(imapfolder));
14548 }
14549 if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) {
14550 ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder));
14551 }
14552 if ((val = ast_variable_retrieve(cfg, "general", "imapgreetings"))) {
14553 imapgreetings = ast_true(val);
14554 } else {
14555 imapgreetings = 0;
14556 }
14557 if ((val = ast_variable_retrieve(cfg, "general", "greetingfolder"))) {
14558 ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
14559 } else if ((val = ast_variable_retrieve(cfg, "general", "greetingsfolder"))) {
14560 /* Also support greetingsfolder as documented in voicemail.conf.sample */
14561 ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
14562 } else {
14563 ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder));
14564 }
14565 if ((val = ast_variable_retrieve(cfg, "general", "imap_poll_logout"))) {
14566 imap_poll_logout = ast_true(val);
14567 } else {
14568 imap_poll_logout = 0;
14569 }
14570
14571 /* There is some very unorthodox casting done here. This is due
14572 * to the way c-client handles the argument passed in. It expects a
14573 * void pointer and casts the pointer directly to a long without
14574 * first dereferencing it. */
14575 if ((val = ast_variable_retrieve(cfg, "general", "imapreadtimeout"))) {
14576 mail_parameters(NIL, SET_READTIMEOUT, (void *) (atol(val)));
14577 } else {
14578 mail_parameters(NIL, SET_READTIMEOUT, (void *) 60L);
14579 }
14580
14581 if ((val = ast_variable_retrieve(cfg, "general", "imapwritetimeout"))) {
14582 mail_parameters(NIL, SET_WRITETIMEOUT, (void *) (atol(val)));
14583 } else {
14584 mail_parameters(NIL, SET_WRITETIMEOUT, (void *) 60L);
14585 }
14586
14587 if ((val = ast_variable_retrieve(cfg, "general", "imapopentimeout"))) {
14588 mail_parameters(NIL, SET_OPENTIMEOUT, (void *) (atol(val)));
14589 } else {
14590 mail_parameters(NIL, SET_OPENTIMEOUT, (void *) 60L);
14591 }
14592
14593 if ((val = ast_variable_retrieve(cfg, "general", "imapclosetimeout"))) {
14594 mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) (atol(val)));
14595 } else {
14596 mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L);
14597 }
14598
14599 /* Increment configuration version */
14600 imapversion++;
14601#endif
14602 /* External voicemail notify application */
14603 if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
14605 ast_debug(1, "found externnotify: %s\n", externnotify);
14606 } else {
14607 externnotify[0] = '\0';
14608 }
14609
14610 /* SMDI voicemail notification */
14611 if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
14612 ast_debug(1, "Enabled SMDI voicemail notification\n");
14613 if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
14615 } else {
14616 ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
14617 smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
14618 }
14619 if (!smdi_iface) {
14620 ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
14621 }
14622 }
14623
14624 /* Silence treshold */
14626 if ((val = ast_variable_retrieve(cfg, "general", "silencethreshold")))
14627 silencethreshold = atoi(val);
14628
14629 if (!(val = ast_variable_retrieve(cfg, "general", "serveremail")))
14632
14633 vmmaxsecs = 0;
14634 if ((val = ast_variable_retrieve(cfg, "general", "maxsecs"))) {
14635 if (sscanf(val, "%30d", &x) == 1) {
14636 vmmaxsecs = x;
14637 } else {
14638 ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
14639 }
14640 } else if ((val = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
14641 static int maxmessage_deprecate = 0;
14642 if (maxmessage_deprecate == 0) {
14643 maxmessage_deprecate = 1;
14644 ast_log(AST_LOG_WARNING, "Setting 'maxmessage' has been deprecated in favor of 'maxsecs'.\n");
14645 }
14646 if (sscanf(val, "%30d", &x) == 1) {
14647 vmmaxsecs = x;
14648 } else {
14649 ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
14650 }
14651 }
14652
14653 vmminsecs = 0;
14654 if ((val = ast_variable_retrieve(cfg, "general", "minsecs"))) {
14655 if (sscanf(val, "%30d", &x) == 1) {
14656 vmminsecs = x;
14657 if (maxsilence / 1000 >= vmminsecs) {
14658 ast_log(AST_LOG_WARNING, "maxsilence should be less than minsecs or you may get empty messages\n");
14659 }
14660 } else {
14661 ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
14662 }
14663 } else if ((val = ast_variable_retrieve(cfg, "general", "minmessage"))) {
14664 static int maxmessage_deprecate = 0;
14665 if (maxmessage_deprecate == 0) {
14666 maxmessage_deprecate = 1;
14667 ast_log(AST_LOG_WARNING, "Setting 'minmessage' has been deprecated in favor of 'minsecs'.\n");
14668 }
14669 if (sscanf(val, "%30d", &x) == 1) {
14670 vmminsecs = x;
14671 if (maxsilence / 1000 >= vmminsecs) {
14672 ast_log(AST_LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
14673 }
14674 } else {
14675 ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
14676 }
14677 }
14678
14679 val = ast_variable_retrieve(cfg, "general", "format");
14680 if (!val) {
14681 val = "wav";
14682 } else {
14683 tmp = ast_strdupa(val);
14685 if (!val) {
14686 ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n");
14687 val = "wav";
14688 }
14689 }
14690 ast_copy_string(vmfmts, val, sizeof(vmfmts));
14691
14692 skipms = 3000;
14693 if ((val = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
14694 if (sscanf(val, "%30d", &x) == 1) {
14695 maxgreet = x;
14696 } else {
14697 ast_log(AST_LOG_WARNING, "Invalid max message greeting length\n");
14698 }
14699 }
14700
14701 if ((val = ast_variable_retrieve(cfg, "general", "skipms"))) {
14702 if (sscanf(val, "%30d", &x) == 1) {
14703 skipms = x;
14704 } else {
14705 ast_log(AST_LOG_WARNING, "Invalid skipms value\n");
14706 }
14707 }
14708
14709 maxlogins = 3;
14710 if ((val = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
14711 if (sscanf(val, "%30d", &x) == 1) {
14712 maxlogins = x;
14713 } else {
14714 ast_log(AST_LOG_WARNING, "Invalid max failed login attempts\n");
14715 }
14716 }
14717
14719 if ((val = ast_variable_retrieve(cfg, "general", "minpassword"))) {
14720 if (sscanf(val, "%30d", &x) == 1) {
14721 minpassword = x;
14722 } else {
14723 ast_log(AST_LOG_WARNING, "Invalid minimum password length. Default to %d\n", minpassword);
14724 }
14725 }
14726
14727 /* Force new user to record name ? */
14728 if (!(val = ast_variable_retrieve(cfg, "general", "forcename")))
14729 val = "no";
14731
14732 /* Force new user to record greetings ? */
14733 if (!(val = ast_variable_retrieve(cfg, "general", "forcegreetings")))
14734 val = "no";
14736
14737 if ((val = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) {
14738 ast_debug(1, "VM_CID Internal context string: %s\n", val);
14739 stringp = ast_strdupa(val);
14740 for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
14741 if (!ast_strlen_zero(stringp)) {
14742 q = strsep(&stringp, ",");
14743 while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
14744 q++;
14746 ast_debug(1, "VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
14747 } else {
14748 cidinternalcontexts[x][0] = '\0';
14749 }
14750 }
14751 }
14752 if (!(val = ast_variable_retrieve(cfg, "general", "review"))){
14753 ast_debug(1, "VM Review Option disabled globally\n");
14754 val = "no";
14755 }
14757
14758 if (!(val = ast_variable_retrieve(cfg, "general", "leaveurgent"))){
14759 val = "yes";
14760 } else if (ast_false(val)) {
14761 ast_debug(1, "VM leave urgent messages disabled globally\n");
14762 val = "no";
14763 }
14765
14766 /* Temporary greeting reminder */
14767 if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
14768 ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n");
14769 val = "no";
14770 } else {
14771 ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n");
14772 }
14774 if (!(val = ast_variable_retrieve(cfg, "general", "messagewrap"))){
14775 ast_debug(1, "VM next message wrap disabled globally\n");
14776 val = "no";
14777 }
14779
14780 if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){
14781 ast_debug(1, "VM Operator break disabled globally\n");
14782 val = "no";
14783 }
14785
14786 if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) {
14787 ast_debug(1, "VM CID Info before msg disabled globally\n");
14788 val = "no";
14789 }
14791
14792 if (!(val = ast_variable_retrieve(cfg, "general", "sendvoicemail"))){
14793 ast_debug(1, "Send Voicemail msg disabled globally\n");
14794 val = "no";
14795 }
14797
14798 if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) {
14799 ast_debug(1, "ENVELOPE before msg enabled globally\n");
14800 val = "yes";
14801 }
14803
14804 if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) {
14805 ast_debug(1, "Move Heard enabled globally\n");
14806 val = "yes";
14807 }
14809
14810 if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) {
14811 ast_debug(1, "Autoset of Urgent flag on forwarded Urgent messages disabled globally\n");
14812 val = "no";
14813 }
14815
14816 if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
14817 ast_debug(1, "Duration info before msg enabled globally\n");
14818 val = "yes";
14819 }
14821
14822 saydurationminfo = 2;
14823 if ((val = ast_variable_retrieve(cfg, "general", "saydurationm"))) {
14824 if (sscanf(val, "%30d", &x) == 1) {
14825 saydurationminfo = x;
14826 } else {
14827 ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
14828 }
14829 }
14830
14831 if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
14832 ast_debug(1, "We are not going to skip to the next msg after save/delete\n");
14833 val = "no";
14834 }
14836
14837 if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) {
14839 ast_debug(1, "found dialout context: %s\n", dialcontext);
14840 } else {
14841 dialcontext[0] = '\0';
14842 }
14843
14844 if ((val = ast_variable_retrieve(cfg, "general", "callback"))) {
14846 ast_debug(1, "found callback context: %s\n", callcontext);
14847 } else {
14848 callcontext[0] = '\0';
14849 }
14850
14851 if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
14853 ast_debug(1, "found operator context: %s\n", exitcontext);
14854 } else {
14855 exitcontext[0] = '\0';
14856 }
14857
14858 /* load password sounds configuration */
14859 if ((val = ast_variable_retrieve(cfg, "general", "vm-login")))
14861 if ((val = ast_variable_retrieve(cfg, "general", "vm-newuser")))
14863 if ((val = ast_variable_retrieve(cfg, "general", "vm-password")))
14865 if ((val = ast_variable_retrieve(cfg, "general", "vm-newpassword")))
14867 if ((val = ast_variable_retrieve(cfg, "general", "vm-invalid-password")))
14869 if ((val = ast_variable_retrieve(cfg, "general", "vm-passchanged")))
14871 if ((val = ast_variable_retrieve(cfg, "general", "vm-reenterpassword")))
14873 if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
14875 if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
14877 }
14878 if ((val = ast_variable_retrieve(cfg, "general", "vm-prepend-timeout"))) {
14880 }
14881 /* load configurable audio prompts */
14882 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
14884 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val))
14886 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val))
14888 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val))
14890 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val))
14892
14893 if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory")))
14894 val = "no";
14896
14897 if (!(val = ast_variable_retrieve(cfg, "general", "passwordlocation"))) {
14898 val = "voicemail.conf";
14899 }
14900 if (!(strcmp(val, "spooldir"))) {
14902 } else {
14904 }
14905
14907 if ((val = ast_variable_retrieve(cfg, "general", "pollfreq"))) {
14908 if (sscanf(val, "%30u", &poll_freq) != 1) {
14910 ast_log(AST_LOG_ERROR, "'%s' is not a valid value for the pollfreq option!\n", val);
14911 }
14912 }
14913
14914 poll_mailboxes = 0;
14915 if ((val = ast_variable_retrieve(cfg, "general", "pollmailboxes")))
14917
14918 memset(fromstring, 0, sizeof(fromstring));
14919 memset(pagerfromstring, 0, sizeof(pagerfromstring));
14920 strcpy(charset, "ISO-8859-1");
14921 if (emailbody) {
14923 emailbody = NULL;
14924 }
14925 if (emailsubject) {
14928 }
14929 if (pagerbody) {
14931 pagerbody = NULL;
14932 }
14933 if (pagersubject) {
14936 }
14937 if ((val = ast_variable_retrieve(cfg, "general", "pbxskip")))
14939 if ((val = ast_variable_retrieve(cfg, "general", "fromstring")))
14941 if ((val = ast_variable_retrieve(cfg, "general", "pagerfromstring")))
14943 if ((val = ast_variable_retrieve(cfg, "general", "charset")))
14945 if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
14946 sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14947 for (x = 0; x < 4; x++) {
14948 memcpy(&adsifdn[x], &tmpadsi[x], 1);
14949 }
14950 }
14951 if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) {
14952 sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
14953 for (x = 0; x < 4; x++) {
14954 memcpy(&adsisec[x], &tmpadsi[x], 1);
14955 }
14956 }
14957 if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) {
14958 if (atoi(val)) {
14959 adsiver = atoi(val);
14960 }
14961 }
14962 if ((val = ast_variable_retrieve(cfg, "general", "tz"))) {
14964 }
14965 if ((val = ast_variable_retrieve(cfg, "general", "locale"))) {
14966 ast_copy_string(locale, val, sizeof(locale));
14967 }
14968 if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) {
14970 }
14971 if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
14973 }
14974 if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
14976 }
14977 if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
14979 }
14980
14981 tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14982 if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_high"))) {
14983 if (sscanf(val, "%30ld", &tps_queue_high) != 1 || tps_queue_high <= 0) {
14984 ast_log(AST_LOG_WARNING, "Invalid the taskprocessor high water alert trigger level '%s'\n", val);
14985 tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
14986 }
14987 }
14988 tps_queue_low = -1;
14989 if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_low"))) {
14990 if (sscanf(val, "%30ld", &tps_queue_low) != 1 ||
14991 tps_queue_low < -1 || tps_queue_high < tps_queue_low) {
14992 ast_log(AST_LOG_WARNING, "Invalid the taskprocessor low water clear alert level '%s'\n", val);
14993 tps_queue_low = -1;
14994 }
14995 }
14996 if (ast_taskprocessor_alert_set_levels(mwi_subscription_tps, tps_queue_low, tps_queue_high)) {
14997 ast_log(AST_LOG_WARNING, "Failed to set alert levels for voicemail taskprocessor.\n");
14998 }
14999
15000 /* load mailboxes from users.conf */
15001 if (ucfg) {
15002 for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
15003 if (!strcasecmp(cat, "general")) {
15004 continue;
15005 }
15006 if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
15007 continue;
15008 if ((current = find_or_create(userscontext, cat))) {
15011 ast_copy_string(current->context, userscontext, sizeof(current->context));
15012 if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) {
15013 current->passwordlocation = OPT_PWLOC_USERSCONF;
15014 }
15015
15016 switch (current->passwordlocation) {
15017 case OPT_PWLOC_SPOOLDIR:
15018 snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox);
15019 read_password_from_file(secretfn, current->password, sizeof(current->password));
15020 }
15021 }
15022 }
15023 }
15024
15025 /* load mailboxes from voicemail.conf */
15026
15027 /*
15028 * Aliases must be loaded before users or the aliases won't be notified
15029 * if there's existing voicemail in the user mailbox.
15030 */
15031 load_aliases(cfg);
15032
15033 load_zonemessages(cfg);
15034
15035 load_users(cfg);
15036
15038
15043
15044 return 0;
15045 } else {
15047 ast_log(AST_LOG_WARNING, "Failed to load configuration file.\n");
15048 return 0;
15049 }
15050}
static char pagerfromstring[100]
static char vm_password[80]
static char vm_invalid_password[80]
#define VM_SEARCH
static char listen_control_reverse_key[12]
static char serveremail[80]
#define VM_SAYCID
#define VM_FWDURGAUTO
#define VM_SAYDURATION
static int pwdchange
#define VM_TEMPGREETWARN
static int skipms
#define DEFAULT_LISTEN_CONTROL_FORWARD_KEY
static char mailcmd[160]
static int vmminsecs
static void read_password_from_file(const char *secretfn, char *password, int passwordlen)
static void apply_options_full(struct ast_vm_user *retval, struct ast_variable *var)
Loads the options specific to a voicemail user.
static void populate_defaults(struct ast_vm_user *vmu)
Sets default voicemail system options to a voicemail user.
static struct ast_taskprocessor * mwi_subscription_tps
#define VM_OPERATOR
static char vm_newpassword[80]
#define VM_MARK_URGENT
static struct ast_flags globalflags
static char listen_control_forward_key[12]
static char vm_login[80]
#define VM_DIRECTFORWARD
static char vm_newuser[80]
static unsigned char adsisec[4]
static const char * substitute_escapes(const char *value)
#define VM_SKIPAFTERCMD
static pthread_t poll_thread
static char zonetag[80]
static char * pagersubject
static int maxmsg
static char vmfmts[80]
static void load_zonemessages(struct ast_config *cfg)
static int passwordlocation
static char vm_mismatch[80]
#define ASTERISK_USERNAME
static char vm_pls_try_again[80]
#define VM_PBXSKIP
static char ext_pass_check_cmd[128]
static char * pagerbody
static char dialcontext[AST_MAX_CONTEXT]
#define DEFAULT_POLL_FREQ
#define VM_ENVELOPE
static void stop_poll_thread(void)
#define MAXMSG
#define DEFAULT_LISTEN_CONTROL_RESTART_KEY
static char listen_control_stop_key[12]
static char fromstring[100]
#define PWDCHANGE_INTERNAL
#define VM_FORCEGREET
#define VM_MESSAGEWRAP
static char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64]
#define DEFAULT_LISTEN_CONTROL_STOP_KEY
static char emaildateformat[32]
static char vm_reenterpassword[80]
static int saydurationminfo
#define VM_ATTACH
static void load_users(struct ast_config *cfg)
static int maxgreet
#define SENDMAIL
#define VM_FORCENAME
static char ext_pass_cmd[128]
static int is_valid_dtmf(const char *key)
Determines if a DTMF key entered is valid.
static char pagerdateformat[32]
static double volgain
static int adsiver
static int maxlogins
static char * emailsubject
static struct ao2_container * mailbox_alias_mappings
#define VM_MOVEHEARD
static char externnotify[160]
static char listen_control_restart_key[12]
#define DEFAULT_LISTEN_CONTROL_PAUSE_KEY
#define MAX_NUM_CID_CONTEXTS
static char vm_prepend_timeout[80]
static char userscontext[AST_MAX_EXTENSION]
static char callcontext[AST_MAX_CONTEXT]
static int maxdeletedmsg
static char * emailbody
static char listen_control_pause_key[12]
static int silencethreshold
static void start_poll_thread(void)
static unsigned int poll_mailboxes
#define MINPASSWORD
static int minpassword
static unsigned int poll_freq
static void free_vm_zones(void)
Free the zones structure.
#define VM_SVMAIL
#define PWDCHANGE_EXTERNAL
static struct ast_vm_user * find_or_create(const char *context, const char *box)
static char locale[20]
static unsigned char adsifdn[4]
static int maxsilence
static void load_aliases(struct ast_config *cfg)
static int vmmaxsecs
#define DEFAULT_LISTEN_CONTROL_REVERSE_KEY
#define MAXMSGLIMIT
static char exitcontext[AST_MAX_CONTEXT]
#define VM_REVIEW
static char vm_passchanged[80]
static struct ast_smdi_interface * smdi_iface
static void free_vm_users(void)
Free the users structure.
#define PATH_MAX
Definition: asterisk.h:40
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_MULTIPLE
Definition: astobj2.h:1049
@ OBJ_UNLINK
Definition: astobj2.h:1039
charset
Definition: chan_unistim.c:336
@ THRESHOLD_SILENCE
Definition: dsp.h:73
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Definition: dsp.c:2009
char * ast_format_str_reduce(char *fmts)
Definition: file.c:1894
char * strsep(char **str, const char *delims)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3326
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
Definition: main/config.c:783
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:773
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1215
#define AST_LOG_WARNING
#define AST_LOG_ERROR
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define AST_PTHREADT_NULL
Definition: lock.h:66
size_t current
Definition: main/cli.c:113
void ast_mwi_state_callback_all(on_mwi_state handler, void *data)
For each managed mailbox call the given handler.
Definition: mwi.c:338
struct ast_smdi_interface * ast_smdi_interface_find(const char *iface_name)
Find an SMDI interface with the specified name.
Definition: res_smdi.c:563
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: utils.c:2199
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
Definition: utils.c:2216
list of users found in the config file
Definition: ast_expr2.c:325
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
Definition: taskprocessor.h:64
int ast_taskprocessor_alert_set_levels(struct ast_taskprocessor *tps, long low_water, long high_water)
Set the high and low alert water marks of the given taskprocessor queue.
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94

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

Referenced by load_config_force().

◆ 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 5380 of file app_voicemail_imap.c.

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

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

Referenced by make_email_file().

◆ add_message_id()

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

Definition at line 12802 of file app_voicemail_imap.c.

12803{
12804 struct ast_variable *var;
12805 struct ast_category *cat;
12806 generate_msg_id(id);
12807
12808 var = ast_variable_new("msg_id", id, "");
12809 if (!var) {
12810 return -1;
12811 }
12812
12813 cat = ast_category_get(msg_cfg, "message", NULL);
12814 if (!cat) {
12815 ast_log(LOG_ERROR, "Voicemail data file %s/%d.txt has no [message] category?\n", dir, msg);
12817 return -1;
12818 }
12819
12821
12822 if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
12823 ast_log(LOG_WARNING, "Unable to update %s to have a message ID\n", filename);
12824 return -1;
12825 }
12826
12827 UPDATE_MSG_ID(dir, msg, id, vmu, msg_cfg, folder);
12828 return 0;
12829}
#define UPDATE_MSG_ID(a, b, c, d, e, f)
static void generate_msg_id(char *dst)
Sets the destination string to a uniquely identifying msg_id string.
#define var
Definition: ast_expr2f.c:605
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:2701
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
Definition: extconf.c:1177
#define ast_variable_new(name, value, filename)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
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:1111
Structure for variables, used for configurations and for channel variables.

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

Referenced by vm_msg_snapshot_create().

◆ adsi_begin()

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

Definition at line 7453 of file app_voicemail_imap.c.

7454{
7455 int x;
7456 if (!ast_adsi_available(chan))
7457 return;
7458 x = ast_adsi_load_session(chan, adsifdn, adsiver, 1);
7459 if (x < 0) {
7460 *useadsi = 0;
7462 return;
7463 }
7464 if (!x) {
7465 if (adsi_load_vmail(chan, useadsi)) {
7466 ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n");
7467 return;
7468 }
7469 } else
7470 *useadsi = 1;
7471}
int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
Check if scripts for a given app are already loaded. Version may be -1, if any version is okay,...
Definition: adsi.c:76
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
static int adsi_load_vmail(struct ast_channel *chan, int *useadsi)
@ AST_ADSI_UNAVAILABLE
Definition: channel.h:871
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)

References adsi_load_vmail(), adsifdn, adsiver, ast_adsi_available(), ast_adsi_load_session(), AST_ADSI_UNAVAILABLE, ast_channel_adsicpe_set(), ast_log, and AST_LOG_WARNING.

Referenced by vm_authenticate(), and vm_execmain().

◆ adsi_delete()

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

Definition at line 7652 of file app_voicemail_imap.c.

7653{
7654 int bytes = 0;
7655 unsigned char buf[256];
7656 unsigned char keys[8];
7657
7658 int x;
7659
7660 if (!ast_adsi_available(chan))
7661 return;
7662
7663 /* New meaning for keys */
7664 for (x = 0; x < 5; x++)
7665 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7666
7667 keys[6] = 0x0;
7668 keys[7] = 0x0;
7669
7670 if (!vms->curmsg) {
7671 /* No prev key, provide "Folder" instead */
7672 keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7673 }
7674 if (vms->curmsg >= vms->lastmsg) {
7675 /* If last message ... */
7676 if (vms->curmsg) {
7677 /* but not only message, provide "Folder" instead */
7678 keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
7679 } else {
7680 /* Otherwise if only message, leave blank */
7681 keys[3] = 1;
7682 }
7683 }
7684
7685 /* If deleted, show "undeleted" */
7686#ifdef IMAP_STORAGE
7687 ast_mutex_lock(&vms->lock);
7688#endif
7689 if (vms->deleted[vms->curmsg]) {
7690 keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
7691 }
7692#ifdef IMAP_STORAGE
7693 ast_mutex_unlock(&vms->lock);
7694#endif
7695
7696 /* Except "Exit" */
7697 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
7698 bytes += ast_adsi_set_keys(buf + bytes, keys);
7699 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7700
7702}
#define ADSI_KEY_APPS
Definition: adsi.h:109
#define ADSI_KEY_SKT
Definition: adsi.h:117
#define ADSI_MSG_DISPLAY
Definition: adsi.h:32
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
#define ast_mutex_unlock(a)
Definition: lock.h:190
#define ast_mutex_lock(a)
Definition: lock.h:189
int * deleted

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

Referenced by vm_execmain().

◆ adsi_folders()

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

Definition at line 7521 of file app_voicemail_imap.c.

7522{
7523 unsigned char buf[256];
7524 int bytes = 0;
7525 unsigned char keys[8];
7526 int x, y;
7527
7528 if (!ast_adsi_available(chan))
7529 return;
7530
7531 for (x = 0; x < 5; x++) {
7532 y = ADSI_KEY_APPS + 12 + start + x;
7533 if (y > ADSI_KEY_APPS + 12 + 4)
7534 y = 0;
7535 keys[x] = ADSI_KEY_SKT | y;
7536 }
7537 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17);
7538 keys[6] = 0;
7539 keys[7] = 0;
7540
7541 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, "");
7542 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
7543 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7544 bytes += ast_adsi_set_keys(buf + bytes, keys);
7545 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7546
7548}
int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
Loads a line of info into the display.
Definition: adsi.c:274
#define ADSI_JUST_CENT
Definition: adsi.h:114
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
#define ADSI_COMM_PAGE
Definition: adsi.h:107

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

Referenced by vm_execmain().

◆ adsi_goodbye()

static void adsi_goodbye ( struct ast_channel chan)
static

Definition at line 7807 of file app_voicemail_imap.c.

7808{
7809 unsigned char buf[256];
7810 int bytes = 0;
7811
7812 if (!ast_adsi_available(chan))
7813 return;
7814 bytes += adsi_logo(buf + bytes);
7815 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
7816 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
7817 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7818 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7819
7821}
#define ADSI_JUST_LEFT
Definition: adsi.h:112
static int adsi_logo(unsigned char *buf)

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

Referenced by vm_execmain().

◆ adsi_load_vmail()

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

Definition at line 7324 of file app_voicemail_imap.c.

7325{
7326 unsigned char buf[256];
7327 int bytes = 0;
7328 int x;
7329 char num[5];
7330
7331 *useadsi = 0;
7332 bytes += ast_adsi_data_mode(buf + bytes);
7334
7335 bytes = 0;
7336 bytes += adsi_logo(buf);
7337 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7338#ifdef DISPLAY
7339 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .", "");
7340#endif
7341 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7342 bytes += ast_adsi_data_mode(buf + bytes);
7344
7346 bytes = 0;
7347 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", "");
7348 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7349 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7350 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7352 return 0;
7353 }
7354
7355#ifdef DISPLAY
7356 /* Add a dot */
7357 bytes = 0;
7358 bytes += ast_adsi_logo(buf);
7359 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7360 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ..", "");
7361 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7363#endif
7364 bytes = 0;
7365 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1);
7366 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1);
7367 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advanced", "3", 1);
7368 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1);
7369 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1);
7370 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1);
7372
7373#ifdef DISPLAY
7374 /* Add another dot */
7375 bytes = 0;
7376 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ...", "");
7377 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7378
7379 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7381#endif
7382
7383 bytes = 0;
7384 /* These buttons we load but don't use yet */
7385 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 6, "Previous", "Prev", "4", 1);
7386 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 8, "Repeat", "Repeat", "5", 1);
7387 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 7, "Delete", "Delete", "7", 1);
7388 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 9, "Next", "Next", "6", 1);
7389 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 10, "Save", "Save", "9", 1);
7390 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 11, "Undelete", "Restore", "7", 1);
7392
7393#ifdef DISPLAY
7394 /* Add another dot */
7395 bytes = 0;
7396 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ....", "");
7397 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7399#endif
7400
7401 bytes = 0;
7402 for (x = 0; x < 5; x++) {
7403 snprintf(num, sizeof(num), "%d", x);
7404 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(NULL, x), mbox(NULL, x), num, 1);
7405 }
7406 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + 5, "Cancel", "Cancel", "#", 1);
7408
7409#ifdef DISPLAY
7410 /* Add another dot */
7411 bytes = 0;
7412 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .....", "");
7413 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7415#endif
7416
7417 if (ast_adsi_end_download(chan)) {
7418 bytes = 0;
7419 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Download Unsuccessful.", "");
7420 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7421 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7422 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7424 return 0;
7425 }
7426 bytes = 0;
7427 bytes += ast_adsi_download_disconnect(buf + bytes);
7428 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7430
7431 ast_debug(1, "Done downloading scripts...\n");
7432
7433#ifdef DISPLAY
7434 /* Add last dot */
7435 bytes = 0;
7436 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
7437 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7438#endif
7439 ast_debug(1, "Restarting session...\n");
7440
7441 bytes = 0;
7442 /* Load the session now */
7443 if (ast_adsi_load_session(chan, adsifdn, adsiver, 1) == 1) {
7444 *useadsi = 1;
7445 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", "");
7446 } else
7447 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Failed!", "");
7448
7450 return 0;
7451}
int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
Creates "load soft key" parameters.
Definition: adsi.c:296
#define ADSI_MSG_DOWNLOAD
Definition: adsi.h:33
int ast_adsi_data_mode(unsigned char *buf)
Puts CPE in data mode.
Definition: adsi.c:219
int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
Definition: adsi.c:32
int ast_adsi_end_download(struct ast_channel *chan)
Definition: adsi.c:43
int ast_adsi_download_disconnect(unsigned char *buf)
Disconnects (and hopefully saves) a downloaded script.
Definition: adsi.c:208
static char * addesc
static const char * mbox(struct ast_vm_user *vmu, int id)

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

Referenced by adsi_begin().

◆ adsi_login()

static void adsi_login ( struct ast_channel chan)
static

Definition at line 7473 of file app_voicemail_imap.c.

7474{
7475 unsigned char buf[256];
7476 int bytes = 0;
7477 unsigned char keys[8];
7478 int x;
7479 if (!ast_adsi_available(chan))
7480 return;
7481
7482 for (x = 0; x < 8; x++)
7483 keys[x] = 0;
7484 /* Set one key for next */
7485 keys[3] = ADSI_KEY_APPS + 3;
7486
7487 bytes += adsi_logo(buf + bytes);
7488 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, " ", "");
7489 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ", "");
7490 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7491 bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Mailbox: ******", "");
7492 bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 1, 1, ADSI_JUST_LEFT);
7493 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Enter", "Enter", "#", 1);
7494 bytes += ast_adsi_set_keys(buf + bytes, keys);
7495 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7497}
int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
Set input information.
Definition: adsi.c:318
int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
Set input format.
Definition: adsi.c:329
#define ADSI_DIR_FROM_LEFT
Definition: adsi.h:120

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

Referenced by vm_authenticate().

◆ adsi_logo()

static int adsi_logo ( unsigned char *  buf)
static

Definition at line 7316 of file app_voicemail_imap.c.

7317{
7318 int bytes = 0;
7319 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
7320 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
7321 return bytes;
7322}

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

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

◆ adsi_message()

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

Definition at line 7550 of file app_voicemail_imap.c.

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

References ADSI_COMM_PAGE, ADSI_JUST_LEFT, ADSI_KEY_APPS, ADSI_KEY_SKT, ADSI_MSG_DISPLAY, ast_adsi_available(), ast_adsi_display(), ast_adsi_set_keys(), ast_adsi_set_line(), ast_adsi_transmit_message(), ast_adsi_voice_mode(), ast_callerid_parse(), ast_copy_string(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), buf, buf1, buf2, vm_state::curbox, vm_state::curmsg, vm_state::deleted, vm_state::fn, vm_state::lastmsg, name, NULL, PATH_MAX, and strsep().

Referenced by play_message(), and vm_execmain().

◆ adsi_password()

static void adsi_password ( struct ast_channel chan)
static

Definition at line 7499 of file app_voicemail_imap.c.

7500{
7501 unsigned char buf[256];
7502 int bytes = 0;
7503 unsigned char keys[8];
7504 int x;
7505 if (!ast_adsi_available(chan))
7506 return;
7507
7508 for (x = 0; x < 8; x++)
7509 keys[x] = 0;
7510 /* Set one key for next */
7511 keys[3] = ADSI_KEY_APPS + 3;
7512
7513 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7514 bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
7515 bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
7516 bytes += ast_adsi_set_keys(buf + bytes, keys);
7517 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7519}

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

Referenced by vm_authenticate().

◆ adsi_status()

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

Definition at line 7704 of file app_voicemail_imap.c.

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

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

Referenced by vm_execmain().

◆ adsi_status2()

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

Definition at line 7751 of file app_voicemail_imap.c.

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

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

Referenced by vm_execmain().

◆ advanced_options()

static int advanced_options ( struct ast_channel chan,
struct ast_vm_user vmu,
struct vm_state vms,
int  msg,
int  option,
signed char  record_gain 
)
static

The advanced options within a message.

Parameters
chan
vmu
vms
msg
option
record_gain

Provides handling for the play message envelope, call the person back, or reply to message.

Returns
zero on success, -1 on error.

Definition at line 16013 of file app_voicemail_imap.c.

16014{
16015 int res = 0;
16016 char filename[PATH_MAX];
16017 struct ast_config *msg_cfg = NULL;
16018 const char *origtime, *context;
16019 char *name, *num;
16020 int retries = 0;
16021 char *cid;
16022 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE, };
16023
16024 vms->starting = 0;
16025
16026 make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
16027
16028 /* Retrieve info from VM attribute file */
16029 snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
16030 RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
16031 msg_cfg = ast_config_load(filename, config_flags);
16032 DISPOSE(vms->curdir, vms->curmsg);
16033 if (!valid_config(msg_cfg)) {
16034 ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
16035 return 0;
16036 }
16037
16038 if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) {
16039 ast_config_destroy(msg_cfg);
16040 return 0;
16041 }
16042
16043 cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid"));
16044
16045 context = ast_variable_retrieve(msg_cfg, "message", "context");
16046 switch (option) {
16047 case 3: /* Play message envelope */
16048 if (!res) {
16049 res = play_message_datetime(chan, vmu, origtime, filename);
16050 }
16051 if (!res) {
16052 res = play_message_callerid(chan, vms, cid, context, 0, 1);
16053 }
16054
16055 res = 't';
16056 break;
16057
16058 case 2: /* Call back */
16059
16060 if (ast_strlen_zero(cid))
16061 break;
16062
16063 ast_callerid_parse(cid, &name, &num);
16064 while ((res > -1) && (res != 't')) {
16065 switch (res) {
16066 case '1':
16067 if (num) {
16068 /* Dial the CID number */
16069 res = dialout(chan, vmu, num, vmu->callback);
16070 if (res) {
16071 ast_config_destroy(msg_cfg);
16072 return 9;
16073 }
16074 } else {
16075 res = '2';
16076 }
16077 break;
16078
16079 case '2':
16080 /* Want to enter a different number, can only do this if there's a dialout context for this user */
16081 if (!ast_strlen_zero(vmu->dialout)) {
16082 res = dialout(chan, vmu, NULL, vmu->dialout);
16083 if (res) {
16084 ast_config_destroy(msg_cfg);
16085 return 9;
16086 }
16087 } else {
16088 ast_verb(3, "Caller can not specify callback number - no dialout context available\n");
16089 res = ast_play_and_wait(chan, "vm-sorry");
16090 }
16091 ast_config_destroy(msg_cfg);
16092 return res;
16093 case '*':
16094 res = 't';
16095 break;
16096 case '3':
16097 case '4':
16098 case '5':
16099 case '6':
16100 case '7':
16101 case '8':
16102 case '9':
16103 case '0':
16104
16105 res = ast_play_and_wait(chan, "vm-sorry");
16106 retries++;
16107 break;
16108 default:
16109 if (num) {
16110 ast_verb(3, "Confirm CID number '%s' is number to use for callback\n", num);
16111 res = ast_play_and_wait(chan, "vm-num-i-have");
16112 if (!res)
16113 res = play_message_callerid(chan, vms, num, vmu->context, 1, 1);
16114 if (!res)
16115 res = ast_play_and_wait(chan, "vm-tocallnum");
16116 /* Only prompt for a caller-specified number if there is a dialout context specified */
16117 if (!ast_strlen_zero(vmu->dialout)) {
16118 if (!res)
16119 res = ast_play_and_wait(chan, "vm-calldiffnum");
16120 }
16121 } else {
16122 res = ast_play_and_wait(chan, "vm-nonumber");
16123 if (!ast_strlen_zero(vmu->dialout)) {
16124 if (!res)
16125 res = ast_play_and_wait(chan, "vm-toenternumber");
16126 }
16127 }
16128 if (!res) {
16129 res = ast_play_and_wait(chan, "vm-star-cancel");
16130 }
16131 if (!res) {
16132 res = ast_waitfordigit(chan, 6000);
16133 }
16134 if (!res) {
16135 retries++;
16136 if (retries > 3) {
16137 res = 't';
16138 }
16139 }
16140 ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
16141 isprint(res) ? res : '?', isprint(res) ? res : '?');
16142 break;
16143
16144 }
16145 if (res == 't')
16146 res = 0;
16147 else if (res == '*')
16148 res = -1;
16149 }
16150 break;
16151
16152 case 1: /* Reply */
16153 /* Send reply directly to sender */
16154 if (ast_strlen_zero(cid))
16155 break;
16156
16157 ast_callerid_parse(cid, &name, &num);
16158 if (!num) {
16159 ast_verb(3, "No CID number available, no reply sent\n");
16160 if (!res)
16161 res = ast_play_and_wait(chan, "vm-nonumber");
16162 ast_config_destroy(msg_cfg);
16163 return res;
16164 } else {
16165 struct ast_vm_user vmu2, *vmu3;
16166 memset(&vmu2, 0, sizeof(vmu2));
16167 vmu3 = find_user(&vmu2, vmu->context, num);
16168 if (vmu3) {
16169 struct leave_vm_options leave_options;
16170 char mailbox[AST_MAX_EXTENSION * 2 + 2];
16171 snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context);
16172
16173 ast_verb(3, "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
16174
16175 memset(&leave_options, 0, sizeof(leave_options));
16176 leave_options.record_gain = record_gain;
16177 leave_options.beeptone = "beep";
16178 res = leave_voicemail(chan, mailbox, &leave_options);
16179 if (!res)
16180 res = 't';
16181 ast_config_destroy(msg_cfg);
16182 free_user(vmu3);
16183 return res;
16184 } else {
16185 /* Sender has no mailbox, can't reply */
16186 ast_verb(3, "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
16187 ast_play_and_wait(chan, "vm-nobox");
16188 res = 't';
16189 ast_config_destroy(msg_cfg);
16190 return res;
16191 }
16192 }
16193 res = 0;
16194
16195 break;
16196 }
16197
16198 ast_config_destroy(msg_cfg);
16199
16200#ifndef IMAP_STORAGE
16201 if (!res) {
16202 make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
16203 vms->heard[msg] = 1;
16204 res = wait_file(chan, vms, vms->fn);
16205 }
16206#endif
16207 return res;
16208}
static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_options *options)
Prompts the user and records a voicemail to a mailbox.
static int make_file(char *dest, const int len, const char *dir, const int num)
Creates a file system path expression for a folder within the voicemail data folder and the appropria...
static int valid_config(const struct ast_config *cfg)
Check if configuration file is valid.
static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms, char *cid, const char *context, int callback, int saycidnumber)
#define DISPOSE(a, b)
static int wait_file(struct ast_channel *chan, struct vm_state *vms, char *file)
static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *vmu, const char *origtime, const char *filename)
#define RETRIEVE(a, b, c, d)
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3175
#define AST_MAX_EXTENSION
Definition: channel.h:134
int ast_play_and_wait(struct ast_channel *chan, const char *fn)
Play a stream and wait for a digit, returning the digit that was pressed.
Definition: main/app.c:1616
#define ast_config_load(filename, flags)
Load a config file.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
Definition: extconf.c:1289
@ CONFIG_FLAG_NOCACHE
#define ast_verb(level,...)
Structure used to handle boolean flags.
Definition: utils.h:199
char callback[80]
char dialout[80]
Options for leaving voicemail with the voicemail() application.
Definition: app_minivm.c:654
signed char record_gain
Definition: app_minivm.c:656
char curdir[PATH_MAX]
int * heard
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189

References ast_callerid_parse(), ast_config_destroy(), ast_config_load, ast_log, AST_LOG_WARNING, AST_MAX_EXTENSION, ast_play_and_wait(), ast_strdupa, ast_strlen_zero(), ast_test_suite_event_notify, ast_variable_retrieve(), ast_verb, ast_waitfordigit(), leave_vm_options::beeptone, ast_vm_user::callback, CONFIG_FLAG_NOCACHE, ast_vm_user::context, voicemailpwcheck::context, vm_state::curdir, vm_state::curmsg, dialout(), ast_vm_user::dialout, DISPOSE, find_user(), vm_state::fn, free_user(), vm_state::heard, leave_voicemail(), ast_vm_user::mailbox, voicemailpwcheck::mailbox, make_file(), name, NULL, PATH_MAX, play_message_callerid(), play_message_datetime(), leave_vm_options::record_gain, RETRIEVE, vm_state::starting, valid_config(), and wait_file().

Referenced by vm_execmain().

◆ alias_mailbox_mapping_create()

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

Definition at line 14273 of file app_voicemail_imap.c.

14274{
14275 struct alias_mailbox_mapping *mapping;
14276 size_t from_len = strlen(alias) + 1;
14277 size_t to_len = strlen(mailbox) + 1;
14278
14279 mapping = ao2_alloc(sizeof(*mapping) + from_len + to_len, NULL);
14280 if (!mapping) {
14281 return NULL;
14282 }
14283 mapping->alias = mapping->buf;
14284 mapping->mailbox = mapping->buf + from_len;
14285 ast_copy_string(mapping->alias, alias, from_len); /* Safe */
14286 ast_copy_string(mapping->mailbox, mailbox, to_len); /* Safe */
14287
14288 return mapping;
14289}
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409

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

Referenced by load_aliases().

◆ AO2_STRING_FIELD_CMP_FN() [1/2]

AO2_STRING_FIELD_CMP_FN ( alias_mailbox_mapping  ,
alias   
)

◆ AO2_STRING_FIELD_CMP_FN() [2/2]

AO2_STRING_FIELD_CMP_FN ( mailbox_alias_mapping  ,
mailbox   
)

◆ AO2_STRING_FIELD_HASH_FN() [1/2]

AO2_STRING_FIELD_HASH_FN ( alias_mailbox_mapping  ,
alias   
)

◆ AO2_STRING_FIELD_HASH_FN() [2/2]

AO2_STRING_FIELD_HASH_FN ( mailbox_alias_mapping  ,
mailbox   
)

◆ append_mailbox()

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

Definition at line 12871 of file app_voicemail_imap.c.

12872{
12873 /* Assumes lock is already held */
12874 char *tmp;
12875 char *stringp;
12876 char *s;
12877 struct ast_vm_user *vmu;
12878 char mailbox_full[MAX_VM_MAILBOX_LEN];
12879 int new = 0, old = 0, urgent = 0;
12880 char secretfn[PATH_MAX] = "";
12881
12882 tmp = ast_strdupa(data);
12883
12884 if (!(vmu = find_or_create(context, box)))
12885 return -1;
12886
12887 populate_defaults(vmu);
12888
12889 stringp = tmp;
12890 if ((s = strsep(&stringp, ","))) {
12891 if (!ast_strlen_zero(s) && s[0] == '*') {
12892 ast_log(LOG_WARNING, "Invalid password detected for mailbox %s. The password"
12893 "\n\tmust be reset in voicemail.conf.\n", box);
12894 }
12895 /* assign password regardless of validity to prevent NULL password from being assigned */
12896 ast_copy_string(vmu->password, s, sizeof(vmu->password));
12897 }
12898 if (stringp && (s = strsep(&stringp, ","))) {
12899 ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
12900 }
12901 if (stringp && (s = strsep(&stringp, ","))) {
12902 vmu->email = ast_strdup(s);
12903 }
12904 if (stringp && (s = strsep(&stringp, ","))) {
12905 ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
12906 }
12907 if (stringp) {
12908 apply_options(vmu, stringp);
12909 }
12910
12911 switch (vmu->passwordlocation) {
12912 case OPT_PWLOC_SPOOLDIR:
12913 snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
12914 read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
12915 }
12916
12917 snprintf(mailbox_full, MAX_VM_MAILBOX_LEN, "%s%s%s",
12918 box,
12919 ast_strlen_zero(context) ? "" : "@",
12920 context);
12921
12922 inboxcount2(mailbox_full, &urgent, &new, &old);
12923#ifdef IMAP_STORAGE
12924 imap_logout(mailbox_full);
12925#endif
12926 queue_mwi_event(NULL, mailbox_full, urgent, new, old);
12927
12928 return 0;
12929}
static void apply_options(struct ast_vm_user *vmu, const char *options)
Destructively Parse options and apply.
static void queue_mwi_event(const char *channel_id, const char *box, int urgent, int new, int old)
static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Check the given mailbox's message count.
int passwordlocation

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

Referenced by load_users().

◆ append_vmbox_info_astman()

static int append_vmbox_info_astman ( struct mansession s,
const struct message m,
struct ast_vm_user vmu,
const char *  event_name,
const char *  actionid 
)
static

Append vmbox info string into given astman with event_name.

Returns
0 if unable to append details, 1 otherwise.

Definition at line 13812 of file app_voicemail_imap.c.

13818{
13819 struct ast_vm_mailbox_snapshot *mailbox_snapshot;
13820 struct ast_vm_msg_snapshot *msg;
13821 int nummessages = 0;
13822 int i;
13823
13824 /* Take a snapshot of the mailbox */
13825 mailbox_snapshot = ast_vm_mailbox_snapshot_create(vmu->mailbox, vmu->context, NULL, 0, AST_VM_SNAPSHOT_SORT_BY_ID, 0);
13826 if (!mailbox_snapshot) {
13827 ast_log(LOG_ERROR, "Could not append voicemail box info for box %s@%s.",
13828 vmu->mailbox, vmu->context);
13829 return 0;
13830 }
13831
13832 astman_send_listack(s, m, "Voicemail box detail will follow", "start");
13833 /* walk through each folder's contents and append info for each message */
13834 for (i = 0; i < mailbox_snapshot->folders; i++) {
13835 AST_LIST_TRAVERSE(&((mailbox_snapshot)->snapshots[i]), msg, msg) {
13836 astman_append(s,
13837 "Event: %s\r\n"
13838 "%s"
13839 "Folder: %s\r\n"
13840 "CallerID: %s\r\n"
13841 "Date: %s\r\n"
13842 "Duration: %s\r\n"
13843 "Flag: %s\r\n"
13844 "ID: %s\r\n"
13845 "\r\n",
13846 event_name,
13847 actionid,
13848 msg->folder_name,
13849 msg->callerid,
13850 msg->origdate,
13851 msg->duration,
13852 msg->flag,
13853 msg->msg_id
13854 );
13855 nummessages++;
13856 }
13857 }
13858
13859 /* done, destroy. */
13860 mailbox_snapshot = ast_vm_mailbox_snapshot_destroy(mailbox_snapshot);
13861 astman_send_list_complete_start(s, m, "VoicemailBoxDetailComplete", nummessages);
13863
13864 return 1;
13865}
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
Definition: manager.c:3431
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
Definition: manager.c:3467
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
Definition: manager.c:3475
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3310
@ AST_VM_SNAPSHOT_SORT_BY_ID
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
Definition: main/app.c:675
struct ast_vm_mailbox_snapshot * ast_vm_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)
Create a snapshot of a mailbox which contains information about every msg.
Definition: main/app.c:661
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
struct ast_vm_msg_snapshot::@184 msg

References AST_LIST_TRAVERSE, ast_log, ast_vm_mailbox_snapshot_create(), ast_vm_mailbox_snapshot_destroy(), AST_VM_SNAPSHOT_SORT_BY_ID, astman_append(), astman_send_list_complete_end(), astman_send_list_complete_start(), astman_send_listack(), ast_vm_user::context, ast_vm_mailbox_snapshot::folders, LOG_ERROR, ast_vm_user::mailbox, ast_vm_msg_snapshot::msg, and NULL.

Referenced by manager_get_mailbox_summary().

◆ 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 13688 of file app_voicemail_imap.c.

13694{
13695 int new;
13696 int old;
13697 char *mailbox;
13698 int ret;
13699
13700 if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {
13701 ast_log(LOG_ERROR, "Wrong input parameter.");
13702 return 0;
13703 }
13704
13705 /* create mailbox string */
13706 if (!ast_strlen_zero(vmu->context)) {
13707 ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);
13708 } else {
13709 ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);
13710 }
13711 if (ret == -1) {
13712 ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));
13713 return 0;
13714 }
13715
13716 /* get mailbox count */
13717 ret = inboxcount(mailbox, &new, &old);
13719 if (ret == -1) {
13720 ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n",
13721 vmu->mailbox ?: "", vmu->context ?: "");
13722 return 0;
13723 }
13724
13725 astman_append(s,
13726 "Event: %s\r\n"
13727 "%s"
13728 "VMContext: %s\r\n"
13729 "VoiceMailbox: %s\r\n"
13730 "Fullname: %s\r\n"
13731 "Email: %s\r\n"
13732 "Pager: %s\r\n"
13733 "ServerEmail: %s\r\n"
13734 "FromString: %s\r\n"
13735 "MailCommand: %s\r\n"
13736 "Language: %s\r\n"
13737 "TimeZone: %s\r\n"
13738 "Callback: %s\r\n"
13739 "Dialout: %s\r\n"
13740 "UniqueID: %s\r\n"
13741 "ExitContext: %s\r\n"
13742 "SayDurationMinimum: %d\r\n"
13743 "SayEnvelope: %s\r\n"
13744 "SayCID: %s\r\n"
13745 "AttachMessage: %s\r\n"
13746 "AttachmentFormat: %s\r\n"
13747 "DeleteMessage: %s\r\n"
13748 "VolumeGain: %.2f\r\n"
13749 "CanReview: %s\r\n"
13750 "CanMarkUrgent: %s\r\n"
13751 "CallOperator: %s\r\n"
13752 "MaxMessageCount: %d\r\n"
13753 "MaxMessageLength: %d\r\n"
13754 "NewMessageCount: %d\r\n"
13755 "OldMessageCount: %d\r\n"
13756#ifdef IMAP_STORAGE
13757 "IMAPUser: %s\r\n"
13758 "IMAPServer: %s\r\n"
13759 "IMAPPort: %s\r\n"
13760 "IMAPFlags: %s\r\n"
13761#endif
13762 "\r\n",
13763
13764 event_name,
13765 actionid,
13766 vmu->context,
13767 vmu->mailbox,
13768 vmu->fullname,
13769 vmu->email,
13770 vmu->pager,
13773 mailcmd,
13774 vmu->language,
13775 vmu->zonetag,
13776 vmu->callback,
13777 vmu->dialout,
13778 vmu->uniqueid,
13779 vmu->exit,
13780 vmu->saydurationm,
13781 ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
13782 ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
13783 ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
13784 vmu->attachfmt,
13785 ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
13786 vmu->volgain,
13787 ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
13788 ast_test_flag(vmu, VM_MARK_URGENT) ? "Yes" : "No",
13789 ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
13790 vmu->maxmsg,
13791 vmu->maxsecs,
13792 new,
13793 old
13794#ifdef IMAP_STORAGE
13795 ,
13796 vmu->imapuser,
13797 vmu->imapserver,
13798 vmu->imapport,
13799 vmu->imapflags
13800#endif
13801 );
13802
13803 return 1;
13804
13805}
static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
#define VM_DELETE
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
char exit[80]
char fromstring[100]
char uniqueid[80]
char serveremail[80]
char attachfmt[20]
#define ast_test_flag(p, flag)
Definition: utils.h:63

References ast_asprintf, ast_free, ast_log, ast_strlen_zero(), ast_test_flag, astman_append(), ast_vm_user::attachfmt, ast_vm_user::callback, ast_vm_user::context, ast_vm_user::dialout, ast_vm_user::email, errno, ast_vm_user::exit, ast_vm_user::fromstring, fromstring, ast_vm_user::fullname, inboxcount(), ast_vm_user::language, LOG_ERROR, ast_vm_user::mailbox, voicemailpwcheck::mailbox, mailcmd, ast_vm_user::maxmsg, ast_vm_user::maxsecs, NULL, ast_vm_user::pager, ast_vm_user::saydurationm, ast_vm_user::serveremail, serveremail, ast_vm_user::uniqueid, VM_ATTACH, VM_DELETE, VM_ENVELOPE, VM_MARK_URGENT, VM_OPERATOR, VM_REVIEW, VM_SAYCID, ast_vm_user::volgain, and ast_vm_user::zonetag.

Referenced by manager_list_voicemail_users(), and manager_status_voicemail_user().

◆ apply_option()

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

Sets a specific property value.

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

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

Definition at line 1386 of file app_voicemail_imap.c.

1387{
1388 int x;
1389 if (!strcasecmp(var, "attach")) {
1391 } else if (!strcasecmp(var, "attachfmt")) {
1392 ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
1393 } else if (!strcasecmp(var, "attachextrecs")) {
1395 } else if (!strcasecmp(var, "serveremail")) {
1396 ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
1397 } else if (!strcasecmp(var, "fromstring")) {
1398 ast_copy_string(vmu->fromstring, value, sizeof(vmu->fromstring));
1399 } else if (!strcasecmp(var, "emailbody")) {
1400 ast_free(vmu->emailbody);
1402 } else if (!strcasecmp(var, "emailsubject")) {
1403 ast_free(vmu->emailsubject);
1405 } else if (!strcasecmp(var, "language")) {
1406 ast_copy_string(vmu->language, value, sizeof(vmu->language));
1407 } else if (!strcasecmp(var, "tz")) {
1408 ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
1409 } else if (!strcasecmp(var, "locale")) {
1410 ast_copy_string(vmu->locale, value, sizeof(vmu->locale));
1411#ifdef IMAP_STORAGE
1412 } else if (!strcasecmp(var, "imapuser")) {
1413 ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
1414 vmu->imapversion = imapversion;
1415 } else if (!strcasecmp(var, "imapserver")) {
1416 ast_copy_string(vmu->imapserver, value, sizeof(vmu->imapserver));
1417 vmu->imapversion = imapversion;
1418 } else if (!strcasecmp(var, "imapport")) {
1419 ast_copy_string(vmu->imapport, value, sizeof(vmu->imapport));
1420 vmu->imapversion = imapversion;
1421 } else if (!strcasecmp(var, "imapflags")) {
1422 ast_copy_string(vmu->imapflags, value, sizeof(vmu->imapflags));
1423 vmu->imapversion = imapversion;
1424 } else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
1425 ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
1426 vmu->imapversion = imapversion;
1427 } else if (!strcasecmp(var, "imapfolder")) {
1428 ast_copy_string(vmu->imapfolder, value, sizeof(vmu->imapfolder));
1429 vmu->imapversion = imapversion;
1430 } else if (!strcasecmp(var, "imapvmshareid")) {
1431 ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
1432 vmu->imapversion = imapversion;
1433#endif
1434 } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
1436 } else if (!strcasecmp(var, "saycid")){
1438 } else if (!strcasecmp(var, "sendvoicemail")){
1440 } else if (!strcasecmp(var, "review")){
1442 } else if (!strcasecmp(var, "leaveurgent")){
1444 } else if (!strcasecmp(var, "tempgreetwarn")){
1446 } else if (!strcasecmp(var, "messagewrap")){
1448 } else if (!strcasecmp(var, "operator")) {
1450 } else if (!strcasecmp(var, "envelope")){
1452 } else if (!strcasecmp(var, "moveheard")){
1454 } else if (!strcasecmp(var, "sayduration")){
1456 } else if (!strcasecmp(var, "saydurationm")){
1457 if (sscanf(value, "%30d", &x) == 1) {
1458 vmu->saydurationm = x;
1459 } else {
1460 ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
1461 }
1462 } else if (!strcasecmp(var, "forcename")){
1464 } else if (!strcasecmp(var, "forcegreetings")){
1466 } else if (!strcasecmp(var, "callback")) {
1467 ast_copy_string(vmu->callback, value, sizeof(vmu->callback));
1468 } else if (!strcasecmp(var, "dialout")) {
1469 ast_copy_string(vmu->dialout, value, sizeof(vmu->dialout));
1470 } else if (!strcasecmp(var, "exitcontext")) {
1471 ast_copy_string(vmu->exit, value, sizeof(vmu->exit));
1472 } else if (!strcasecmp(var, "minsecs")) {
1473 if (sscanf(value, "%30d", &x) == 1 && x >= 0) {
1474 vmu->minsecs = x;
1475 } else {
1476 ast_log(LOG_WARNING, "Invalid min message length of %s. Using global value %d\n", value, vmminsecs);
1477 vmu->minsecs = vmminsecs;
1478 }
1479 } else if (!strcasecmp(var, "maxmessage") || !strcasecmp(var, "maxsecs")) {
1480 vmu->maxsecs = atoi(value);
1481 if (vmu->maxsecs <= 0) {
1482 ast_log(AST_LOG_WARNING, "Invalid max message length of %s. Using global value %d\n", value, vmmaxsecs);
1483 vmu->maxsecs = vmmaxsecs;
1484 } else {
1485 vmu->maxsecs = atoi(value);
1486 }
1487 if (!strcasecmp(var, "maxmessage"))
1488 ast_log(