Asterisk - The Open Source Telephony Project GIT-master-3dee037
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 COUNT(a, b)   count_messages(a,b)
 
#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 LAST_MSG_INDEX(a)   last_message_index(a)
 
#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 MSGFILE_LEN   (7)
 
#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_ODBC_AUDIO_ON_DISK   (1 << 21)
 
#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 1014 of file app_voicemail_imap.c.

◆ COUNT

#define COUNT (   a,
  b 
)    count_messages(a,b)

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

◆ DELETE

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

Definition at line 1015 of file app_voicemail_imap.c.

◆ DISPOSE

#define DISPOSE (   a,
  b 
)

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

◆ ERROR_MAX_MSGS

#define ERROR_MAX_MSGS   -101

Definition at line 695 of file app_voicemail_imap.c.

◆ EXISTS

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

Definition at line 1012 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 785 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.

◆ LAST_MSG_INDEX

#define LAST_MSG_INDEX (   a)    last_message_index(a)

Definition at line 1008 of file app_voicemail_imap.c.

◆ MAPPING_BUCKETS

#define MAPPING_BUCKETS   511

Definition at line 1108 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 886 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 888 of file app_voicemail_imap.c.

◆ MAX_VM_MBOX_ID_LEN

#define MAX_VM_MBOX_ID_LEN   (AST_MAX_EXTENSION)

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

◆ MSGFILE_LEN

#define MSGFILE_LEN   (7)

Length of the message file name: msgXXXX

Definition at line 698 of file app_voicemail_imap.c.

◆ OPERATOR_EXIT

#define OPERATOR_EXIT   300

Definition at line 696 of file app_voicemail_imap.c.

◆ PWDCHANGE_EXTERNAL

#define PWDCHANGE_EXTERNAL   (1 << 2)

Definition at line 1028 of file app_voicemail_imap.c.

◆ PWDCHANGE_INTERNAL

#define PWDCHANGE_INTERNAL   (1 << 1)

Definition at line 1027 of file app_voicemail_imap.c.

◆ RENAME

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

Definition at line 1013 of file app_voicemail_imap.c.

◆ RETRIEVE

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

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

◆ tdesc

#define tdesc   "Comedian Mail (Voicemail System)"

Definition at line 1037 of file app_voicemail_imap.c.

◆ UPDATE_MSG_ID

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

Definition at line 1016 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_ODBC_AUDIO_ON_DISK

#define VM_ODBC_AUDIO_ON_DISK   (1 << 21)

When using ODBC, leave the message and greeting recordings on disk instead of moving them into the table

Definition at line 692 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 940 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 700 of file app_voicemail_imap.c.

700 {
701 NEW_FOLDER = 0,
702 OLD_FOLDER = 1,
703 WORK_FOLDER = 2,
704 FAMILY_FOLDER = 3,
705 FRIENDS_FOLDER = 4,
707};
@ 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 725 of file app_voicemail_imap.c.

725 {
730 /* This *must* be the last value in this enum! */
732};
@ 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 709 of file app_voicemail_imap.c.

709 {
710 OPT_SILENT = (1 << 0),
711 OPT_BUSY_GREETING = (1 << 1),
712 OPT_UNAVAIL_GREETING = (1 << 2),
713 OPT_RECORDGAIN = (1 << 3),
714 OPT_PREPEND_MAILBOX = (1 << 4),
715 OPT_AUTOPLAY = (1 << 6),
716 OPT_DTMFEXIT = (1 << 7),
717 OPT_MESSAGE_Urgent = (1 << 8),
718 OPT_MESSAGE_PRIORITY = (1 << 9),
719 OPT_EARLYM_GREETING = (1 << 10),
720 OPT_BEEP = (1 << 11),
721 OPT_SILENT_IF_GREET = (1 << 12),
722 OPT_READONLY = (1 << 13),
723};
@ 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 734 of file app_voicemail_imap.c.

734 {
738};
@ 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 6434 of file app_voicemail_imap.c.

6435{
6436 DIR *dir;
6437 struct dirent *de;
6438 char fn[256];
6439 int ret = 0;
6440 struct alias_mailbox_mapping *mapping;
6441 char *c;
6442 char *m;
6443
6444 /* If no mailbox, return immediately */
6446 return 0;
6447
6448 if (ast_strlen_zero(folder))
6449 folder = "INBOX";
6451 context = "default";
6452
6453 c = (char *)context;
6454 m = (char *)mailbox;
6455
6457 char tmp[MAX_VM_MAILBOX_LEN];
6458
6459 snprintf(tmp, MAX_VM_MAILBOX_LEN, "%s@%s", mailbox, context);
6461 if (mapping) {
6462 separate_mailbox(ast_strdupa(mapping->mailbox), &m, &c);
6463 ao2_ref(mapping, -1);
6464 }
6465 }
6466
6467 snprintf(fn, sizeof(fn), "%s%s/%s/%s", VM_SPOOL_DIR, c, m, folder);
6468
6469 if (!(dir = opendir(fn)))
6470 return 0;
6471
6472 while ((de = readdir(dir))) {
6473 if (!strncasecmp(de->d_name, "msg", 3)) {
6474 if (shortcircuit) {
6475 ret = 1;
6476 break;
6477 } else if (!strncasecmp(de->d_name + 8, "txt", 3)) {
6478 ret++;
6479 }
6480 }
6481 }
6482
6483 closedir(dir);
6484
6485 return ret;
6486}
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 17811 of file app_voicemail_imap.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

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

13602{
13603 struct ast_vm_user svm;
13604 struct ast_vm_user *vmu = NULL;
13605 char *parse;
13606 char *mailbox;
13607 char *context;
13608 int res = 0;
13609
13611 AST_APP_ARG(mailbox_context);
13612 AST_APP_ARG(attribute);
13613 AST_APP_ARG(folder);
13614 );
13615
13616 buf[0] = '\0';
13617
13618 if (ast_strlen_zero(args)) {
13619 ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
13620 return -1;
13621 }
13622
13623 parse = ast_strdupa(args);
13624 AST_STANDARD_APP_ARGS(arg, parse);
13625
13626 if (ast_strlen_zero(arg.mailbox_context)
13627 || ast_strlen_zero(arg.attribute)
13628 || separate_mailbox(ast_strdupa(arg.mailbox_context), &mailbox, &context)) {
13629 ast_log(LOG_ERROR, "VM_INFO requires an argument (<mailbox>[@<context>],attribute[,folder])\n");
13630 return -1;
13631 }
13632
13633 memset(&svm, 0, sizeof(svm));
13634 vmu = find_user(&svm, context, mailbox);
13635
13636 if (!strncasecmp(arg.attribute, "exists", 5)) {
13637 ast_copy_string(buf, vmu ? "1" : "0", len);
13638 free_user(vmu);
13639 return 0;
13640 }
13641
13642 if (vmu) {
13643 if (!strncasecmp(arg.attribute, "password", 8)) {
13645 } else if (!strncasecmp(arg.attribute, "fullname", 8)) {
13647 } else if (!strncasecmp(arg.attribute, "email", 5)) {
13648 ast_copy_string(buf, vmu->email, len);
13649 } else if (!strncasecmp(arg.attribute, "pager", 5)) {
13650 ast_copy_string(buf, vmu->pager, len);
13651 } else if (!strncasecmp(arg.attribute, "language", 8)) {
13653 } else if (!strncasecmp(arg.attribute, "locale", 6)) {
13654 ast_copy_string(buf, vmu->locale, len);
13655 } else if (!strncasecmp(arg.attribute, "tz", 2)) {
13657 } else if (!strncasecmp(arg.attribute, "count", 5)) {
13658 char *mailbox_id;
13659
13660 mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
13661 sprintf(mailbox_id, "%s@%s", mailbox, context);/* Safe */
13662
13663 /* If mbxfolder is empty messagecount will default to INBOX */
13664 res = messagecount(mailbox_id, arg.folder);
13665 if (res < 0) {
13666 ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
13667 free_user(vmu);
13668 return -1;
13669 }
13670 snprintf(buf, len, "%d", res);
13671 } else {
13672 ast_log(LOG_ERROR, "Unknown attribute '%s' for VM_INFO\n", arg.attribute);
13673 free_user(vmu);
13674 return -1;
13675 }
13676 free_user(vmu);
13677 }
13678
13679 return 0;
13680}
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 14836 of file app_voicemail_imap.c.

14837{
14838 struct ast_vm_user *current;
14839 char *cat;
14840 const char *val;
14841 char *q, *stringp, *tmp;
14842 int x;
14843 unsigned int tmpadsi[4];
14844 char secretfn[PATH_MAX] = "";
14845 long tps_queue_low;
14846 long tps_queue_high;
14847
14848#ifdef IMAP_STORAGE
14849 ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder));
14850#endif
14851 /* set audio control prompts */
14857
14858#ifdef IMAP_STORAGE
14859 ast_mwi_state_callback_all(imap_close_subscribed_mailbox, NULL);
14860#endif
14861
14862 /* Free all the users structure */
14863 free_vm_users();
14864
14865 /* Free all the zones structure */
14866 free_vm_zones();
14867
14868 /* Remove all aliases */
14871
14873
14874 memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
14875 memset(ext_pass_check_cmd, 0, sizeof(ext_pass_check_cmd));
14876
14877 if (cfg) {
14878 /* General settings */
14879
14880 if (!(val = ast_variable_retrieve(cfg, "general", "userscontext")))
14881 val = "default";
14883
14884 aliasescontext[0] = '\0';
14885 val = ast_variable_retrieve(cfg, "general", "aliasescontext");
14887
14888 /* Attach voice message to mail message ? */
14889 if (!(val = ast_variable_retrieve(cfg, "general", "attach")))
14890 val = "yes";
14892
14893 if (!(val = ast_variable_retrieve(cfg, "general", "searchcontexts")))
14894 val = "no";
14896
14897 volgain = 0.0;
14898 if ((val = ast_variable_retrieve(cfg, "general", "volgain")))
14899 sscanf(val, "%30lf", &volgain);
14900
14901#ifdef ODBC_STORAGE
14902 strcpy(odbc_database, "asterisk");
14903 if ((val = ast_variable_retrieve(cfg, "general", "odbcstorage"))) {
14904 ast_copy_string(odbc_database, val, sizeof(odbc_database));
14905 }
14906
14907 strcpy(odbc_table, "voicemessages");
14908 if ((val = ast_variable_retrieve(cfg, "general", "odbctable"))) {
14909 ast_copy_string(odbc_table, val, sizeof(odbc_table));
14910 }
14911 odbc_table_len = strlen(odbc_table);
14912
14914 if (!(val = ast_variable_retrieve(cfg, "general", "odbc_audio_on_disk")))
14915 val = "no";
14917
14918#endif
14919 /* Mail command */
14920 strcpy(mailcmd, SENDMAIL);
14921 if ((val = ast_variable_retrieve(cfg, "general", "mailcmd")))
14922 ast_copy_string(mailcmd, val, sizeof(mailcmd)); /* User setting */
14923
14924 maxsilence = 0;
14925 if ((val = ast_variable_retrieve(cfg, "general", "maxsilence"))) {
14926 maxsilence = atoi(val);
14927 if (maxsilence > 0)
14928 maxsilence *= 1000;
14929 }
14930
14931 if (!(val = ast_variable_retrieve(cfg, "general", "maxmsg"))) {
14932 maxmsg = MAXMSG;
14933 } else {
14934 maxmsg = atoi(val);
14935 if (maxmsg < 0) {
14936 ast_log(AST_LOG_WARNING, "Invalid number of messages per folder '%s'. Using default value %i\n", val, MAXMSG);
14937 maxmsg = MAXMSG;
14938 } else if (maxmsg > MAXMSGLIMIT) {
14939 ast_log(AST_LOG_WARNING, "Maximum number of messages per folder is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
14941 }
14942 }
14943
14944 if (!(val = ast_variable_retrieve(cfg, "general", "backupdeleted"))) {
14945 maxdeletedmsg = 0;
14946 } else {
14947 if (sscanf(val, "%30d", &x) == 1)
14948 maxdeletedmsg = x;
14949 else if (ast_true(val))
14951 else
14952 maxdeletedmsg = 0;
14953
14954 if (maxdeletedmsg < 0) {
14955 ast_log(AST_LOG_WARNING, "Invalid number of deleted messages saved per mailbox '%s'. Using default value %i\n", val, MAXMSG);
14957 } else if (maxdeletedmsg > MAXMSGLIMIT) {
14958 ast_log(AST_LOG_WARNING, "Maximum number of deleted messages saved per mailbox is %i. Cannot accept value '%s'\n", MAXMSGLIMIT, val);
14960 }
14961 }
14962
14963 /* Load date format config for voicemail mail */
14964 if ((val = ast_variable_retrieve(cfg, "general", "emaildateformat"))) {
14966 }
14967
14968 /* Load date format config for voicemail pager mail */
14969 if ((val = ast_variable_retrieve(cfg, "general", "pagerdateformat"))) {
14971 }
14972
14973 /* External password changing command */
14974 if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) {
14977 } else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) {
14980 }
14981
14982 /* External password validation command */
14983 if ((val = ast_variable_retrieve(cfg, "general", "externpasscheck"))) {
14985 ast_debug(1, "found externpasscheck: %s\n", ext_pass_check_cmd);
14986 }
14987
14988#ifdef IMAP_STORAGE
14989 /* IMAP server address */
14990 if ((val = ast_variable_retrieve(cfg, "general", "imapserver"))) {
14991 ast_copy_string(imapserver, val, sizeof(imapserver));
14992 } else {
14993 ast_copy_string(imapserver, "localhost", sizeof(imapserver));
14994 }
14995 /* IMAP server port */
14996 if ((val = ast_variable_retrieve(cfg, "general", "imapport"))) {
14997 ast_copy_string(imapport, val, sizeof(imapport));
14998 } else {
14999 ast_copy_string(imapport, "143", sizeof(imapport));
15000 }
15001 /* IMAP server flags */
15002 if ((val = ast_variable_retrieve(cfg, "general", "imapflags"))) {
15003 ast_copy_string(imapflags, val, sizeof(imapflags));
15004 }
15005 /* IMAP server master username */
15006 if ((val = ast_variable_retrieve(cfg, "general", "authuser"))) {
15007 ast_copy_string(authuser, val, sizeof(authuser));
15008 }
15009 /* IMAP server master password */
15010 if ((val = ast_variable_retrieve(cfg, "general", "authpassword"))) {
15011 ast_copy_string(authpassword, val, sizeof(authpassword));
15012 }
15013 /* Expunge on exit */
15014 if ((val = ast_variable_retrieve(cfg, "general", "expungeonhangup"))) {
15015 if (ast_false(val))
15016 expungeonhangup = 0;
15017 else
15018 expungeonhangup = 1;
15019 } else {
15020 expungeonhangup = 1;
15021 }
15022 /* IMAP voicemail folder */
15023 if ((val = ast_variable_retrieve(cfg, "general", "imapfolder"))) {
15024 ast_copy_string(imapfolder, val, sizeof(imapfolder));
15025 } else {
15026 ast_copy_string(imapfolder, "INBOX", sizeof(imapfolder));
15027 }
15028 if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) {
15029 ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder));
15030 }
15031 if ((val = ast_variable_retrieve(cfg, "general", "imapgreetings"))) {
15032 imapgreetings = ast_true(val);
15033 } else {
15034 imapgreetings = 0;
15035 }
15036 if ((val = ast_variable_retrieve(cfg, "general", "greetingfolder"))) {
15037 ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
15038 } else if ((val = ast_variable_retrieve(cfg, "general", "greetingsfolder"))) {
15039 /* Also support greetingsfolder as documented in voicemail.conf.sample */
15040 ast_copy_string(greetingfolder, val, sizeof(greetingfolder));
15041 } else {
15042 ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder));
15043 }
15044 if ((val = ast_variable_retrieve(cfg, "general", "imap_poll_logout"))) {
15045 imap_poll_logout = ast_true(val);
15046 } else {
15047 imap_poll_logout = 0;
15048 }
15049
15050 /* There is some very unorthodox casting done here. This is due
15051 * to the way c-client handles the argument passed in. It expects a
15052 * void pointer and casts the pointer directly to a long without
15053 * first dereferencing it. */
15054 if ((val = ast_variable_retrieve(cfg, "general", "imapreadtimeout"))) {
15055 mail_parameters(NIL, SET_READTIMEOUT, (void *) (atol(val)));
15056 } else {
15057 mail_parameters(NIL, SET_READTIMEOUT, (void *) 60L);
15058 }
15059
15060 if ((val = ast_variable_retrieve(cfg, "general", "imapwritetimeout"))) {
15061 mail_parameters(NIL, SET_WRITETIMEOUT, (void *) (atol(val)));
15062 } else {
15063 mail_parameters(NIL, SET_WRITETIMEOUT, (void *) 60L);
15064 }
15065
15066 if ((val = ast_variable_retrieve(cfg, "general", "imapopentimeout"))) {
15067 mail_parameters(NIL, SET_OPENTIMEOUT, (void *) (atol(val)));
15068 } else {
15069 mail_parameters(NIL, SET_OPENTIMEOUT, (void *) 60L);
15070 }
15071
15072 if ((val = ast_variable_retrieve(cfg, "general", "imapclosetimeout"))) {
15073 mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) (atol(val)));
15074 } else {
15075 mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) 60L);
15076 }
15077
15078 /* Increment configuration version */
15079 imapversion++;
15080#endif
15081 /* External voicemail notify application */
15082 if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) {
15084 ast_debug(1, "found externnotify: %s\n", externnotify);
15085 } else {
15086 externnotify[0] = '\0';
15087 }
15088
15089 /* SMDI voicemail notification */
15090 if ((val = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(val)) {
15091 ast_debug(1, "Enabled SMDI voicemail notification\n");
15092 if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) {
15094 } else {
15095 ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n");
15096 smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
15097 }
15098 if (!smdi_iface) {
15099 ast_log(AST_LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n");
15100 }
15101 }
15102
15103 /* Silence treshold */
15105 if ((val = ast_variable_retrieve(cfg, "general", "silencethreshold")))
15106 silencethreshold = atoi(val);
15107
15108 if (!(val = ast_variable_retrieve(cfg, "general", "serveremail")))
15111
15112 vmmaxsecs = 0;
15113 if ((val = ast_variable_retrieve(cfg, "general", "maxsecs"))) {
15114 if (sscanf(val, "%30d", &x) == 1) {
15115 vmmaxsecs = x;
15116 } else {
15117 ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
15118 }
15119 } else if ((val = ast_variable_retrieve(cfg, "general", "maxmessage"))) {
15120 static int maxmessage_deprecate = 0;
15121 if (maxmessage_deprecate == 0) {
15122 maxmessage_deprecate = 1;
15123 ast_log(AST_LOG_WARNING, "Setting 'maxmessage' has been deprecated in favor of 'maxsecs'.\n");
15124 }
15125 if (sscanf(val, "%30d", &x) == 1) {
15126 vmmaxsecs = x;
15127 } else {
15128 ast_log(AST_LOG_WARNING, "Invalid max message time length\n");
15129 }
15130 }
15131
15132 vmminsecs = 0;
15133 if ((val = ast_variable_retrieve(cfg, "general", "minsecs"))) {
15134 if (sscanf(val, "%30d", &x) == 1) {
15135 vmminsecs = x;
15136 if (maxsilence / 1000 >= vmminsecs) {
15137 ast_log(AST_LOG_WARNING, "maxsilence should be less than minsecs or you may get empty messages\n");
15138 }
15139 } else {
15140 ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
15141 }
15142 } else if ((val = ast_variable_retrieve(cfg, "general", "minmessage"))) {
15143 static int maxmessage_deprecate = 0;
15144 if (maxmessage_deprecate == 0) {
15145 maxmessage_deprecate = 1;
15146 ast_log(AST_LOG_WARNING, "Setting 'minmessage' has been deprecated in favor of 'minsecs'.\n");
15147 }
15148 if (sscanf(val, "%30d", &x) == 1) {
15149 vmminsecs = x;
15150 if (maxsilence / 1000 >= vmminsecs) {
15151 ast_log(AST_LOG_WARNING, "maxsilence should be less than minmessage or you may get empty messages\n");
15152 }
15153 } else {
15154 ast_log(AST_LOG_WARNING, "Invalid min message time length\n");
15155 }
15156 }
15157
15158 val = ast_variable_retrieve(cfg, "general", "format");
15159 if (!val) {
15160 val = "wav";
15161 } else {
15162 tmp = ast_strdupa(val);
15164 if (!val) {
15165 ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n");
15166 val = "wav";
15167 }
15168 }
15169 ast_copy_string(vmfmts, val, sizeof(vmfmts));
15170
15171 skipms = 3000;
15172 if ((val = ast_variable_retrieve(cfg, "general", "maxgreet"))) {
15173 if (sscanf(val, "%30d", &x) == 1) {
15174 maxgreet = x;
15175 } else {
15176 ast_log(AST_LOG_WARNING, "Invalid max message greeting length\n");
15177 }
15178 }
15179
15180 if ((val = ast_variable_retrieve(cfg, "general", "skipms"))) {
15181 if (sscanf(val, "%30d", &x) == 1) {
15182 skipms = x;
15183 } else {
15184 ast_log(AST_LOG_WARNING, "Invalid skipms value\n");
15185 }
15186 }
15187
15188 maxlogins = 3;
15189 if ((val = ast_variable_retrieve(cfg, "general", "maxlogins"))) {
15190 if (sscanf(val, "%30d", &x) == 1) {
15191 maxlogins = x;
15192 } else {
15193 ast_log(AST_LOG_WARNING, "Invalid max failed login attempts\n");
15194 }
15195 }
15196
15198 if ((val = ast_variable_retrieve(cfg, "general", "minpassword"))) {
15199 if (sscanf(val, "%30d", &x) == 1) {
15200 minpassword = x;
15201 } else {
15202 ast_log(AST_LOG_WARNING, "Invalid minimum password length. Default to %d\n", minpassword);
15203 }
15204 }
15205
15206 /* Force new user to record name ? */
15207 if (!(val = ast_variable_retrieve(cfg, "general", "forcename")))
15208 val = "no";
15210
15211 /* Force new user to record greetings ? */
15212 if (!(val = ast_variable_retrieve(cfg, "general", "forcegreetings")))
15213 val = "no";
15215
15216 if ((val = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))) {
15217 ast_debug(1, "VM_CID Internal context string: %s\n", val);
15218 stringp = ast_strdupa(val);
15219 for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
15220 if (!ast_strlen_zero(stringp)) {
15221 q = strsep(&stringp, ",");
15222 while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
15223 q++;
15225 ast_debug(1, "VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
15226 } else {
15227 cidinternalcontexts[x][0] = '\0';
15228 }
15229 }
15230 }
15231 if (!(val = ast_variable_retrieve(cfg, "general", "review"))){
15232 ast_debug(1, "VM Review Option disabled globally\n");
15233 val = "no";
15234 }
15236
15237 if (!(val = ast_variable_retrieve(cfg, "general", "leaveurgent"))){
15238 val = "yes";
15239 } else if (ast_false(val)) {
15240 ast_debug(1, "VM leave urgent messages disabled globally\n");
15241 val = "no";
15242 }
15244
15245 /* Temporary greeting reminder */
15246 if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
15247 ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n");
15248 val = "no";
15249 } else {
15250 ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n");
15251 }
15253 if (!(val = ast_variable_retrieve(cfg, "general", "messagewrap"))){
15254 ast_debug(1, "VM next message wrap disabled globally\n");
15255 val = "no";
15256 }
15258
15259 if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){
15260 ast_debug(1, "VM Operator break disabled globally\n");
15261 val = "no";
15262 }
15264
15265 if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) {
15266 ast_debug(1, "VM CID Info before msg disabled globally\n");
15267 val = "no";
15268 }
15270
15271 if (!(val = ast_variable_retrieve(cfg, "general", "sendvoicemail"))){
15272 ast_debug(1, "Send Voicemail msg disabled globally\n");
15273 val = "no";
15274 }
15276
15277 if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) {
15278 ast_debug(1, "ENVELOPE before msg enabled globally\n");
15279 val = "yes";
15280 }
15282
15283 if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) {
15284 ast_debug(1, "Move Heard enabled globally\n");
15285 val = "yes";
15286 }
15288
15289 if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) {
15290 ast_debug(1, "Autoset of Urgent flag on forwarded Urgent messages disabled globally\n");
15291 val = "no";
15292 }
15294
15295 if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) {
15296 ast_debug(1, "Duration info before msg enabled globally\n");
15297 val = "yes";
15298 }
15300
15301 saydurationminfo = 2;
15302 if ((val = ast_variable_retrieve(cfg, "general", "saydurationm"))) {
15303 if (sscanf(val, "%30d", &x) == 1) {
15304 saydurationminfo = x;
15305 } else {
15306 ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
15307 }
15308 }
15309
15310 if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
15311 ast_debug(1, "We are not going to skip to the next msg after save/delete\n");
15312 val = "no";
15313 }
15315
15316 if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) {
15318 ast_debug(1, "found dialout context: %s\n", dialcontext);
15319 } else {
15320 dialcontext[0] = '\0';
15321 }
15322
15323 if ((val = ast_variable_retrieve(cfg, "general", "callback"))) {
15325 ast_debug(1, "found callback context: %s\n", callcontext);
15326 } else {
15327 callcontext[0] = '\0';
15328 }
15329
15330 if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
15332 ast_debug(1, "found operator context: %s\n", exitcontext);
15333 } else {
15334 exitcontext[0] = '\0';
15335 }
15336
15337 /* load password sounds configuration */
15338 if ((val = ast_variable_retrieve(cfg, "general", "vm-login")))
15340 if ((val = ast_variable_retrieve(cfg, "general", "vm-newuser")))
15342 if ((val = ast_variable_retrieve(cfg, "general", "vm-password")))
15344 if ((val = ast_variable_retrieve(cfg, "general", "vm-newpassword")))
15346 if ((val = ast_variable_retrieve(cfg, "general", "vm-invalid-password")))
15348 if ((val = ast_variable_retrieve(cfg, "general", "vm-passchanged")))
15350 if ((val = ast_variable_retrieve(cfg, "general", "vm-reenterpassword")))
15352 if ((val = ast_variable_retrieve(cfg, "general", "vm-mismatch")))
15354 if ((val = ast_variable_retrieve(cfg, "general", "vm-pls-try-again"))) {
15356 }
15357 if ((val = ast_variable_retrieve(cfg, "general", "vm-prepend-timeout"))) {
15359 }
15360 /* load configurable audio prompts */
15361 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-forward-key")) && is_valid_dtmf(val))
15363 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-reverse-key")) && is_valid_dtmf(val))
15365 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-pause-key")) && is_valid_dtmf(val))
15367 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-restart-key")) && is_valid_dtmf(val))
15369 if ((val = ast_variable_retrieve(cfg, "general", "listen-control-stop-key")) && is_valid_dtmf(val))
15371
15372 if (!(val = ast_variable_retrieve(cfg, "general", "usedirectory")))
15373 val = "no";
15375
15376 if (!(val = ast_variable_retrieve(cfg, "general", "passwordlocation"))) {
15377 val = "voicemail.conf";
15378 }
15379 if (!(strcmp(val, "spooldir"))) {
15381 } else {
15383 }
15384
15386 if ((val = ast_variable_retrieve(cfg, "general", "pollfreq"))) {
15387 if (sscanf(val, "%30u", &poll_freq) != 1) {
15389 ast_log(AST_LOG_ERROR, "'%s' is not a valid value for the pollfreq option!\n", val);
15390 }
15391 }
15392
15393 poll_mailboxes = 0;
15394 if ((val = ast_variable_retrieve(cfg, "general", "pollmailboxes")))
15396
15397 memset(fromstring, 0, sizeof(fromstring));
15398 memset(pagerfromstring, 0, sizeof(pagerfromstring));
15399 strcpy(charset, "ISO-8859-1");
15400 if (emailbody) {
15402 emailbody = NULL;
15403 }
15404 if (emailsubject) {
15407 }
15408 if (pagerbody) {
15410 pagerbody = NULL;
15411 }
15412 if (pagersubject) {
15415 }
15416 if ((val = ast_variable_retrieve(cfg, "general", "pbxskip")))
15418 if ((val = ast_variable_retrieve(cfg, "general", "fromstring")))
15420 if ((val = ast_variable_retrieve(cfg, "general", "pagerfromstring")))
15422 if ((val = ast_variable_retrieve(cfg, "general", "charset")))
15424 if ((val = ast_variable_retrieve(cfg, "general", "adsifdn"))) {
15425 sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
15426 for (x = 0; x < 4; x++) {
15427 memcpy(&adsifdn[x], &tmpadsi[x], 1);
15428 }
15429 }
15430 if ((val = ast_variable_retrieve(cfg, "general", "adsisec"))) {
15431 sscanf(val, "%2x%2x%2x%2x", &tmpadsi[0], &tmpadsi[1], &tmpadsi[2], &tmpadsi[3]);
15432 for (x = 0; x < 4; x++) {
15433 memcpy(&adsisec[x], &tmpadsi[x], 1);
15434 }
15435 }
15436 if ((val = ast_variable_retrieve(cfg, "general", "adsiver"))) {
15437 if (atoi(val)) {
15438 adsiver = atoi(val);
15439 }
15440 }
15441 if ((val = ast_variable_retrieve(cfg, "general", "tz"))) {
15443 }
15444 if ((val = ast_variable_retrieve(cfg, "general", "locale"))) {
15445 ast_copy_string(locale, val, sizeof(locale));
15446 }
15447 if ((val = ast_variable_retrieve(cfg, "general", "emailsubject"))) {
15449 }
15450 if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
15452 }
15453 if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
15455 }
15456 if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
15458 }
15459
15460 tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
15461 if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_high"))) {
15462 if (sscanf(val, "%30ld", &tps_queue_high) != 1 || tps_queue_high <= 0) {
15463 ast_log(AST_LOG_WARNING, "Invalid the taskprocessor high water alert trigger level '%s'\n", val);
15464 tps_queue_high = AST_TASKPROCESSOR_HIGH_WATER_LEVEL;
15465 }
15466 }
15467 tps_queue_low = -1;
15468 if ((val = ast_variable_retrieve(cfg, "general", "tps_queue_low"))) {
15469 if (sscanf(val, "%30ld", &tps_queue_low) != 1 ||
15470 tps_queue_low < -1 || tps_queue_high < tps_queue_low) {
15471 ast_log(AST_LOG_WARNING, "Invalid the taskprocessor low water clear alert level '%s'\n", val);
15472 tps_queue_low = -1;
15473 }
15474 }
15475 if (ast_taskprocessor_alert_set_levels(mwi_subscription_tps, tps_queue_low, tps_queue_high)) {
15476 ast_log(AST_LOG_WARNING, "Failed to set alert levels for voicemail taskprocessor.\n");
15477 }
15478
15479 /* load mailboxes from users.conf */
15480 if (ucfg) {
15481 for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
15482 if (!strcasecmp(cat, "general")) {
15483 continue;
15484 }
15485 if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
15486 continue;
15487 if ((current = find_or_create(userscontext, cat))) {
15490 ast_copy_string(current->context, userscontext, sizeof(current->context));
15491 if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) {
15492 current->passwordlocation = OPT_PWLOC_USERSCONF;
15493 }
15494
15495 switch (current->passwordlocation) {
15496 case OPT_PWLOC_SPOOLDIR:
15497 snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox);
15498 read_password_from_file(secretfn, current->password, sizeof(current->password));
15499 }
15500 }
15501 }
15502 }
15503
15504 /* load mailboxes from voicemail.conf */
15505
15506 /*
15507 * Aliases must be loaded before users or the aliases won't be notified
15508 * if there's existing voicemail in the user mailbox.
15509 */
15510 load_aliases(cfg);
15511
15512 load_zonemessages(cfg);
15513
15514 load_users(cfg);
15515
15517
15522
15523 return 0;
15524 } else {
15526 ast_log(AST_LOG_WARNING, "Failed to load configuration file.\n");
15527 return 0;
15528 }
15529}
static char pagerfromstring[100]
static char vm_password[80]
static char vm_invalid_password[80]
#define VM_SEARCH
#define VM_ODBC_AUDIO_ON_DISK
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:784
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:774
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_ODBC_AUDIO_ON_DISK, 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 5733 of file app_voicemail_imap.c.

5734{
5735 char fname[PATH_MAX] = "";
5736 char sox_gain_tmpdir[PATH_MAX];
5737 char *file_to_delete = NULL, *dir_to_delete = NULL;
5738 int res;
5739 char altfname[PATH_MAX] = "";
5740 int altused = 0;
5741 char altformat[80] = "";
5742 char *c = NULL;
5743
5744 /* Eww. We want formats to tell us their own MIME type */
5745 char *mime_type = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
5746
5747 /* Users of multiple file formats need special attention. */
5748 snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5749 if (!ast_file_is_readable(fname)) {
5750 ast_copy_string(altformat, vmfmts, sizeof(altformat));
5751 c = strchr(altformat, '|');
5752 if (c) {
5753 *c = '\0';
5754 }
5755 ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - trying first/alternate format %s\n", fname, strerror(errno), altformat);
5756 snprintf(altfname, sizeof(altfname), "%s.%s", attach, altformat);
5757 if (!ast_file_is_readable(altfname)) {
5758 ast_log(AST_LOG_WARNING, "Failed to open file: %s: %s - alternate format %s failure\n", altfname, strerror(errno), altformat);
5759 } else {
5760 altused = 1;
5761 }
5762 }
5763
5764 /* This 'while' loop will only execute once. We use it so that we can 'break' */
5765 while (vmu->volgain < -.001 || vmu->volgain > .001 || altused) {
5766 char tmpdir[PATH_MAX];
5767
5768 create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
5769
5770 res = snprintf(sox_gain_tmpdir, sizeof(sox_gain_tmpdir), "%s/vm-gain-XXXXXX", tmpdir);
5771 if (res >= sizeof(sox_gain_tmpdir)) {
5772 ast_log(LOG_ERROR, "Failed to create temporary directory path %s: Out of buffer space\n", tmpdir);
5773 break;
5774 }
5775
5776 if (mkdtemp(sox_gain_tmpdir)) {
5777 int soxstatus = 0;
5778 char sox_gain_cmd[PATH_MAX];
5779
5780 ast_debug(3, "sox_gain_tmpdir: %s\n", sox_gain_tmpdir);
5781
5782 /* Save for later */
5783 dir_to_delete = sox_gain_tmpdir;
5784
5785 res = snprintf(fname, sizeof(fname), "%s/output.%s", sox_gain_tmpdir, format);
5786 if (res >= sizeof(fname)) {
5787 ast_log(LOG_ERROR, "Failed to create filename buffer for %s/output.%s: Too long\n", sox_gain_tmpdir, format);
5788 break;
5789 }
5790
5791 if (!altused) {
5792 res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5793 vmu->volgain, attach, format, fname);
5794 } else {
5795 if (!strcasecmp(format, "wav")) {
5796 if (vmu->volgain < -.001 || vmu->volgain > .001) {
5797 res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s -e signed-integer -b 16 %s",
5798 vmu->volgain, attach, altformat, fname);
5799 } else {
5800 res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s -e signed-integer -b 16 %s",
5801 attach, altformat, fname);
5802 }
5803 } else {
5804 if (vmu->volgain < -.001 || vmu->volgain > .001) {
5805 res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox -v %.4f %s.%s %s",
5806 vmu->volgain, attach, altformat, fname);
5807 } else {
5808 res = snprintf(sox_gain_cmd, sizeof(sox_gain_cmd), "sox %s.%s %s",
5809 attach, altformat, fname);
5810 }
5811 }
5812 }
5813
5814 if (res >= sizeof(sox_gain_cmd)) {
5815 ast_log(LOG_ERROR, "Failed to generate sox command, out of buffer space\n");
5816 break;
5817 }
5818
5819 soxstatus = ast_safe_system(sox_gain_cmd);
5820 if (!soxstatus) {
5821 /* Save for later */
5822 file_to_delete = fname;
5823 ast_debug(3, "VOLGAIN: Stored at: %s - Level: %.4f - Mailbox: %s\n", fname, vmu->volgain, mailbox);
5824 } else {
5825 ast_log(LOG_WARNING, "Sox failed to re-encode %s: %s (have you installed support for all sox file formats?)\n",
5826 fname,
5827 soxstatus == 1 ? "Problem with command line options" : "An error occurred during file processing");
5828 ast_log(LOG_WARNING, "Voicemail attachment will have no volume gain.\n");
5829 }
5830 }
5831
5832 break;
5833 }
5834
5835 if (!file_to_delete) {
5836 res = snprintf(fname, sizeof(fname), "%s.%s", attach, format);
5837 if (res >= sizeof(fname)) {
5838 ast_log(LOG_ERROR, "Failed to create filename buffer for %s.%s: Too long\n", attach, format);
5839 return -1;
5840 }
5841 }
5842
5843 fprintf(p, "--%s" ENDL, bound);
5844 if (msgnum > -1)
5845 fprintf(p, "Content-Type: %s%s; name=\"%s\"" ENDL, mime_type, format, filename);
5846 else
5847 fprintf(p, "Content-Type: %s%s; name=\"%s.%s\"" ENDL, mime_type, format, greeting_attachment, format);
5848 fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
5849 fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
5850 if (msgnum > -1)
5851 fprintf(p, "Content-Disposition: attachment; filename=\"%s\"" ENDL ENDL, filename);
5852 else
5853 fprintf(p, "Content-Disposition: attachment; filename=\"%s.%s\"" ENDL ENDL, greeting_attachment, format);
5855 if (last)
5856 fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound);
5857
5858 if (file_to_delete) {
5859 unlink(file_to_delete);
5860 }
5861
5862 if (dir_to_delete) {
5863 rmdir(dir_to_delete);
5864 }
5865
5866 return 0;
5867}
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 13273 of file app_voicemail_imap.c.

13274{
13275 struct ast_variable *var;
13276 struct ast_category *cat;
13277 generate_msg_id(id);
13278
13279 var = ast_variable_new("msg_id", id, "");
13280 if (!var) {
13281 return -1;
13282 }
13283
13284 cat = ast_category_get(msg_cfg, "message", NULL);
13285 if (!cat) {
13286 ast_log(LOG_ERROR, "Voicemail data file %s/%d.txt has no [message] category?\n", dir, msg);
13288 return -1;
13289 }
13290
13292
13293 if (ast_config_text_file_save(filename, msg_cfg, "app_voicemail")) {
13294 ast_log(LOG_WARNING, "Unable to update %s to have a message ID\n", filename);
13295 return -1;
13296 }
13297
13298 UPDATE_MSG_ID(dir, msg, id, vmu, msg_cfg, folder);
13299 return 0;
13300}
#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:2716
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:1120
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 7851 of file app_voicemail_imap.c.

7852{
7853 int x;
7854 if (!ast_adsi_available(chan))
7855 return;
7856 x = ast_adsi_load_session(chan, adsifdn, adsiver, 1);
7857 if (x < 0) {
7858 *useadsi = 0;
7860 return;
7861 }
7862 if (!x) {
7863 if (adsi_load_vmail(chan, useadsi)) {
7864 ast_log(AST_LOG_WARNING, "Unable to upload voicemail scripts\n");
7865 return;
7866 }
7867 } else
7868 *useadsi = 1;
7869}
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:891
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 8050 of file app_voicemail_imap.c.

8051{
8052 int bytes = 0;
8053 unsigned char buf[256];
8054 unsigned char keys[8];
8055
8056 int x;
8057
8058 if (!ast_adsi_available(chan))
8059 return;
8060
8061 /* New meaning for keys */
8062 for (x = 0; x < 5; x++)
8063 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
8064
8065 keys[6] = 0x0;
8066 keys[7] = 0x0;
8067
8068 if (!vms->curmsg) {
8069 /* No prev key, provide "Folder" instead */
8070 keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
8071 }
8072 if (vms->curmsg >= vms->lastmsg) {
8073 /* If last message ... */
8074 if (vms->curmsg) {
8075 /* but not only message, provide "Folder" instead */
8076 keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
8077 } else {
8078 /* Otherwise if only message, leave blank */
8079 keys[3] = 1;
8080 }
8081 }
8082
8083 /* If deleted, show "undeleted" */
8084#ifdef IMAP_STORAGE
8085 ast_mutex_lock(&vms->lock);
8086#endif
8087 if (vms->deleted[vms->curmsg]) {
8088 keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
8089 }
8090#ifdef IMAP_STORAGE
8091 ast_mutex_unlock(&vms->lock);
8092#endif
8093
8094 /* Except "Exit" */
8095 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
8096 bytes += ast_adsi_set_keys(buf + bytes, keys);
8097 bytes += ast_adsi_voice_mode(buf + bytes, 0);
8098
8100}
#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 7919 of file app_voicemail_imap.c.

7920{
7921 unsigned char buf[256];
7922 int bytes = 0;
7923 unsigned char keys[8];
7924 int x, y;
7925
7926 if (!ast_adsi_available(chan))
7927 return;
7928
7929 for (x = 0; x < 5; x++) {
7930 y = ADSI_KEY_APPS + 12 + start + x;
7931 if (y > ADSI_KEY_APPS + 12 + 4)
7932 y = 0;
7933 keys[x] = ADSI_KEY_SKT | y;
7934 }
7935 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 17);
7936 keys[6] = 0;
7937 keys[7] = 0;
7938
7939 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, label, "");
7940 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
7941 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7942 bytes += ast_adsi_set_keys(buf + bytes, keys);
7943 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7944
7946}
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 8205 of file app_voicemail_imap.c.

8206{
8207 unsigned char buf[256];
8208 int bytes = 0;
8209
8210 if (!ast_adsi_available(chan))
8211 return;
8212 bytes += adsi_logo(buf + bytes);
8213 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
8214 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
8215 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
8216 bytes += ast_adsi_voice_mode(buf + bytes, 0);
8217
8219}
#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 7722 of file app_voicemail_imap.c.

7723{
7724 unsigned char buf[256];
7725 int bytes = 0;
7726 int x;
7727 char num[5];
7728
7729 *useadsi = 0;
7730 bytes += ast_adsi_data_mode(buf + bytes);
7732
7733 bytes = 0;
7734 bytes += adsi_logo(buf);
7735 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7736#ifdef DISPLAY
7737 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .", "");
7738#endif
7739 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7740 bytes += ast_adsi_data_mode(buf + bytes);
7742
7744 bytes = 0;
7745 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Cancelled.", "");
7746 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7747 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7748 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7750 return 0;
7751 }
7752
7753#ifdef DISPLAY
7754 /* Add a dot */
7755 bytes = 0;
7756 bytes += ast_adsi_logo(buf);
7757 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Downloading Scripts", "");
7758 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ..", "");
7759 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7761#endif
7762 bytes = 0;
7763 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1);
7764 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1);
7765 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advanced", "3", 1);
7766 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1);
7767 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1);
7768 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1);
7770
7771#ifdef DISPLAY
7772 /* Add another dot */
7773 bytes = 0;
7774 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ...", "");
7775 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7776
7777 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7779#endif
7780
7781 bytes = 0;
7782 /* These buttons we load but don't use yet */
7783 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 6, "Previous", "Prev", "4", 1);
7784 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 8, "Repeat", "Repeat", "5", 1);
7785 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 7, "Delete", "Delete", "7", 1);
7786 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 9, "Next", "Next", "6", 1);
7787 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 10, "Save", "Save", "9", 1);
7788 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 11, "Undelete", "Restore", "7", 1);
7790
7791#ifdef DISPLAY
7792 /* Add another dot */
7793 bytes = 0;
7794 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " ....", "");
7795 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7797#endif
7798
7799 bytes = 0;
7800 for (x = 0; x < 5; x++) {
7801 snprintf(num, sizeof(num), "%d", x);
7802 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(NULL, x), mbox(NULL, x), num, 1);
7803 }
7804 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + 5, "Cancel", "Cancel", "#", 1);
7806
7807#ifdef DISPLAY
7808 /* Add another dot */
7809 bytes = 0;
7810 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, " .....", "");
7811 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7813#endif
7814
7815 if (ast_adsi_end_download(chan)) {
7816 bytes = 0;
7817 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Download Unsuccessful.", "");
7818 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "ADSI Unavailable", "");
7819 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7820 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7822 return 0;
7823 }
7824 bytes = 0;
7825 bytes += ast_adsi_download_disconnect(buf + bytes);
7826 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7828
7829 ast_debug(1, "Done downloading scripts...\n");
7830
7831#ifdef DISPLAY
7832 /* Add last dot */
7833 bytes = 0;
7834 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
7835 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7836#endif
7837 ast_debug(1, "Restarting session...\n");
7838
7839 bytes = 0;
7840 /* Load the session now */
7841 if (ast_adsi_load_session(chan, adsifdn, adsiver, 1) == 1) {
7842 *useadsi = 1;
7843 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Scripts Loaded!", "");
7844 } else
7845 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Load Failed!", "");
7846
7848 return 0;
7849}
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 7871 of file app_voicemail_imap.c.

7872{
7873 unsigned char buf[256];
7874 int bytes = 0;
7875 unsigned char keys[8];
7876 int x;
7877 if (!ast_adsi_available(chan))
7878 return;
7879
7880 for (x = 0; x < 8; x++)
7881 keys[x] = 0;
7882 /* Set one key for next */
7883 keys[3] = ADSI_KEY_APPS + 3;
7884
7885 bytes += adsi_logo(buf + bytes);
7886 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, " ", "");
7887 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ", "");
7888 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7889 bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Mailbox: ******", "");
7890 bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 1, 1, ADSI_JUST_LEFT);
7891 bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Enter", "Enter", "#", 1);
7892 bytes += ast_adsi_set_keys(buf + bytes, keys);
7893 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7895}
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 7714 of file app_voicemail_imap.c.

7715{
7716 int bytes = 0;
7717 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_CENT, 0, "Comedian Mail", "");
7718 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, "(C)2002-2006 Digium, Inc.", "");
7719 return bytes;
7720}

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

7949{
7950 int bytes = 0;
7951 unsigned char buf[256];
7952 char buf1[256], buf2[256];
7953 char fn2[PATH_MAX];
7954
7955 char cid[256] = "";
7956 char *val;
7957 char *name, *num;
7958 char datetime[21] = "";
7959 FILE *f;
7960
7961 unsigned char keys[8];
7962
7963 int x;
7964
7965 if (!ast_adsi_available(chan))
7966 return;
7967
7968 /* Retrieve important info */
7969 snprintf(fn2, sizeof(fn2), "%s.txt", vms->fn);
7970 f = fopen(fn2, "r");
7971 if (f) {
7972 while (!feof(f)) {
7973 if (!fgets((char *) buf, sizeof(buf), f)) {
7974 continue;
7975 }
7976 if (!feof(f)) {
7977 char *stringp = NULL;
7978 stringp = (char *) buf;
7979 strsep(&stringp, "=");
7980 val = strsep(&stringp, "=");
7981 if (!ast_strlen_zero(val)) {
7982 if (!strcmp((char *) buf, "callerid"))
7983 ast_copy_string(cid, val, sizeof(cid));
7984 if (!strcmp((char *) buf, "origdate"))
7985 ast_copy_string(datetime, val, sizeof(datetime));
7986 }
7987 }
7988 }
7989 fclose(f);
7990 }
7991 /* New meaning for keys */
7992 for (x = 0; x < 5; x++)
7993 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
7994 keys[6] = 0x0;
7995 keys[7] = 0x0;
7996
7997 if (!vms->curmsg) {
7998 /* No prev key, provide "Folder" instead */
7999 keys[0] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
8000 }
8001 if (vms->curmsg >= vms->lastmsg) {
8002 /* If last message ... */
8003 if (vms->curmsg) {
8004 /* but not only message, provide "Folder" instead */
8005 keys[3] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 1);
8006 bytes += ast_adsi_voice_mode(buf + bytes, 0);
8007
8008 } else {
8009 /* Otherwise if only message, leave blank */
8010 keys[3] = 1;
8011 }
8012 }
8013
8014 if (!ast_strlen_zero(cid)) {
8015 ast_callerid_parse(cid, &name, &num);
8016 if (!name)
8017 name = num;
8018 } else {
8019 name = "Unknown Caller";
8020 }
8021
8022 /* If deleted, show "undeleted" */
8023#ifdef IMAP_STORAGE
8024 ast_mutex_lock(&vms->lock);
8025#endif
8026 if (vms->deleted[vms->curmsg]) {
8027 keys[1] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 11);
8028 }
8029#ifdef IMAP_STORAGE
8030 ast_mutex_unlock(&vms->lock);
8031#endif
8032
8033 /* Except "Exit" */
8034 keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
8035 snprintf(buf1, sizeof(buf1), "%s%s", vms->curbox,
8036 strcasecmp(vms->curbox, "INBOX") ? " Messages" : "");
8037 snprintf(buf2, sizeof(buf2), "Message %d of %d", vms->curmsg + 1, vms->lastmsg + 1);
8038
8039 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
8040 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
8041 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, name, "");
8042 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, datetime, "");
8043 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
8044 bytes += ast_adsi_set_keys(buf + bytes, keys);
8045 bytes += ast_adsi_voice_mode(buf + bytes, 0);
8046
8048}
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 7897 of file app_voicemail_imap.c.

7898{
7899 unsigned char buf[256];
7900 int bytes = 0;
7901 unsigned char keys[8];
7902 int x;
7903 if (!ast_adsi_available(chan))
7904 return;
7905
7906 for (x = 0; x < 8; x++)
7907 keys[x] = 0;
7908 /* Set one key for next */
7909 keys[3] = ADSI_KEY_APPS + 3;
7910
7911 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
7912 bytes += ast_adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
7913 bytes += ast_adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
7914 bytes += ast_adsi_set_keys(buf + bytes, keys);
7915 bytes += ast_adsi_voice_mode(buf + bytes, 0);
7917}

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

8103{
8104 unsigned char buf[256] = "";
8105 char buf1[256] = "", buf2[256] = "";
8106 int bytes = 0;
8107 unsigned char keys[8];
8108 int x;
8109
8110 char *newm = (vms->newmessages == 1) ? "message" : "messages";
8111 char *oldm = (vms->oldmessages == 1) ? "message" : "messages";
8112 if (!ast_adsi_available(chan))
8113 return;
8114 if (vms->newmessages) {
8115 snprintf(buf1, sizeof(buf1), "You have %d new", vms->newmessages);
8116 if (vms->oldmessages) {
8117 strncat(buf1, " and", sizeof(buf1) - strlen(buf1) - 1);
8118 snprintf(buf2, sizeof(buf2), "%d old %s.", vms->oldmessages, oldm);
8119 } else {
8120 snprintf(buf2, sizeof(buf2), "%s.", newm);
8121 }
8122 } else if (vms->oldmessages) {
8123 snprintf(buf1, sizeof(buf1), "You have %d old", vms->oldmessages);
8124 snprintf(buf2, sizeof(buf2), "%s.", oldm);
8125 } else {
8126 strcpy(buf1, "You have no messages.");
8127 buf2[0] = ' ';
8128 buf2[1] = '\0';
8129 }
8130 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
8131 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
8132 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
8133
8134 for (x = 0; x < 6; x++)
8135 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
8136 keys[6] = 0;
8137 keys[7] = 0;
8138
8139 /* Don't let them listen if there are none */
8140 if (vms->lastmsg < 0)
8141 keys[0] = 1;
8142 bytes += ast_adsi_set_keys(buf + bytes, keys);
8143
8144 bytes += ast_adsi_voice_mode(buf + bytes, 0);
8145
8147}
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 8149 of file app_voicemail_imap.c.

8150{
8151 unsigned char buf[256] = "";
8152 char buf1[256] = "", buf2[256] = "";
8153 int bytes = 0;
8154 unsigned char keys[8];
8155 int x;
8156
8157 char *mess = (vms->lastmsg == 0) ? "message" : "messages";
8158
8159 if (!ast_adsi_available(chan))
8160 return;
8161
8162 /* Original command keys */
8163 for (x = 0; x < 6; x++)
8164 keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
8165
8166 keys[6] = 0;
8167 keys[7] = 0;
8168
8169 if ((vms->lastmsg + 1) < 1)
8170 keys[0] = 0;
8171
8172 snprintf(buf1, sizeof(buf1), "%s%s has", vms->curbox,
8173 strcasecmp(vms->curbox, "INBOX") ? " folder" : "");
8174
8175 if (vms->lastmsg + 1)
8176 snprintf(buf2, sizeof(buf2), "%d %s.", vms->lastmsg + 1, mess);
8177 else
8178 strcpy(buf2, "no messages.");
8179 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 1, ADSI_JUST_LEFT, 0, buf1, "");
8180 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
8181 bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, "", "");
8182 bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
8183 bytes += ast_adsi_set_keys(buf + bytes, keys);
8184
8185 bytes += ast_adsi_voice_mode(buf + bytes, 0);
8186
8188
8189}

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

16491{
16492 int res = 0;
16493 char filename[PATH_MAX];
16494 struct ast_config *msg_cfg = NULL;
16495 const char *origtime, *context;
16496 char *name, *num;
16497 int retries = 0;
16498 char *cid;
16499 struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE, };
16500
16501 vms->starting = 0;
16502
16503 make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
16504
16505 /* Retrieve info from VM attribute file */
16506 snprintf(filename, sizeof(filename), "%s.txt", vms->fn);
16507 RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context);
16508 msg_cfg = ast_config_load(filename, config_flags);
16509 DISPOSE(vms->curdir, vms->curmsg);
16510 if (!valid_config(msg_cfg)) {
16511 ast_log(AST_LOG_WARNING, "No message attribute file?!! (%s)\n", filename);
16512 return 0;
16513 }
16514
16515 if (!(origtime = ast_variable_retrieve(msg_cfg, "message", "origtime"))) {
16516 ast_config_destroy(msg_cfg);
16517 return 0;
16518 }
16519
16520 cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid"));
16521
16522 context = ast_variable_retrieve(msg_cfg, "message", "context");
16523 switch (option) {
16524 case 3: /* Play message envelope */
16525 if (!res) {
16526 res = play_message_datetime(chan, vmu, origtime, filename);
16527 }
16528 if (!res) {
16529 res = play_message_callerid(chan, vms, cid, context, 0, 1);
16530 }
16531
16532 res = 't';
16533 break;
16534
16535 case 2: /* Call back */
16536
16537 if (ast_strlen_zero(cid))
16538 break;
16539
16540 ast_callerid_parse(cid, &name, &num);
16541 while ((res > -1) && (res != 't')) {
16542 switch (res) {
16543 case '1':
16544 if (num) {
16545 /* Dial the CID number */
16546 res = dialout(chan, vmu, num, vmu->callback);
16547 if (res) {
16548 ast_config_destroy(msg_cfg);
16549 return 9;
16550 }
16551 } else {
16552 res = '2';
16553 }
16554 break;
16555
16556 case '2':
16557 /* Want to enter a different number, can only do this if there's a dialout context for this user */
16558 if (!ast_strlen_zero(vmu->dialout)) {
16559 res = dialout(chan, vmu, NULL, vmu->dialout);
16560 if (res) {
16561 ast_config_destroy(msg_cfg);
16562 return 9;
16563 }
16564 } else {
16565 ast_verb(3, "Caller can not specify callback number - no dialout context available\n");
16566 res = ast_play_and_wait(chan, "vm-sorry");
16567 }
16568 ast_config_destroy(msg_cfg);
16569 return res;
16570 case '*':
16571 res = 't';
16572 break;
16573 case '3':
16574 case '4':
16575 case '5':
16576 case '6':
16577 case '7':
16578 case '8':
16579 case '9':
16580 case '0':
16581
16582 res = ast_play_and_wait(chan, "vm-sorry");
16583 retries++;
16584 break;
16585 default:
16586 if (num) {
16587 ast_verb(3, "Confirm CID number '%s' is number to use for callback\n", num);
16588 res = ast_play_and_wait(chan, "vm-num-i-have");
16589 if (!res)
16590 res = play_message_callerid(chan, vms, num, vmu->context, 1, 1);
16591 if (!res)
16592 res = ast_play_and_wait(chan, "vm-tocallnum");
16593 /* Only prompt for a caller-specified number if there is a dialout context specified */
16594 if (!ast_strlen_zero(vmu->dialout)) {
16595 if (!res)
16596 res = ast_play_and_wait(chan, "vm-calldiffnum");
16597 }
16598 } else {
16599 res = ast_play_and_wait(chan, "vm-nonumber");
16600 if (!ast_strlen_zero(vmu->dialout)) {
16601 if (!res)
16602 res = ast_play_and_wait(chan, "vm-toenternumber");
16603 }
16604 }
16605 if (!res) {
16606 res = ast_play_and_wait(chan, "vm-star-cancel");
16607 }
16608 if (!res) {
16609 res = ast_waitfordigit(chan, 6000);
16610 }
16611 if (!res) {
16612 retries++;
16613 if (retries > 3) {
16614 res = 't';
16615 }
16616 }
16617 ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
16618 isprint(res) ? res : '?', isprint(res) ? res : '?');
16619 break;
16620
16621 }
16622 if (res == 't')
16623 res = 0;
16624 else if (res == '*')
16625 res = -1;
16626 }
16627 break;
16628
16629 case 1: /* Reply */
16630 /* Send reply directly to sender */
16631 if (ast_strlen_zero(cid))
16632 break;
16633
16634 ast_callerid_parse(cid, &name, &num);
16635 if (!num) {
16636 ast_verb(3, "No CID number available, no reply sent\n");
16637 if (!res)
16638 res = ast_play_and_wait(chan, "vm-nonumber");
16639 ast_config_destroy(msg_cfg);
16640 return res;
16641 } else {
16642 struct ast_vm_user vmu2, *vmu3;
16643 memset(&vmu2, 0, sizeof(vmu2));
16644 vmu3 = find_user(&vmu2, vmu->context, num);
16645 if (vmu3) {
16646 struct leave_vm_options leave_options;
16647 char mailbox[AST_MAX_EXTENSION * 2 + 2];
16648 snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context);
16649
16650 ast_verb(3, "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
16651
16652 memset(&leave_options, 0, sizeof(leave_options));
16653 leave_options.record_gain = record_gain;
16654 leave_options.beeptone = "beep";
16655 res = leave_voicemail(chan, mailbox, &leave_options);
16656 if (!res)
16657 res = 't';
16658 ast_config_destroy(msg_cfg);
16659 free_user(vmu3);
16660 return res;
16661 } else {
16662 /* Sender has no mailbox, can't reply */
16663 ast_verb(3, "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
16664 ast_play_and_wait(chan, "vm-nobox");
16665 res = 't';
16666 ast_config_destroy(msg_cfg);
16667 return res;
16668 }
16669 }
16670 res = 0;
16671
16672 break;
16673 }
16674
16675 ast_config_destroy(msg_cfg);
16676
16677#ifndef IMAP_STORAGE
16678 if (!res) {
16679 make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg);
16680 vms->heard[msg] = 1;
16681 res = wait_file(chan, vms, vms->fn);
16682 }
16683#endif
16684 return res;
16685}
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:3194
#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 14744 of file app_voicemail_imap.c.

14745{
14746 struct alias_mailbox_mapping *mapping;
14747 size_t from_len = strlen(alias) + 1;
14748 size_t to_len = strlen(mailbox) + 1;
14749
14750 mapping = ao2_alloc(sizeof(*mapping) + from_len + to_len, NULL);
14751 if (!mapping) {
14752 return NULL;
14753 }
14754 mapping->alias = mapping->buf;
14755 mapping->mailbox = mapping->buf + from_len;
14756 ast_copy_string(mapping->alias, alias, from_len); /* Safe */
14757 ast_copy_string(mapping->mailbox, mailbox, to_len); /* Safe */
14758
14759 return mapping;
14760}
#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 13342 of file app_voicemail_imap.c.

13343{
13344 /* Assumes lock is already held */
13345 char *tmp;
13346 char *stringp;
13347 char *s;
13348 struct ast_vm_user *vmu;
13349 char mailbox_full[MAX_VM_MAILBOX_LEN];
13350 int new = 0, old = 0, urgent = 0;
13351 char secretfn[PATH_MAX] = "";
13352
13353 tmp = ast_strdupa(data);
13354
13355 if (!(vmu = find_or_create(context, box)))
13356 return -1;
13357
13358 populate_defaults(vmu);
13359
13360 stringp = tmp;
13361 if ((s = strsep(&stringp, ","))) {
13362 if (!ast_strlen_zero(s) && s[0] == '*') {
13363 ast_log(LOG_WARNING, "Invalid password detected for mailbox %s. The password"
13364 "\n\tmust be reset in voicemail.conf.\n", box);
13365 }
13366 /* assign password regardless of validity to prevent NULL password from being assigned */
13367 ast_copy_string(vmu->password, s, sizeof(vmu->password));
13368 }
13369 if (stringp && (s = strsep(&stringp, ","))) {
13370 ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
13371 }
13372 if (stringp && (s = strsep(&stringp, ","))) {
13373 vmu->email = ast_strdup(s);
13374 }
13375 if (stringp && (s = strsep(&stringp, ","))) {
13376 ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
13377 }
13378 if (stringp) {
13379 apply_options(vmu, stringp);
13380 }
13381
13382 switch (vmu->passwordlocation) {
13383 case OPT_PWLOC_SPOOLDIR:
13384 snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, vmu->context, vmu->mailbox);
13385 read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
13386 }
13387
13388 snprintf(mailbox_full, MAX_VM_MAILBOX_LEN, "%s%s%s",
13389 box,
13390 ast_strlen_zero(context) ? "" : "@",
13391 context);
13392
13393 inboxcount2(mailbox_full, &urgent, &new, &old);
13394#ifdef IMAP_STORAGE
13395 imap_logout(mailbox_full);
13396#endif
13397 queue_mwi_event(NULL, mailbox_full, urgent, new, old);
13398
13399 return 0;
13400}
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 14283 of file app_voicemail_imap.c.

14289{
14290 struct ast_vm_mailbox_snapshot *mailbox_snapshot;
14291 struct ast_vm_msg_snapshot *msg;
14292 int nummessages = 0;
14293 int i;
14294
14295 /* Take a snapshot of the mailbox */
14296 mailbox_snapshot = ast_vm_mailbox_snapshot_create(vmu->mailbox, vmu->context, NULL, 0, AST_VM_SNAPSHOT_SORT_BY_ID, 0);
14297 if (!mailbox_snapshot) {
14298 ast_log(LOG_ERROR, "Could not append voicemail box info for box %s@%s.",
14299 vmu->mailbox, vmu->context);
14300 return 0;
14301 }
14302
14303 astman_send_listack(s, m, "Voicemail box detail will follow", "start");
14304 /* walk through each folder's contents and append info for each message */
14305 for (i = 0; i < mailbox_snapshot->folders; i++) {
14306 AST_LIST_TRAVERSE(&((mailbox_snapshot)->snapshots[i]), msg, msg) {
14307 astman_append(s,
14308 "Event: %s\r\n"
14309 "%s"
14310 "Folder: %s\r\n"
14311 "CallerID: %s\r\n"
14312 "Date: %s\r\n"
14313 "Duration: %s\r\n"
14314 "Flag: %s\r\n"
14315 "ID: %s\r\n"
14316 "\r\n",
14317 event_name,
14318 actionid,
14319 msg->folder_name,
14320 msg->callerid,
14321 msg->origdate,
14322 msg->duration,
14323 msg->flag,
14324 msg->msg_id
14325 );
14326 nummessages++;
14327 }
14328 }
14329
14330 /* done, destroy. */
14331 mailbox_snapshot = ast_vm_mailbox_snapshot_destroy(mailbox_snapshot);
14332 astman_send_list_complete_start(s, m, "VoicemailBoxDetailComplete", nummessages);
14334
14335 return 1;
14336}
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:2011
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:2047
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
Definition: manager.c:2055
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:1890
@ 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 14159 of file app_voicemail_imap.c.

14165{
14166 int new;
14167 int old;
14168 char *mailbox;
14169 int ret;
14170
14171 if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {
14172 ast_log(LOG_ERROR, "Wrong input parameter.");
14173 return 0;
14174 }
14175
14176 /* create mailbox string */
14177 if (!ast_strlen_zero(vmu->context)) {
14178 ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);
14179 } else {
14180 ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);
14181 }
14182 if (ret == -1) {
14183 ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));
14184 return 0;
14185 }
14186
14187 /* get mailbox count */
14188 ret = inboxcount(mailbox, &new, &old);
14190 if (ret == -1) {
14191 ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n",
14192 vmu->mailbox ?: "", vmu->context ?: "");
14193 return 0;
14194 }
14195
14196 astman_append(s,
14197 "Event: %s\r\n"
14198 "%s"
14199 "VMContext: %s\r\n"
14200 "VoiceMailbox: %s\r\n"
14201 "Fullname: %s\r\n"
14202 "Email: %s\r\n"
14203 "Pager: %s\r\n"
14204 "ServerEmail: %s\r\n"
14205 "FromString: %s\r\n"
14206 "MailCommand: %s\r\n"
14207 "Language: %s\r\n"
14208 "TimeZone: %s\r\n"
14209 "Callback: %s\r\n"
14210 "Dialout: %s\r\n"
14211 "UniqueID: %s\r\n"
14212 "ExitContext: %s\r\n"
14213 "SayDurationMinimum: %d\r\n"
14214 "SayEnvelope: %s\r\n"
14215 "SayCID: %s\r\n"
14216 "AttachMessage: %s\r\n"
14217 "AttachmentFormat: %s\r\n"
14218 "DeleteMessage: %s\r\n"
14219 "VolumeGain: %.2f\r\n"
14220 "CanReview: %s\r\n"
14221 "CanMarkUrgent: %s\r\n"
14222 "CallOperator: %s\r\n"
14223 "MaxMessageCount: %d\r\n"
14224 "MaxMessageLength: %d\r\n"
14225 "NewMessageCount: %d\r\n"
14226 "OldMessageCount: %d\r\n"
14227#ifdef IMAP_STORAGE
14228 "IMAPUser: %s\r\n"
14229 "IMAPServer: %s\r\n"
14230 "IMAPPort: %s\r\n"
14231 "IMAPFlags: %s\r\n"
14232#endif
14233 "\r\n",
14234
14235 event_name,
14236 actionid,
14237 vmu->context,
14238 vmu->mailbox,
14239 vmu->fullname,
14240 vmu->email,
14241 vmu->pager,
14244 mailcmd,
14245 vmu->language,
14246 vmu->zonetag,
14247 vmu->callback,
14248 vmu->dialout,
14249 vmu->uniqueid,
14250 vmu->exit,
14251 vmu->saydurationm,
14252 ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
14253 ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
14254 ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
14255 vmu->attachfmt,
14256 ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
14257 vmu->volgain,
14258 ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
14259 ast_test_flag(vmu, VM_MARK_URGENT) ? "Yes" : "No",
14260 ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
14261 vmu->maxmsg,
14262 vmu->maxsecs,
14263 new,
14264 old
14265#ifdef IMAP_STORAGE
14266 ,
14267 vmu->imapuser,
14268 vmu->imapserver,
14269 vmu->imapport,
14270 vmu->imapflags
14271#endif
14272 );
14273
14274 return 1;
14275
14276}
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 1525 of file app_voicemail_imap.c.

1526{
1527 int x;
1528 if (!strcasecmp(var, "attach")) {
1530 } else if (!strcasecmp(var, "attachfmt")) {
1531 ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
1532 } else if (!strcasecmp(var, "attachextrecs")) {
1534 } else if (!strcasecmp(var, "serveremail")) {
1535 ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
1536 } else if (!strcasecmp(var, "fromstring")) {
1537 ast_copy_string(vmu->fromstring, value, sizeof(vmu->fromstring));
1538 } else if (!strcasecmp(var, "emailbody")) {
1539 ast_free(vmu->emailbody);
1541 } else if (!strcasecmp(var, "emailsubject")) {
1542 ast_free(vmu->emailsubject);
1544 } else if (!strcasecmp(var, "language")) {
1545 ast_copy_string(vmu->language, value, sizeof(vmu->language));
1546 } else if (!strcasecmp(var, "tz")) {
1547 ast_copy_string(vmu->zonetag, value, sizeof(vmu->zonetag));
1548 } else if (!strcasecmp(var, "locale")) {
1549 ast_copy_string(vmu->locale, value, sizeof(vmu->locale));
1550#ifdef IMAP_STORAGE
1551 } else if (!strcasecmp(var, "imapuser")) {
1552 ast_copy_string(vmu->imapuser, value, sizeof(vmu->imapuser));
1553 vmu->imapversion = imapversion;
1554 } else if (!strcasecmp(var, "imapserver")) {
1555 ast_copy_string(vmu->imapserver, value, sizeof(vmu->imapserver));
1556 vmu->imapversion = imapversion;
1557 } else if (!strcasecmp(var, "imapport")) {
1558 ast_copy_string(vmu->imapport, value, sizeof(vmu->imapport));
1559 vmu->imapversion = imapversion;
1560 } else if (!strcasecmp(var, "imapflags")) {
1561 ast_copy_string(vmu->imapflags, value, sizeof(vmu->imapflags));
1562 vmu->imapversion = imapversion;
1563 } else if (!strcasecmp(var, "imappassword") || !strcasecmp(var, "imapsecret")) {
1564 ast_copy_string(vmu->imappassword, value, sizeof(vmu->imappassword));
1565 vmu->imapversion = imapversion;
1566 } else if (!strcasecmp(var, "imapfolder")) {
1567 ast_copy_string(vmu->imapfolder, value, sizeof(vmu->imapfolder));
1568 vmu->imapversion = imapversion;
1569 } else if (!strcasecmp(var, "imapvmshareid")) {
1570 ast_copy_string(vmu->imapvmshareid, value, sizeof(vmu->imapvmshareid));
1571 vmu->imapversion = imapversion;
1572#endif
1573 } else if (!strcasecmp(var, "delete") || !strcasecmp(var, "deletevoicemail")) {
1575 } else if (!strcasecmp(var, "saycid")){
1577 } else if (!strcasecmp(var, "sendvoicemail")){
1579 } else if (!strcasecmp(var, "review")){
1581 } else if (!strcasecmp(var, "leaveurgent")){
1583 } else if (!strcasecmp(var, "tempgreetwarn")){
1585 } else if (!strcasecmp(var, "messagewrap")){
1587 } else if (!strcasecmp(var, "operator")) {
1589 } else if (!strcasecmp(var, "envelope")){
1591 } else if (!strcasecmp(var, "moveheard")){
1593 } else if (!strcasecmp(var, "sayduration")){
1595 } else if (!strcasecmp(var, "saydurationm")){
1596 if (sscanf(value, "%30d", &x) == 1) {
1597 vmu->saydurationm = x;
1598 } else {
1599 ast_log(AST_LOG_WARNING, "Invalid min duration for say duration\n");
1600 }
1601 }