From e6efa85868de061645a11a05f25b942c5d7ceba2 Mon Sep 17 00:00:00 2001
From: Andreas Granig <agranig@sipwise.com>
Date: Fri, 3 Oct 2014 14:37:12 +0200
Subject: [PATCH] MT#9403 play prompt on change to empty folder

---
 apps/app_voicemail.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 36be7a9..499cb06 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -7571,6 +7571,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
 	signed char record_gain = 0;
 	int play_auto = 0;
 	int play_folder = 0;
+    int folder_change = 0;
 #ifdef IMAP_STORAGE
 	int deleted = 0;
 #endif
@@ -7797,6 +7798,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
 			cmd = vm_browse_messages(chan, &vms, vmu);
 			break;
 		case '2': /* Change folders */
+            folder_change = 1;
 			if (useadsi)
 				adsi_folders(chan, 0, "Change to folder...");
 			cmd = get_folder2(chan, "vm-changeto", 0);
@@ -8076,6 +8078,16 @@ static int vm_execmain(struct ast_channel *chan, void *data)
 				adsi_status(chan, &vms);
 			break;
 		default:	/* Nothing */
+            if (folder_change && !vms.oldmessages && !vms.newmessages) {
+                if(!strcasecmp(chan->language, "ro")) {
+                    ast_play_and_wait(chan, "vm-dir-empty");
+                } else {
+                    res = ast_play_and_wait(chan, "vm-no");
+                    if (!res)
+                        res = ast_play_and_wait(chan, "vm-messages");
+                }
+            }
+            folder_change = 0;
 			cmd = vm_instructions(chan, &vms, 0);
 			break;
 		}