Re-merge changes that were reverted.

------------------------------------------------------------------------
r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines

Add support for folders in MixMonitor 'm' option.  Backport manager actions.

The manager actions are needed, so MixMonitor can be executed on existing
channels.

(issue DPMA-68)

------------------------------------------------------------------------
r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines

Remove folder_dir from voicemail snapshots API.

It was both unused (except in tests, where it was fudged) and unnecessary.

(closes issue AST-842)

------------------------------------------------------------------------
r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines

Add "send to voicemail" Digium phone functionality to Asterisk.

This change accommodates two methods by which calls can be directed to
a user's voicemail.

* Incoming calls can be redirected to any user's voicemail.
* Established calls can be blind transferred to any user's voicemail.

Digium phones indicate the desire to direct a call to voicemail by using
a Diversion header with a reason parameter of "send_to_vm".

This patch adds the "send_to_vm" reason as a valid redirecting reason. In
addition, chan_sip.c has been modified to update redirecting information
on the transferred channel by reading a Diversion header on a REFER request.

(closes issue AST-871)
Reported by Malcolm Davenport

Review: https://reviewboard.asterisk.org/r/1925

------------------------------------------------------------------------
r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines

Fix deadlock in SIP transfers that involve a REFER request

In r367163, "send to voicemail" functionality was added to the SIP channel
driver.  This required updating the party redirecting information for the
channel based on the headers provided in the REFER request.  When the
redirecting party information is updated on the channel, a call to
ast_indicate_data occurs.  Because handle_request_refer still had the sip_pvt
locked, a deadlock could occur between the pbx_thread and the do_monitor thread
servicing the REFER request.

This patch preserves the proper locking order between the channel and the
sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party
redirecting information on the channel.

(closes issue AST-903)
Reported by: Matt Jordan
patches:
  jira_ast_903_trunk.patch by rmudgett (license 5621)

------------------------------------------------------------------------
r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines

Remove global symbol requirement from app_voicemail.

This uses the existing "function installation" stuff that already existed for
other functions, like getting message counts.

(closes issue AST-807)
(issue AST-901)
(issue AST-908)

Review: https://reviewboard.asterisk.org/r/1965/

------------------------------------------------------------------------
r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines

These functions that were moved need to be static.

Also wrap test functions in a #ifdef.

(issue AST-807)
(issue AST-901)
(issue AST-908)

------------------------------------------------------------------------
r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines

Remove some symbol exports that got missed in the removal of global symbols.

(issue AST-807)
(issue AST-901)
(issue AST-908)

------------------------------------------------------------------------
r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines

Fix voicemail API tests by using the correct argument order for create/destroy.

------------------------------------------------------------------------


git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jason Parker
2012-07-09 19:05:54 +00:00
parent ac20e0c611
commit 05d05e68f5
10 changed files with 665 additions and 335 deletions

View File

@@ -43,7 +43,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/paths.h"
#include "asterisk/channel.h"
#include "asterisk/app.h"
#include "asterisk/app_voicemail.h"
/*! \internal \brief Permissions to set on the voicemail directories we create
* - taken from app_voicemail */
@@ -128,8 +127,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
VM_API_STRING_FIELD_VERIFY((expected)->origtime, msg->origtime); \
VM_API_STRING_FIELD_VERIFY((expected)->duration, msg->duration); \
VM_API_STRING_FIELD_VERIFY((expected)->folder_name, msg->folder_name); \
/* We are currently not going to check folder_dir, since its never written out. */ \
/* VM_API_STRING_FIELD_VERIFY((expected)->folder_dir, msg->folder_dir); \ */ \
VM_API_STRING_FIELD_VERIFY((expected)->flag, msg->flag); \
VM_API_INT_VERIFY((expected)->msg_number, msg->msg_number); \
break; \
@@ -318,13 +315,13 @@ static struct ast_vm_msg_snapshot *test_vm_api_create_mock_snapshot(const char *
* \returns 0 on success
* \returns 1 on failure
*/
static int test_vm_api_create_voicemail_folder(struct ast_vm_msg_snapshot *snapshot)
static int test_vm_api_create_voicemail_folder(const char *folder_path)
{
mode_t mode = VOICEMAIL_DIR_MODE;
int res;
if ((res = ast_mkdir(snapshot->folder_dir, mode))) {
ast_log(AST_LOG_ERROR, "ast_mkdir '%s' failed: %s\n", snapshot->folder_dir, strerror(res));
if ((res = ast_mkdir(folder_path, mode))) {
ast_log(AST_LOG_ERROR, "ast_mkdir '%s' failed: %s\n", folder_path, strerror(res));
return 1;
}
return 0;
@@ -353,24 +350,23 @@ static int test_vm_api_create_voicemail_files(const char *context, const char *m
*/
snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
ast_config_AST_SPOOL_DIR, context, mailbox, snapshot->folder_name);
ast_string_field_set(snapshot, folder_dir, folder_path);
snprintf(msg_path, sizeof(msg_path), "%s/msg%04d.txt",
snapshot->folder_dir, snapshot->msg_number);
folder_path, snapshot->msg_number);
snprintf(snd_path, sizeof(snd_path), "%s/msg%04d.gsm",
snapshot->folder_dir, snapshot->msg_number);
folder_path, snapshot->msg_number);
snprintf(beep_path, sizeof(beep_path), "%s/sounds/en/beep.gsm", ast_config_AST_VAR_DIR);
if (test_vm_api_create_voicemail_folder(snapshot)) {
if (test_vm_api_create_voicemail_folder(folder_path)) {
return 1;
}
if (ast_lock_path(snapshot->folder_dir) == AST_LOCK_FAILURE) {
ast_log(AST_LOG_ERROR, "Unable to lock directory %s\n", snapshot->folder_dir);
if (ast_lock_path(folder_path) == AST_LOCK_FAILURE) {
ast_log(AST_LOG_ERROR, "Unable to lock directory %s\n", folder_path);
return 1;
}
if (symlink(beep_path, snd_path)) {
ast_unlock_path(snapshot->folder_dir);
ast_unlock_path(folder_path);
ast_log(AST_LOG_ERROR, "Failed to create a symbolic link from %s to %s: %s\n",
beep_path, snd_path, strerror(errno));
return 1;
@@ -379,7 +375,7 @@ static int test_vm_api_create_voicemail_files(const char *context, const char *m
if (!(msg_file = fopen(msg_path, "w"))) {
/* Attempt to remove the sound file */
unlink(snd_path);
ast_unlock_path(snapshot->folder_dir);
ast_unlock_path(folder_path);
ast_log(AST_LOG_ERROR, "Failed to open %s for writing\n", msg_path);
return 1;
}
@@ -417,11 +413,11 @@ static int test_vm_api_create_voicemail_files(const char *context, const char *m
fclose(msg_file);
if (chmod(msg_path, VOICEMAIL_FILE_MODE) < 0) {
ast_unlock_path(snapshot->folder_dir);
ast_unlock_path(folder_path);
ast_log(AST_LOG_ERROR, "Couldn't set permissions on voicemail text file %s: %s", msg_path, strerror(errno));
return 1;
}
ast_unlock_path(snapshot->folder_dir);
ast_unlock_path(folder_path);
return 0;
}
@@ -439,16 +435,13 @@ static void test_vm_api_remove_voicemail(struct ast_vm_msg_snapshot *snapshot)
return;
}
if (ast_strlen_zero(snapshot->folder_dir)) {
snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
ast_config_AST_SPOOL_DIR, "default", snapshot->exten, snapshot->folder_name);
ast_string_field_set(snapshot, folder_dir, folder_path);
}
snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
ast_config_AST_SPOOL_DIR, "default", snapshot->exten, snapshot->folder_name);
snprintf(msg_path, sizeof(msg_path), "%s/msg%04d.txt",
snapshot->folder_dir, snapshot->msg_number);
folder_path, snapshot->msg_number);
snprintf(snd_path, sizeof(snd_path), "%s/msg%04d.gsm",
snapshot->folder_dir, snapshot->msg_number);
folder_path, snapshot->msg_number);
unlink(msg_path);
unlink(snd_path);
@@ -625,7 +618,6 @@ static void test_vm_api_test_teardown(void)
static void test_vm_api_update_test_snapshots(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
{
int i, j;
char folder_path[PATH_MAX];
struct ast_vm_msg_snapshot *msg;
for (i = 0; i < TOTAL_SNAPSHOTS; ++i) {
@@ -639,13 +631,6 @@ static void test_vm_api_update_test_snapshots(struct ast_vm_mailbox_snapshot *ma
ast_string_field_set(test_snapshots[i], origtime, msg->origtime);
ast_string_field_set(test_snapshots[i], duration, msg->duration);
ast_string_field_set(test_snapshots[i], folder_name, msg->folder_name);
/* TODO: because the folder_dir isn't updated in a snapshot, this will
* always be NULL. We need to recreate the folder path here
ast_string_field_set(test_snapshots[i], folder_dir, msg->folder_dir);
*/
snprintf(folder_path, sizeof(folder_path), "%s/voicemail/%s/%s/%s",
ast_config_AST_SPOOL_DIR, "default", test_snapshots[i]->exten, test_snapshots[i]->folder_name);
ast_string_field_set(test_snapshots[i], folder_dir, folder_path);
ast_string_field_set(test_snapshots[i], flag, msg->flag);
test_snapshots[i]->msg_number = msg->msg_number;
}