Commit Graph

1190 Commits

Author SHA1 Message Date
Naveen Albert b791c27385 app_voicemail: Properly reinitialize config after unit tests.
Most app_voicemail unit tests were not properly cleaning up
after themselves after running. This led to test mailboxes
lingering around in the system. It also meant that if any
unit tests in app_voicemail that create mailboxes were executed
and the module was not unloaded/loaded again prior to running
the test_voicemail_vm_info unit test, Asterisk would segfault
due to an attempt to copy a NULL string.

The load_config test did actually have logic to reinitialize
the config after the test. However, this did not work in practice
since load_config() would not reload the config since voicemail.conf
had not changed during the test; thus, additional logic has been
added to ensure that voicemail.conf is truly reloaded, after any
unit tests which modify the users list.

This prevents the SEGV due to invalid mailboxes lingering around,
and also ensures that the system state is restored to what it was
prior to the tests running.

Resolves: #629
2024-03-06 14:05:17 +00:00
Naveen Albert b5850941b1 app_voicemail: Allow preventing mark messages as urgent.
This adds an option to allow preventing callers from leaving
messages marked as 'urgent'.

Resolves: #619

UserNote: The leaveurgent mailbox option can now be used to
control whether callers may leave messages marked as 'Urgent'.
2024-03-05 23:35:11 +00:00
Mike Bradeen 0668e5494a app_voicemail_odbc: remove macrocontext from voicemail_messages table
When app_macro was deprecated, the macrocontext column was removed from
the INSERT statement but the binds were not renumbered. This broke the
insert.

This change removes the macrocontext column via alembic and re-numbers
the existing columns in the INSERT.

Fixes: #527

UserNote: The fix requires removing the macrocontext column from the
voicemail_messages table in the voicemail database via alembic upgrade.

UpgradeNote: The fix requires that the voicemail database be upgraded via
alembic. Upgrading to the latest voicemail database via alembic will
remove the macrocontext column from the voicemail_messages table.
2024-01-17 15:01:38 +00:00
Naveen Albert d1fb397cfc general: Fix broken links.
This fixes a number of broken links throughout the
tree, mostly caused by wiki.asterisk.org being replaced
with docs.asterisk.org, which should eliminate the
need for sporadic fixes as in f28047db36.

Resolves: #430
2023-12-08 13:11:54 +00:00
Sean Bright 3026ac08ab app_voicemail.c: Completely resequence mailbox folders.
Resequencing is a process that occurs when we open a voicemail folder
and discover that there are gaps between messages (e.g. `msg0000.txt`
is missing but `msg0001.txt` exists). Resequencing involves shifting
the existing messages down so we end up with a sequential list of
messages.

Currently, this process stops after reaching a threshold based on the
message limit (`maxmsg`) configured on the current folder. However, if
`maxmsg` is lowered when a voicemail folder contains more than
`maxmsg + 10` messages, resequencing will not run completely leaving
the mailbox in an inconsistent state.

We now resequence up to the maximum number of messages permitted by
`app_voicemail` (currently hard-coded at 9999 messages).

Fixes #86
2023-11-28 20:01:04 +00:00
Naveen Albert d678370b54 app_voicemail: Add AMI event for mailbox PIN changes.
This adds an AMI event that is emitted whenever a
mailbox password is successfully changed, allowing
AMI consumers to process these.

UserNote: The VoicemailPasswordChange event is
now emitted whenever a mailbox password is updated,
containing the mailbox information and the new
password.

Resolves: #398
2023-11-01 12:46:33 +00:00
Naveen Albert d60c3c36e7 app_voicemail: Disable ADSI if unavailable.
If ADSI is available on a channel, app_voicemail will repeatedly
try to use ADSI, even if there is no CPE that supports it. This
leads to many unnecessary delays during the session. If ADSI is
available but ADSI setup fails, we now disable it to prevent
further attempts to use ADSI during the session.

Resolves: #354
2023-10-05 14:35:38 +00:00
Mike Bradeen fce6821106 app_voicemail: Fix for loop declarations
Resolve for loop initial declarations added in cli changes.

Resolves: #275
2023-08-30 13:05:30 +00:00
Mike Bradeen eef5a0b7bf Adds manager actions to allow move/remove/forward individual messages
in a particular mailbox folder. The forward command can be used
to copy a message within a mailbox or to another mailbox. Also adds
a VoicemailBoxSummarry, required to retrieve message ID's.

Resolves: #181

UserNote: The following manager actions have been added

VoicemailBoxSummary - Generate message list for a given mailbox

VoicemailRemove - Remove a message from a mailbox folder

VoicemailMove - Move a message from one folder to another within a mailbox

VoicemailForward - Copy a message from one folder in one mailbox
to another folder in another or the same mailbox.
2023-07-12 17:37:40 +00:00
Mike Bradeen 48c6e3fb1d app_voicemail: add CLI commands for message manipulation
Adds CLI commands to allow move/remove/forward individual messages
from a particular mailbox folder. The forward command can be used
to copy a message within a mailbox or to another mailbox. Also adds
a show mailbox, required to retrieve message ID's.

Resolves: #170

UserNote: The following CLI commands have been added to app_voicemail

voicemail show mailbox <mailbox> <context>
Show contents of mailbox <mailbox>@<context>

voicemail remove <mailbox> <context> <from_folder> <messageid>
Remove message <messageid> from <from_folder> in mailbox <mailbox>@<context>

voicemail move <mailbox> <context> <from_folder> <messageid> <to_folder>
Move message <messageid> in mailbox <mailbox>&<context> from <from_folder> to <to_folder>

voicemail forward <from_mailbox> <from_context> <from_folder> <messageid> <to_mailbox> <to_context> <to_folder>
Forward message <messageid> in mailbox <mailbox>@<context> <from_folder> to
mailbox <mailbox>@<context> <to_folder>
2023-07-12 17:36:58 +00:00
Mike Bradeen 250b3a2f3c app_voicemail: fix imap compilation errors
Fixes two compilation errors in app_voicemail_imap, one due to an unsed
variable and one due to a new variable added in the incorrect location
in _163.

Resolves: #174
2023-06-29 16:08:14 +00:00
Olaf Titz 128a9969a1 app_voicemail_imap: Fix message count when IMAP server is unavailable
Some callers of __messagecount did not correctly handle error return,
instead returning a -1 message count.
This caused a notification with "Messages-Waiting: yes" and
"Voice-Message: -1/0 (0/0)" if the IMAP server was unavailable.

Fixes: #64
2023-06-26 13:03:23 +00:00
Mike Bradeen e8f548c155 app_macro: Remove deprecated module.
For most modules that interacted with app_macro, this change is limited
to no longer looking for the current context from the macrocontext when
set.  Additionally, the following modules are impacted:

app_dial - no longer supports M^ connected/redirecting macro
app_minivm - samples written using macro will no longer work.
The sample needs a re-write

app_queue - can no longer a macro on the called party's channel.
Use gosub which is currently supported

ccss - no callback macro, gosub only

app_voicemail - no macro support

channel  - remove macrocontext and priority, no connected line or
redirection macro options
options - stdexten is deprecated to gosub as the default and only
pbx - removed macrolock
pbx_dundi - no longer look for macro

snmp - removed macro context, exten, and priority

ASTERISK-30304

Change-Id: I830daab293117179b8d61bd4df0d971a1b3d07f6
2023-01-10 14:07:44 -06:00
Naveen Albert 4168fa3466 app_voicemail_odbc: Fix string overflow warning.
Fixes a negative offset warning by initializing
the buffer to empty.

Additionally, although it doesn't currently complain
about it, the size of a buffer is increased to
accomodate the maximum size contents it could have.

ASTERISK-30240 #close

Change-Id: I8eecedf14d3f2a75864797f802277cac89a32877
2022-12-20 08:53:59 -06:00
Naveen Albert 9e14523ca3 app_voicemail: Fix missing email in msg_create_from_file.
msg_create_from_file currently does not dispatch emails,
which means that applications using this function, such
as MixMonitor, will not trigger notifications to users
(only AMI events are sent our currently). This is inconsistent
with other ways users can receive voicemail.

This is fixed by adding an option that attempts to send
an email and falling back to just the notifications as
done now if that fails. The existing behavior remains
the default.

ASTERISK-30283 #close

Change-Id: I597cbb9cf971a18d8776172b26ab187dc096a5c7
2022-12-08 12:18:14 -06:00
Naveen Albert f5378f63c4 general: Improve logging levels of some log messages.
Adjusts some logging levels to be more or less important,
that is more prominent when actual problems occur and less
prominent for less noteworthy things.

ASTERISK-30153 #close

Change-Id: Ifc8f7df427aa018627db462125ae744986d3261b
2022-08-01 11:03:43 -05:00
Naveen Albert cc8e098e1d app_voicemail: Add option to prevent message deletion.
Adds an option to VoiceMailMain that prevents the user
from deleting messages during that application invocation.
This can be useful for public or shared mailboxes, where
some users should be able to listen to messages but not
delete them.

ASTERISK-30063 #close

Change-Id: Icdfb8423ae8d1fce65a056b603eb84a672e80a26
2022-06-15 11:37:06 -05:00
Naveen Albert 39820e3561 app_voicemail: Emit warning if asking for nonexistent mailbox.
Currently, if VoiceMailMain is called with a mailbox, if that
mailbox doesn't exist, then the application silently falls back
to prompting the user for the mailbox, as if no arguments were
provided.

However, if a specific mailbox is requested and it doesn't exist,
then no warning at all is emitted.

This fixes this behavior to now warn if a specifically
requested mailbox could not be accessed, before falling back to
prompting the user for the correct mailbox.

ASTERISK-29920 #close

Change-Id: Ib4093b88cd661a2cabc5d685777d4e2f0ebd20a4
2022-02-23 16:28:41 -06:00
Mark Petersen 4f06de7cf8 app_voicemail.c: Support for Danish syntax in VM
added support for playing the correct plural sound file
dependen on where you have 1 or multipe messages
based on the existing SE/NO code

ASTERISK-29797

Change-Id: I88aa814d02f3772bb80b474204b1ffb26fe438c2
2021-12-14 05:36:39 -05:00
Alexander Traud 826233b550 progdocs: Fix Doxygen left-overs.
Change-Id: I5b5cf9c9cbbe00ba8b379a8d162ac67445d39016
2021-12-13 08:57:26 -06:00
Alexander Traud cc025026b7 progdocs: Fix for Doxygen, the hidden parts.
ASTERISK-29779

Change-Id: If338163488498f65fa7248b60e80299c0a928e4b
2021-12-02 10:37:38 -06:00
Naveen Albert d374d63ef8 app_voicemail: Refactor email generation functions
Refactors generic functions used for email generation
into utils.c so that they can be used by multiple
modules, including app_voicemail and app_minivm,
to avoid code duplication.

ASTERISK-29715 #close

Change-Id: I1de0ed3483623e9599711129edc817c45ad237ee
2021-11-30 09:28:46 -06:00
Alexander Traud 196c24df22 apps: Fix for Doxygen.
ASTERISK-29740

Change-Id: Icb6fbcfea0a5f1c82caa5001902b6a786adbf307
2021-11-18 10:37:56 -06:00
Josh Soref eb03b18ff9 apps: Spelling fixes
Correct typos of the following word families:

simultaneously
administrator
directforward
attachfmt
dailplan
automatically
applicable
nouns
explicit
outside
sponsored
attachment
audio
spied
doesn't
counting
encoded
implements
recursively
emailaddress
arguments
queuerules
members
priority
output
advanced
silencethreshold
brazilian
debugging
argument
meadmin
formatting
integrated
sneakiness

ASTERISK-29714

Change-Id: Ie5ecaec91c00b26309da4e51cfc0991a5bb7d092
2021-11-16 05:38:29 -06:00
Naveen Albert 4e514419d9 app_voicemail: Fix phantom voicemail bug on rerecord
If users are able to press # for options while leaving
a message and then press 3 to rerecord the message, if
the caller hangs up during the rerecord prompt but before
Asterisk starts recording a message, then an "empty"
voicemail gets processed whereby an email gets sent out
notifying the user of a 0:00 duration message. The file
doesn't actually exist, so playback will fail since there
was no message to begin with.

This adds a check after the streaming of the rerecord
announcement to see if the caller has hung up. If so,
we bail out early so that we can clean up properly.

ASTERISK-29391 #close

Change-Id: Id965d72759a2fd3b39afb76fec08aaebebe75c31
2021-11-08 11:28:56 -06:00
Sean Bright 26fc5f3c72 app_voicemail.c: Ability to silence instructions if greeting is present.
There is an option to silence voicemail instructions but it does not
take into consideration if a recorded greeting exists or not. Add a
new 'S' option that does that.

ASTERISK-29632 #close

Change-Id: I03f2f043a9beb9d99deab302247e2a8686066fb4
2021-09-08 19:18:11 -05:00
Naveen Albert 567ea5abf8 app_voicemail: Configurable voicemail beep
Hitherto, VoiceMail() played a non-customizable beep tone to indicate
the caller could leave a message. In some cases, the beep may not
be desired, or a different tone may be desired.

To increase flexibility, a new option allows customization of the tone.
If the t option is specified, the default beep will be overridden.
Supplying an argument will cause it to use the specified file for the tone,
and omitting it will cause it to skip the beep altogether. If the option
is not used, the default behavior persists.

ASTERISK-29349

Change-Id: I1c439c0011497e28a28067fc1cf1e654c8843280
2021-05-19 08:03:30 -05:00
Sean Bright 44d68bd56b app_voicemail: Prevent deadlocks when out of ODBC database connections
ASTERISK-28992 #close

Change-Id: Ia7d608924036139ee2520b840d077762d02668d0
2021-01-06 10:50:30 -06:00
Joshua C. Colp eda3679c1c voicemail: add option 'e' to play greetings as early media
When using this option, answering the channel is deferred until
all prompts/greetings have been played and the caller is about
to leave their message.

ASTERISK-29118 #close

Change-Id: I41b9f0428783c0bd697c8c994f906d1e75ce9ddb
2020-12-01 11:22:49 -06:00
Alexander Traud 57ee79a563 Compiler fixes for GCC with -Og
ASTERISK-29144

Change-Id: I2a72c072083b4492a223c6f9d73d21f4f424db62
2020-11-03 17:08:07 -06:00
Sean Bright 4b5ed817bd app_voicemail.c: Document VMSayName interruption behavior
ASTERISK-26424 #close

Change-Id: I797ad0ed302d0b3d2c90543eff5b7207ed08ecf0
2020-10-02 08:02:54 -05:00
Sean Bright c925ed0eb9 app_voicemail: Process urgent messages with mailcmd
Rather than putting messages into INBOX and then moving them to Urgent
later, put them directly in to the Urgent folder. This prevents
mailcmd from being skipped.

ASTERISK-27273 #close

Change-Id: I49934e093290d308506ab8d45a40ef705c5ae4f5
2020-08-25 18:16:53 -05:00
Kevin Harwell 3d1bf3c537 Compiler fixes for gcc 10
This patch fixes a few compile warnings/errors that now occur when using gcc
10+.

Also, the Makefile.rules check to turn off partial inlining in gcc versions
greater or equal to 8.2.1 had a bug where it only it only checked against
versions with at least 3 numbers (ex: 8.2.1 vs 10). This patch now ensures
any version above the specified version is correctly compared.

Change-Id: I54718496eb0c3ce5bd6d427cd279a29e8d2825f9
2020-06-10 09:33:28 -05:00
George Joseph 7baf2c4bf1 app_voicemail: Add workaround for a gcc 10 issue with -Wrestrict
The gcc 10 -Wrestrict option was causing "overlap" errors when
snprintf was copying one char[256] structure member to another
char[256] member in the same structure.

Using ast_alloca instead of declaring the structure inline
solves the issue.

Here's a link to the "enhancement":
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-10/msg00570.html

We may follow up with a gcc bug report.

Change-Id: Ie0099adcb0a9727bd9aa99e024dd912a67eaf534
2020-04-30 11:10:23 -05:00
Friendly Automation 95c6fbeae0 Merge "app_voicemail: Remove MessageExists and MESSAGE_EXISTS()" 2020-01-22 15:46:35 -06:00
Joshua Colp 64debbd13f Merge "app_voicemail, say: Fix various leading whitespace problems" 2020-01-20 10:07:13 -06:00
Joshua Colp 058e9f735e Merge "app_voicemail: Prevent crash when saving message with realtime voicemail" 2020-01-20 09:31:42 -06:00
Sean Bright f09cf4da44 app_voicemail: Remove MessageExists and MESSAGE_EXISTS()
* The MailboxExists dialplan application was deprecated on 2006-09-26
  in Asterisk 1.6.0 (commit ec83b11183)

* The MAILBOX_EXISTS dialplan function was deprecated on 2011-12-06 in
  Asterisk 11.0.0 (commit fd64bb66f9)

Change-Id: I71cfc9d7b9217a37b802f4cc6ef2d57900b7398f
2020-01-16 16:39:04 -05:00
Sean Bright 5cbf47714a app_voicemail, say: Fix various leading whitespace problems
In af90afd90c, Japanese language support
was added to app_voicemail and main/say.c, but the leading whitespace
is not consistent with Asterisk coding guidelines. This patch fixes
that.

Whitespace only, no functional change.

ASTERISK~23324
Reported by: Kevin McCoy

Change-Id: I72c725f5930084673749bd7c9cc426a987f08e87
2020-01-16 13:55:32 -06:00
Sean Bright ba8ccb9132 app_voicemail: Prevent crash when saving message with realtime voicemail
ast_store_realtime() is not NULL tolerant, so we need to initialize
the field values we pass to it to the empty string to avoid a crash.

ASTERISK-23739 #close
Reported by: Stas Kobzar

Change-Id: I756c5dd0299c77f4274368f7c99eb0464367466c
2020-01-15 15:52:25 -06:00
Sean Bright 9be89d9913 app_voicemail: Set globals to default values when voicemail.conf missing
If voicemail.conf exists but is empty, the config parsing process will
default a number of global variables to non-zero values. On the other
hand, if voicemail.conf is missing (arguably semantically equivalent
to an empty file), this process is skipped and the globals are
defaulted to 0.

Set the globals to the same values they would be set to if a
configuration were present. This allows voicemail configuration to be
done completely by Realtime without the need to create an empty
voicemail.conf file.

ASTERISK-27622 #close
Reported by: Jim Van Meggelen

Change-Id: Id907d280f310f12e542ca527e6a025432b9fb409
2020-01-14 16:31:49 -06:00
Kevin Harwell bdd785d31c various files - fix some alerts raised by lgtm code analysis
This patch fixes several issues reported by the lgtm code analysis tool:

https://lgtm.com/projects/g/asterisk/asterisk

Not all reported issues were addressed in this patch. This patch mostly fixes
confirmed reported errors, potential problematic code points, and a few other
"low hanging" warnings or recommendations found in core supported modules.
These include, but are not limited to the following:

* innapropriate stack allocation in loops
* buffer overflows
* variable declaration "hiding" another variable declaration
* comparisons results that are always the same
* ambiguously signed bit-field members
* missing header guards

Change-Id: Id4a881686605d26c94ab5409bc70fcc21efacc25
2019-11-18 08:30:45 -06:00
cmaj 2d67dbfef5 app_voicemail.c: Support multiple file formats for forwarded messages.
If you specify multiple formats in voicemail.conf, eg. "format = gsm|wav"
and are using realtime ODBC backend, only the first format gets stored
in the database. So when you forward a message later on, there is a bug
generating the email, related to the stored format (GSM) being different
than the desired email format (WAV) specified for the user. Sox can
handle this, but Asterisk needs to tell sox exactly what to do.

ASTERISK-22192

Change-Id: I7321e7f7e7c58adbf41dd4fd7191c887b9b2eafd
2019-10-14 17:20:01 -05:00
Sean Bright 7362647e2f Revert "app_voicemail: Cleanup stale lock files on module load"
This reverts commit fd2e8d0da7.

Reason for revert: Problematic for users who store their voicemail
on network storage devices, or share voicemail storage between
multiple Asterisk instances.

ASTERISK-28567 #close

Change-Id: I3ff4ca983d8e753fe2971f3439bd154705693c41
2019-10-08 06:35:05 -05:00
Corey Farrell 863fe2225f app_voicemail: Fix module unload leak.
Change-Id: Ib9a06565b9a178822d3bbb67eccf51432e12d84a
2019-09-19 11:16:14 -05:00
Alexei Gradinari 15624d9a7a app_voicemail/IMAP: check mailstream not NULL in leave_voicemail
The function leave_voicemail checks if expungeonhangup is set,
but does not check if IMAP stream is closed,
so it could call imap function with NULL stream.
This leads to segfault.

ASTERISK-28505 #close

Change-Id: Ib66c57c1f1ba97774e447b36349198e2626a8d7c
2019-08-15 09:47:24 -05:00
Sean Bright 9d07d5a6d6 app_voicemail: Remove extra menuselect build options
You now select voicemail backends like normal dialplan applications, so
there is no longer a need for their own menuselect category.

Reported by snuff-work in #asterisk-dev

Change-Id: Idfa4c9c8349726074318a9e6b68d24c374521005
2019-08-06 07:22:27 -06:00
Kevin Harwell c93c579190 app_voicemail: Remove dependency on the stasis cache
app_voicemail utilized the stasis cache when polling mailboxes for MWI. This
caused a memory leak (items were not being appropriately removed from the
cache), and subsequent slowdown in system processing. This patch removes the
stasis cache dependency, thus alleviating the memory leak. It does this by
utilizing the new MWI API that better manages state lifetime.

ASTERISK-28443
ASTERISK-27121

Change-Id: Ie89fedaca81ea1fd03d150d9d3a1ef3d53740e46
2019-07-09 09:36:26 -05:00
Kevin Harwell ff0d0ac23a mwi core: Move core MWI functionality into its own files
There is enough MWI functionality to warrant it having its own 'c' and header
files. This patch moves all current core MWI data structures, and functions
into the following files:

main/mwi.h
main/mwi.c

Note, code was simply moved, and not modified. However, this patch is also in
preparation for core MWI changes, and additions to come.

Change-Id: I9dde8bfae1e7ec254fa63166e090f77e4d3097e0
2019-04-23 17:40:15 -05:00
Sean Bright d58d7d4500 app_voicemail: Don't split mailbox options on comma
Because the per-mailbox options are the last thing on a line, don't look
for or stomp on any subsequent commas.

ASTERISK-27935 #close
Reported by: Sébastien Duthil

Change-Id: I07b2eb4a33c303d0c7114d5b906f8c067c60a153
2019-04-13 12:39:39 -06:00