Skip to content
Snippets Groups Projects
app_voicemail.c 528 KiB
Newer Older
Mark Spencer's avatar
Mark Spencer committed
/*
 * Asterisk -- An open source telephony toolkit.
Mark Spencer's avatar
Mark Spencer committed
 *
 * Copyright (C) 1999 - 2006, Digium, Inc.
Mark Spencer's avatar
Mark Spencer committed
 *
 * Mark Spencer <markster@digium.com>
Mark Spencer's avatar
Mark Spencer committed
 *
 * See http://www.asterisk.org for more information about
 * the Asterisk project. Please do not directly contact
 * any of the maintainers of this project for assistance;
 * the project provides a web site, mailing lists and IRC
 * channels for your use.
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License Version 2. See the LICENSE file
 * at the top of the source tree.
 */

/*!
 * \file
 * \author Mark Spencer <markster@digium.com>
 * \brief Comedian Mail - Voicemail System
 * unixODBC (http://www.unixodbc.org/)
 * A source distribution of University of Washington's IMAP c-client
 *         (http://www.washington.edu/imap/)
Russell Bryant's avatar
Russell Bryant committed
 * \par See also
 * \arg \ref Config_vm
 * \note For information about voicemail IMAP storage, https://wiki.asterisk.org/wiki/display/AST/IMAP+Voicemail+Storage
Andrew Latham's avatar
Andrew Latham committed
 * \ingroup applications
 * \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.
/*! \li \ref app_voicemail.c uses configuration file \ref voicemail.conf
Andrew Latham's avatar
Andrew Latham committed
 * \addtogroup configuration_file Configuration Files
 */

Andrew Latham's avatar
Andrew Latham committed
 * \page voicemail.conf voicemail.conf
 * \verbinclude voicemail.conf.sample
 */

#ifdef IMAP_STORAGE
#include <ctype.h>
#include <signal.h>
#include <pwd.h>
#ifdef USE_SYSTEM_IMAP
#include <imap/c-client.h>
#include <imap/imap4r1.h>
#include <imap/linkage.h>
#elif defined (USE_SYSTEM_CCLIENT)
#include <c-client/c-client.h>
#include <c-client/imap4r1.h>
#include <c-client/linkage.h>
#include "c-client.h"
#include "imap4r1.h"
#include "linkage.h"
#endif
#include "asterisk/paths.h"	/* use ast_config_AST_SPOOL_DIR */
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <time.h>
#include <dirent.h>
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#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/astobj2.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/test.h"
#ifdef IMAP_STORAGE
#include "asterisk/threadstorage.h"
#endif

/*** DOCUMENTATION
	<application name="VoiceMail" language="en_US">
		<synopsis>
			Leave a Voicemail message.
		</synopsis>
		<syntax>
			<parameter name="mailboxs" argsep="&amp;" required="true">
				<argument name="mailbox1" argsep="@" required="true">
					<argument name="mailbox" required="true" />
					<argument name="context" />
				</argument>
				<argument name="mailbox2" argsep="@" multiple="true">
					<argument name="mailbox" required="true" />
					<argument name="context" />
				</argument>
			</parameter>
			<parameter name="options">
				<optionlist>
					<option name="b">
						<para>Play the <literal>busy</literal> greeting to the calling party.</para>
					</option>
					<option name="d">
						<argument name="c" />
						<para>Accept digits for a new extension in context <replaceable>c</replaceable>,
						if played during the greeting. Context defaults to the current context.</para>
					</option>
					<option name="g">
						<argument name="#" required="true" />
						<para>Use the specified amount of gain when recording the voicemail
						message. The units are whole-number decibels (dB). Only works on supported
						technologies, which is DAHDI only.</para>
					</option>
					<option name="s">
						<para>Skip the playback of instructions for leaving a message to the
						calling party.</para>
					</option>
					<option name="u">
						<para>Play the <literal>unavailable</literal> greeting.</para>
					</option>
					<option name="U">
						<para>Mark message as <literal>URGENT</literal>.</para>
					</option>
					<option name="P">
						<para>Mark message as <literal>PRIORITY</literal>.</para>
					</option>
				</optionlist>
			</parameter>
		</syntax>
		<description>
			<para>This application allows the calling party to leave a message for the specified
			list of mailboxes. When multiple mailboxes are specified, the greeting will be taken from
			the first mailbox specified. Dialplan execution will stop if the specified mailbox does not
			exist.</para>
			<para>The Voicemail application will exit if any of the following DTMF digits are received:</para>
			<enumlist>
				<enum name="0">
					<para>Jump to the <literal>o</literal> extension in the current dialplan context.</para>
				</enum>
				<enum name="*">
					<para>Jump to the <literal>a</literal> extension in the current dialplan context.</para>
				</enum>
			</enumlist>
			<para>This application will set the following channel variable upon completion:</para>
			<variablelist>
				<variable name="VMSTATUS">
					<para>This indicates the status of the execution of the VoiceMail application.</para>
					<value name="SUCCESS" />
					<value name="USEREXIT" />
					<value name="FAILED" />
				</variable>
			</variablelist>
		</description>
		<see-also>
			<ref type="application">VoiceMailMain</ref>
		</see-also>
	</application>
	<application name="VoiceMailMain" language="en_US">
		<synopsis>
			Check Voicemail messages.
		</synopsis>
		<syntax>
			<parameter name="mailbox" required="true" argsep="@">
				<argument name="mailbox" />
				<argument name="context" />
			</parameter>
			<parameter name="options">
				<optionlist>
					<option name="p">
						<para>Consider the <replaceable>mailbox</replaceable> parameter as a prefix to
Loading
Loading full blame...