From 2d697115a47b9ada343eab0e95b3d66181fc48b4 Mon Sep 17 00:00:00 2001 From: Jason Parker Date: Tue, 1 May 2012 17:25:14 +0000 Subject: [PATCH] Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@364761 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_voicemail.c | 6 +---- include/asterisk/app_voicemail.h | 1 - tests/test_voicemail_api.c | 46 +++++++++++--------------------- 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 20185fdc9f..32c857fa20 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -14227,9 +14227,6 @@ static int vm_msg_snapshot_create(struct ast_vm_user *vmu, if ((value = ast_variable_retrieve(msg_cfg, "message", "duration"))) { ast_string_field_set(msg_snapshot, duration, value); } - if ((value = ast_variable_retrieve(msg_cfg, "message", "folder_dir"))) { - ast_string_field_set(msg_snapshot, folder_dir, value); - } if ((value = ast_variable_retrieve(msg_cfg, "message", "flag"))) { ast_string_field_set(msg_snapshot, flag, value); } @@ -14421,8 +14418,7 @@ struct ast_str *vm_mailbox_snapshot_str(const char *mailbox, const char *context ast_str_append(&str, 0, "TIME: %s\n", msg_snapshot->origtime); ast_str_append(&str, 0, "DURATION: %s\n", msg_snapshot->duration); ast_str_append(&str, 0, "FOLDER NAME: %s\n", msg_snapshot->folder_name); - ast_str_append(&str, 0, "FOLDER DIR: %s\n", msg_snapshot->folder_dir); - ast_str_append(&str, 0, "FLAG: %s\n", msg_snapshot->folder_dir); + ast_str_append(&str, 0, "FLAG: %s\n", msg_snapshot->flag); ast_str_append(&str, 0, "\n"); } } diff --git a/include/asterisk/app_voicemail.h b/include/asterisk/app_voicemail.h index 11b1df4307..7f8dd5e4fd 100644 --- a/include/asterisk/app_voicemail.h +++ b/include/asterisk/app_voicemail.h @@ -44,7 +44,6 @@ struct ast_vm_msg_snapshot { AST_STRING_FIELD(origtime); AST_STRING_FIELD(duration); AST_STRING_FIELD(folder_name); - AST_STRING_FIELD(folder_dir); AST_STRING_FIELD(flag); ); unsigned int msg_number; diff --git a/tests/test_voicemail_api.c b/tests/test_voicemail_api.c index a0311143bf..7b6643bc32 100644 --- a/tests/test_voicemail_api.c +++ b/tests/test_voicemail_api.c @@ -128,8 +128,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 +316,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 +351,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 +376,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 +414,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 +436,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 +619,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 +632,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; } -- 2.47.2