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);
}
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");
}
}
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; \
* \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;
*/
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;
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;
}
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;
}
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);
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) {
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;
}