Index: sems/apps/sw_vsc/SW_Vsc.cpp
===================================================================
--- sems.orig/apps/sw_vsc/SW_Vsc.cpp	2016-07-21 12:55:32.091065992 +0200
+++ sems/apps/sw_vsc/SW_Vsc.cpp	2016-07-21 13:22:56.987148286 +0200
@@ -154,114 +154,102 @@
     if (m_patterns.audioPath[m_patterns.audioPath.length() - 1] != '/' )
         m_patterns.audioPath += "/";
 
+    // MT#20649: don't fail if announcements are missing;
     m_patterns.failAnnouncement = cfg.getParameter("error_announcement", "");
     if (m_patterns.failAnnouncement.empty())
     {
-        ERROR("ErrorAnnouncement file not set\n");
-        return -1;
+        ERROR("error_announcement file not set\n");
     }
     m_patterns.unknownAnnouncement = cfg.getParameter("unknown_announcement", "");
     if (m_patterns.unknownAnnouncement.empty())
     {
-        ERROR("UnknownAnnouncement file not set\n");
-        return -1;
+        ERROR("unknown_announcement file not set\n");
     }
     m_patterns.cfuOnAnnouncement = cfg.getParameter("cfu_on_announcement", "");
     if (m_patterns.cfuOnAnnouncement.empty())
     {
-        ERROR("CfuOnAnnouncement file not set\n");
-        return -1;
+        ERROR("cfu_on_announcement file not set\n");
     }
     m_patterns.cfuOffAnnouncement = cfg.getParameter("cfu_off_announcement", "");
     if (m_patterns.cfuOffAnnouncement.empty())
     {
-        ERROR("CfuOffAnnouncement file not set\n");
-        return -1;
+        ERROR("cfu_off_announcement file not set\n");
     }
     m_patterns.cfbOnAnnouncement = cfg.getParameter("cfb_on_announcement", "");
     if (m_patterns.cfbOnAnnouncement.empty())
     {
-        ERROR("CfbOnAnnouncement file not set\n");
-        return -1;
+        ERROR("cfb_on_announcement file not set\n");
     }
     m_patterns.cfbOffAnnouncement = cfg.getParameter("cfb_off_announcement", "");
     if (m_patterns.cfbOffAnnouncement.empty())
     {
-        ERROR("CfbOffAnnouncement file not set\n");
-        return -1;
+        ERROR("cfb_off_announcement file not set\n");
     }
     m_patterns.cftOnAnnouncement = cfg.getParameter("cft_on_announcement", "");
     if (m_patterns.cftOnAnnouncement.empty())
     {
-        ERROR("CftOnAnnouncement file not set\n");
-        return -1;
+        ERROR("cft_on_announcement file not set\n");
     }
     m_patterns.cftOffAnnouncement = cfg.getParameter("cft_off_announcement", "");
     if (m_patterns.cftOffAnnouncement.empty())
     {
-        ERROR("CftOffAnnouncement file not set\n");
-        return -1;
+        ERROR("cft_off_announcement file not set\n");
     }
     m_patterns.cfnaOnAnnouncement = cfg.getParameter("cfna_on_announcement", "");
     if (m_patterns.cfnaOnAnnouncement.empty())
     {
-        ERROR("CfnaOnAnnouncement file not set\n");
-        return -1;
+        ERROR("cfna_on_announcement file not set\n");
     }
     m_patterns.cfnaOffAnnouncement = cfg.getParameter("cfna_off_announcement", "");
     if (m_patterns.cfnaOffAnnouncement.empty())
     {
-        ERROR("CfnaOffAnnouncement file not set\n");
-        return -1;
+        ERROR("cfna_off_announcement file not set\n");
     }
     m_patterns.speedDialAnnouncement = cfg.getParameter("speed_dial_announcement", "");
     if (m_patterns.speedDialAnnouncement.empty())
     {
-        ERROR("SpeedDialAnnouncement file not set\n");
-        return -1;
+        ERROR("speed_dial_announcement file not set\n");
     }
     m_patterns.reminderOnAnnouncement = cfg.getParameter("reminder_on_announcement", "");
     if (m_patterns.reminderOnAnnouncement.empty())
     {
-        ERROR("ReminderOnAnnouncement file not set\n");
-        return -1;
+        ERROR("reminder_on_announcement file not set\n");
     }
     m_patterns.reminderOffAnnouncement = cfg.getParameter("reminder_off_announcement", "");
     if (m_patterns.reminderOffAnnouncement.empty())
     {
-        ERROR("ReminderOffAnnouncement file not set\n");
-        return -1;
+        ERROR("reminder_off_announcement file not set\n");
     }
     m_patterns.blockinclirOnAnnouncement = cfg.getParameter("blockinclir_on_announcement", "");
     if (m_patterns.blockinclirOnAnnouncement.empty())
     {
-        ERROR("BlockinclirOnAnnouncement file not set\n");
-        return -1;
+        ERROR("blockinclir_on_announcement file not set\n");
     }
     m_patterns.blockinclirOffAnnouncement = cfg.getParameter("blockinclir_off_announcement", "");
     if (m_patterns.blockinclirOffAnnouncement.empty())
     {
-        ERROR("BlockinclirOffAnnouncement file not set\n");
-        return -1;
+        ERROR("blockinclir_off_announcement file not set\n");
     }
 
+    // We could set a default in cfg.getParameter, but we really want to log the error
+    // if the pattern in question is not set:
 
     m_patterns.voicemailNumber = cfg.getParameter("voicemail_number", "");
     if (m_patterns.voicemailNumber.empty())
     {
-        ERROR("voicemailNumber is empty\n");
-        return -1;
+        ERROR("voicemail_number not set\n");
+        m_patterns.voicemailNumber = "invalid_default_value";
     }
 
     cfuOnPattern = cfg.getParameter("cfu_on_pattern", "");
     if (cfuOnPattern.empty())
     {
-        ERROR("CfuOnPattern is empty\n");
-        return -1;
+        ERROR("cfu_on_pattern is empty\n");
+        cfuOnPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cfuOnPattern, cfuOnPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CfuOnPattern failed to compile ('%s'): %s\n",
+        ERROR("cfu_on_pattern failed to compile ('%s'): %s\n",
               cfuOnPattern.c_str(),
               strerror(errno));
         return -1;
@@ -270,12 +258,12 @@
     cfuOffPattern = cfg.getParameter("cfu_off_pattern", "");
     if (cfuOffPattern.empty())
     {
-        ERROR("CfuOffPattern is empty\n");
-        return -1;
+        ERROR("cfu_off_pattern is empty\n");
+        cfuOffPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cfuOffPattern, cfuOffPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CfuOffPattern failed to compile ('%s'): %s\n",
+        ERROR("cfu_off_pattern failed to compile ('%s'): %s\n",
               cfuOffPattern.c_str(),
               strerror(errno));
         return -1;
@@ -284,12 +272,12 @@
     cfbOnPattern = cfg.getParameter("cfb_on_pattern", "");
     if (cfbOnPattern.empty())
     {
-        ERROR("CfbOnPattern is empty\n");
-        return -1;
+        ERROR("cfb_on_pattern is empty\n");
+        cfbOnPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cfbOnPattern, cfbOnPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CfbOnPattern failed to compile ('%s'): %s\n",
+        ERROR("cfb_on_pattern failed to compile ('%s'): %s\n",
               cfbOnPattern.c_str(),
               strerror(errno));
         return -1;
@@ -298,27 +286,26 @@
     cfbOffPattern = cfg.getParameter("cfb_off_pattern", "");
     if (cfbOffPattern.empty())
     {
-        ERROR("CfbOffPattern is empty\n");
-        return -1;
+        ERROR("cfb_off_pattern is empty\n");
+        cfbOffPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cfbOffPattern, cfbOffPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CfbOffPattern failed to compile ('%s'): %s\n",
+        ERROR("cfb_off_pattern failed to compile ('%s'): %s\n",
               cfbOffPattern.c_str(),
               strerror(errno));
         return -1;
     }
 
-
     cftOnPattern = cfg.getParameter("cft_on_pattern", "");
     if (cftOnPattern.empty())
     {
-        ERROR("CftOnPattern is empty\n");
-        return -1;
+        ERROR("cft_on_pattern is empty\n");
+        cftOnPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cftOnPattern, cftOnPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CftOnPattern failed to compile ('%s'): %s\n",
+        ERROR("cft_on_pattern failed to compile ('%s'): %s\n",
               cftOnPattern.c_str(),
               strerror(errno));
         return -1;
@@ -327,12 +314,12 @@
     cftOffPattern = cfg.getParameter("cft_off_pattern", "");
     if (cftOffPattern.empty())
     {
-        ERROR("CftOffPattern is empty\n");
-        return -1;
+        ERROR("cft_off_pattern is empty\n");
+        cftOffPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cftOffPattern, cftOffPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CftOffPattern failed to compile ('%s'): %s\n",
+        ERROR("cft_off_pattern failed to compile ('%s'): %s\n",
               cftOffPattern.c_str(),
               strerror(errno));
         return -1;
@@ -341,12 +328,12 @@
     cfnaOnPattern = cfg.getParameter("cfna_on_pattern", "");
     if (cfnaOnPattern.empty())
     {
-        ERROR("CfnaOnPattern is empty\n");
-        return -1;
+        ERROR("cfna_on_pattern is empty\n");
+        cfnaOnPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cfnaOnPattern, cfnaOnPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CfnaOnPattern failed to compile ('%s'): %s\n",
+        ERROR("cfna_on_pattern failed to compile ('%s'): %s\n",
               cfnaOnPattern.c_str(),
               strerror(errno));
         return -1;
@@ -355,12 +342,12 @@
     cfnaOffPattern = cfg.getParameter("cfna_off_pattern", "");
     if (cfnaOffPattern.empty())
     {
-        ERROR("CfnaOffPattern is empty\n");
-        return -1;
+        ERROR("cfna_off_pattern is empty\n");
+        cfnaOffPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.cfnaOffPattern, cfnaOffPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("CfnaOffPattern failed to compile ('%s'): %s\n",
+        ERROR("cfna_off_pattern failed to compile ('%s'): %s\n",
               cfnaOffPattern.c_str(),
               strerror(errno));
         return -1;
@@ -369,43 +356,41 @@
     speedDialPattern = cfg.getParameter("speed_dial_pattern", "");
     if (speedDialPattern.empty())
     {
-        ERROR("SpeedDialPattern is empty\n");
-        return -1;
+        ERROR("speed_dial_pattern is empty\n");
+        speedDialPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.speedDialPattern, speedDialPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("SpeedDialPattern failed to compile ('%s'): %s\n",
+        ERROR("speed_dial_pattern failed to compile ('%s'): %s\n",
               speedDialPattern.c_str(),
               strerror(errno));
         return -1;
     }
 
-
     reminderOnPattern = cfg.getParameter("reminder_on_pattern", "");
     if (reminderOnPattern.empty())
     {
-        ERROR("ReminderOnPattern is empty\n");
-        return -1;
+        ERROR("reminder_on_pattern is empty\n");
+        reminderOnPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.reminderOnPattern, reminderOnPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("ReminderOnPattern failed to compile ('%s'): %s\n",
+        ERROR("reminder_on_pattern failed to compile ('%s'): %s\n",
               reminderOnPattern.c_str(),
               strerror(errno));
         return -1;
     }
 
-
     reminderOffPattern = cfg.getParameter("reminder_off_pattern", "");
     if (reminderOffPattern.empty())
     {
-        ERROR("ReminderOffPattern is empty\n");
-        return -1;
+        ERROR("reminder_off_pattern is empty\n");
+        reminderOffPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.reminderOffPattern, reminderOffPattern.c_str(),
                 REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("ReminderOffPattern failed to compile ('%s'): %s\n",
+        ERROR("reminder_off_pattern failed to compile ('%s'): %s\n",
               reminderOffPattern.c_str(),
               strerror(errno));
         return -1;
@@ -414,28 +399,27 @@
     blockinclirOnPattern = cfg.getParameter("blockinclir_on_pattern", "");
     if (blockinclirOnPattern.empty())
     {
-        ERROR("BlockinclirOnPattern is empty\n");
-        return -1;
+        ERROR("blockinclir_on_pattern is empty\n");
+        blockinclirOnPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.blockinclirOnPattern, blockinclirOnPattern.c_str(), REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("BlockinclirOnPattern failed to compile ('%s'): %s\n",
+        ERROR("blockinclir_on_pattern failed to compile ('%s'): %s\n",
               blockinclirOnPattern.c_str(),
               strerror(errno));
         return -1;
     }
 
-
     blockinclirOffPattern = cfg.getParameter("blockinclir_off_pattern", "");
     if (blockinclirOffPattern.empty())
     {
-        ERROR("BlockinclirOffPattern is empty\n");
-        return -1;
+        ERROR("blockinclir_off_pattern is empty\n");
+        blockinclirOffPattern = "invalid_default_value";
     }
     if (regcomp(&m_patterns.blockinclirOffPattern, blockinclirOffPattern.c_str(),
                 REG_EXTENDED | REG_NOSUB))
     {
-        ERROR("BlockinclirOffPattern failed to compile ('%s'): %s\n",
+        ERROR("blockinclir_off_pattern failed to compile ('%s'): %s\n",
               blockinclirOffPattern.c_str(),
               strerror(errno));
         return -1;
@@ -1123,124 +1107,21 @@
 
 
     failAnnouncement = m_patterns->audioPath + lang + m_patterns->failAnnouncement;
-    if (!file_exists(failAnnouncement))
+    if (m_patterns->failAnnouncement.empty() || !file_exists(failAnnouncement))
     {
         ERROR("ErrorAnnouncement file does not exist ('%s').\n",
               failAnnouncement.c_str());
         throw AmSession::Exception(500, "could not get failed announcement");
     }
     unknownAnnouncement = m_patterns->audioPath + lang + m_patterns->unknownAnnouncement;
-    if (!file_exists(unknownAnnouncement))
+    if (m_patterns->unknownAnnouncement.empty() || !file_exists(unknownAnnouncement))
     {
         ERROR("UnknownAnnouncement file does not exist ('%s').\n",
               unknownAnnouncement.c_str());
         filename = failAnnouncement;
         goto out;
     }
-    cfuOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cfuOnAnnouncement;
-    if (!file_exists(cfuOnAnnouncement))
-    {
-        ERROR("CfuOnAnnouncement file does not exist ('%s').\n",
-              cfuOnAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    cfuOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cfuOffAnnouncement;
-    if (!file_exists(cfuOffAnnouncement))
-    {
-        ERROR("CfuOffAnnouncement file does not exist ('%s').\n",
-              cfuOffAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    cfbOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cfbOnAnnouncement;
-    if (!file_exists(cfbOnAnnouncement))
-    {
-        ERROR("CfbOnAnnouncement file does not exist ('%s').\n",
-              cfbOnAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    cfbOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cfbOffAnnouncement;
-    if (!file_exists(cfbOffAnnouncement))
-    {
-        ERROR("CfbOffAnnouncement file does not exist ('%s').\n",
-              cfbOffAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    cftOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cftOnAnnouncement;
-    if (!file_exists(cftOnAnnouncement))
-    {
-        ERROR("CftOnAnnouncement file does not exist ('%s').\n",
-              cftOnAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    cftOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cftOffAnnouncement;
-    if (!file_exists(cftOffAnnouncement))
-    {
-        ERROR("CftOffAnnouncement file does not exist ('%s').\n",
-              cftOffAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    cfnaOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cfnaOnAnnouncement;
-    if (!file_exists(cfnaOnAnnouncement))
-    {
-        ERROR("CfnaOnAnnouncement file does not exist ('%s').\n",
-              cfnaOnAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    cfnaOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cfnaOffAnnouncement;
-    if (!file_exists(cfnaOffAnnouncement))
-    {
-        ERROR("CfnaOffAnnouncement file does not exist ('%s').\n",
-              cfnaOffAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    speedDialAnnouncement = m_patterns->audioPath + lang + m_patterns->speedDialAnnouncement;
-    if (!file_exists(speedDialAnnouncement))
-    {
-        ERROR("SpeedDialAnnouncement file does not exist ('%s').\n",
-              speedDialAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    reminderOnAnnouncement = m_patterns->audioPath + lang + m_patterns->reminderOnAnnouncement;
-    if (!file_exists(reminderOnAnnouncement))
-    {
-        ERROR("ReminderOnAnnouncement file does not exist ('%s').\n",
-              reminderOnAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    reminderOffAnnouncement = m_patterns->audioPath + lang + m_patterns->reminderOffAnnouncement;
-    if (!file_exists(reminderOffAnnouncement))
-    {
-        ERROR("ReminderOffAnnouncement file does not exist ('%s').\n",
-              reminderOffAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    blockinclirOnAnnouncement = m_patterns->audioPath + lang + m_patterns->blockinclirOnAnnouncement;
-    if (!file_exists(blockinclirOnAnnouncement))
-    {
-        ERROR("BlockinclirOnAnnouncement file does not exist ('%s').\n",
-              blockinclirOnAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
-    blockinclirOffAnnouncement = m_patterns->audioPath + lang + m_patterns->blockinclirOffAnnouncement;
-    if (!file_exists(blockinclirOffAnnouncement))
-    {
-        ERROR("BlockinclirOffAnnouncement file does not exist ('%s').\n",
-              blockinclirOffAnnouncement.c_str());
-        filename = failAnnouncement;
-        goto out;
-    }
+
 
     my_handler = mysql_init(NULL);
     if (!mysql_real_connect(my_handler,
@@ -1278,6 +1159,15 @@
     if ((ret = regexec(&m_patterns->cfuOnPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cfuOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cfuOnAnnouncement;
+        if (m_patterns->cfuOnAnnouncement.empty() || !file_exists(cfuOnAnnouncement))
+        {
+            ERROR("CfuOnAnnouncement file does not exist ('%s').\n",
+                  cfuOnAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         u_int64_t attId = getAttributeId(my_handler, "cfu");
         if (!attId)
         {
@@ -1349,6 +1239,15 @@
     if ((ret = regexec(&m_patterns->cfuOffPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cfuOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cfuOffAnnouncement;
+        if (m_patterns->cfuOffAnnouncement.empty() || !file_exists(cfuOffAnnouncement))
+        {
+            ERROR("CfuOffAnnouncement file does not exist ('%s').\n",
+                  cfuOffAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         if (!deleteCFMap(my_handler, subId, SW_VSC_DESTSET_CFU, "cfu"))
         {
             filename = failAnnouncement;
@@ -1395,6 +1294,15 @@
     if ((ret = regexec(&m_patterns->cfbOnPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cfbOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cfbOnAnnouncement;
+        if (m_patterns->cfbOnAnnouncement.empty() || !file_exists(cfbOnAnnouncement))
+        {
+            ERROR("CfbOnAnnouncement file does not exist ('%s').\n",
+                  cfbOnAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         u_int64_t attId = getAttributeId(my_handler, "cfb");
         if (!attId)
         {
@@ -1466,6 +1374,15 @@
     if ((ret = regexec(&m_patterns->cfbOffPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cfbOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cfbOffAnnouncement;
+        if (m_patterns->cfbOffAnnouncement.empty() || !file_exists(cfbOffAnnouncement))
+        {
+            ERROR("CfbOffAnnouncement file does not exist ('%s').\n",
+                  cfbOffAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         if (!deleteCFMap(my_handler, subId, SW_VSC_DESTSET_CFB, "cfb"))
         {
             filename = failAnnouncement;
@@ -1512,6 +1429,15 @@
     if ((ret = regexec(&m_patterns->cftOnPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cftOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cftOnAnnouncement;
+        if (m_patterns->cftOnAnnouncement.empty() || !file_exists(cftOnAnnouncement))
+        {
+            ERROR("CftOnAnnouncement file does not exist ('%s').\n",
+                  cftOnAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         u_int64_t attId = getAttributeId(my_handler, "cft");
         if (!attId)
         {
@@ -1621,6 +1547,15 @@
     if ((ret = regexec(&m_patterns->cftOffPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cftOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cftOffAnnouncement;
+        if (m_patterns->cftOffAnnouncement.empty() || !file_exists(cftOffAnnouncement))
+        {
+            ERROR("CftOffAnnouncement file does not exist ('%s').\n",
+                  cftOffAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         if (!deleteCFMap(my_handler, subId, SW_VSC_DESTSET_CFT, "cft"))
         {
             filename = failAnnouncement;
@@ -1692,6 +1627,15 @@
     if ((ret = regexec(&m_patterns->cfnaOnPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cfnaOnAnnouncement = m_patterns->audioPath + lang + m_patterns->cfnaOnAnnouncement;
+        if (m_patterns->cfnaOnAnnouncement.empty() || !file_exists(cfnaOnAnnouncement))
+        {
+            ERROR("CfnaOnAnnouncement file does not exist ('%s').\n",
+                  cfnaOnAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         u_int64_t attId = getAttributeId(my_handler, "cfna");
         if (!attId)
         {
@@ -1763,6 +1707,15 @@
     if ((ret = regexec(&m_patterns->cfnaOffPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        cfnaOffAnnouncement = m_patterns->audioPath + lang + m_patterns->cfnaOffAnnouncement;
+        if (m_patterns->cfnaOffAnnouncement.empty() || !file_exists(cfnaOffAnnouncement))
+        {
+            ERROR("CfnaOffAnnouncement file does not exist ('%s').\n",
+                  cfnaOffAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         if (!deleteCFMap(my_handler, subId, SW_VSC_DESTSET_CFNA, "cfna"))
         {
             filename = failAnnouncement;
@@ -1809,6 +1762,15 @@
     if ((ret = regexec(&m_patterns->speedDialPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        speedDialAnnouncement = m_patterns->audioPath + lang + m_patterns->speedDialAnnouncement;
+        if (m_patterns->speedDialAnnouncement.empty() || !file_exists(speedDialAnnouncement))
+        {
+            ERROR("SpeedDialAnnouncement file does not exist ('%s').\n",
+                  speedDialAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         string slot = string("*") + req.user.substr(4, 1);
         if (!number2uri(req, my_handler, uuid, subId, domain, domId, 5,
                 uri, username))
@@ -1839,6 +1801,15 @@
     if ((ret = regexec(&m_patterns->reminderOnPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        reminderOnAnnouncement = m_patterns->audioPath + lang + m_patterns->reminderOnAnnouncement;
+        if (m_patterns->reminderOnAnnouncement.empty() || !file_exists(reminderOnAnnouncement))
+        {
+            ERROR("ReminderOnAnnouncement file does not exist ('%s').\n",
+                  reminderOnAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         int hour, min;
         string tim; char c_tim[6] = "";
         hour = atoi(req.user.substr(4, 2).c_str());
@@ -1885,6 +1856,15 @@
     if ((ret = regexec(&m_patterns->reminderOffPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        reminderOffAnnouncement = m_patterns->audioPath + lang + m_patterns->reminderOffAnnouncement;
+        if (m_patterns->reminderOffAnnouncement.empty() || !file_exists(reminderOffAnnouncement))
+        {
+            ERROR("ReminderOffAnnouncement file does not exist ('%s').\n",
+                  reminderOffAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         if (!deleteReminder(my_handler, subId))
         {
             filename = failAnnouncement;
@@ -1906,10 +1886,18 @@
     }
 
 
-    // block in clir
     if ((ret = regexec(&m_patterns->blockinclirOnPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        blockinclirOnAnnouncement = m_patterns->audioPath + lang + m_patterns->blockinclirOnAnnouncement;
+        if (m_patterns->blockinclirOnAnnouncement.empty() || !file_exists(blockinclirOnAnnouncement))
+        {
+            ERROR("BlockinclirOnAnnouncement file does not exist ('%s').\n",
+                  blockinclirOnAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         std::string val = "1";
         u_int64_t attId = getAttributeId(my_handler, "block_in_clir");
         if (!attId)
@@ -1957,6 +1945,15 @@
     if ((ret = regexec(&m_patterns->blockinclirOffPattern,
                        req.user.c_str(), 0, 0, 0)) == 0)
     {
+        blockinclirOffAnnouncement = m_patterns->audioPath + lang + m_patterns->blockinclirOffAnnouncement;
+        if (m_patterns->blockinclirOffAnnouncement.empty() || !file_exists(blockinclirOffAnnouncement))
+        {
+            ERROR("BlockinclirOffAnnouncement file does not exist ('%s').\n",
+                  blockinclirOffAnnouncement.c_str());
+            filename = failAnnouncement;
+            goto out;
+        }
+
         u_int64_t attId = getAttributeId(my_handler, "block_in_clir");
         if (!attId)
         {
