[asterisk-commits] qwell: branch certified-1.8.11 r364761 - in /certified/branches/1.8.11: apps/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 1 12:25:19 CDT 2012


Author: qwell
Date: Tue May  1 12:25:14 2012
New Revision: 364761

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=364761
Log:
Remove folder_dir from voicemail snapshots API.

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

(closes issue AST-842)

Modified:
    certified/branches/1.8.11/apps/app_voicemail.c
    certified/branches/1.8.11/include/asterisk/app_voicemail.h
    certified/branches/1.8.11/tests/test_voicemail_api.c

Modified: certified/branches/1.8.11/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/1.8.11/apps/app_voicemail.c?view=diff&rev=364761&r1=364760&r2=364761
==============================================================================
--- certified/branches/1.8.11/apps/app_voicemail.c (original)
+++ certified/branches/1.8.11/apps/app_voicemail.c Tue May  1 12:25:14 2012
@@ -14227,9 +14227,6 @@
 		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 @@
 			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");
 		}
 	}

Modified: certified/branches/1.8.11/include/asterisk/app_voicemail.h
URL: http://svnview.digium.com/svn/asterisk/certified/branches/1.8.11/include/asterisk/app_voicemail.h?view=diff&rev=364761&r1=364760&r2=364761
==============================================================================
--- certified/branches/1.8.11/include/asterisk/app_voicemail.h (original)
+++ certified/branches/1.8.11/include/asterisk/app_voicemail.h Tue May  1 12:25:14 2012
@@ -44,7 +44,6 @@
 		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;

Modified: certified/branches/1.8.11/tests/test_voicemail_api.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/1.8.11/tests/test_voicemail_api.c?view=diff&rev=364761&r1=364760&r2=364761
==============================================================================
--- certified/branches/1.8.11/tests/test_voicemail_api.c (original)
+++ certified/branches/1.8.11/tests/test_voicemail_api.c Tue May  1 12:25:14 2012
@@ -128,8 +128,6 @@
 			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 @@
  * \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 @@
 	 */
 	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 @@
 	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 @@
 	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 @@
 		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_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 @@
 					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;
 				}




More information about the asterisk-commits mailing list