Author: sayer
Date: 2009-01-27 11:16:46 +0100 (Tue, 27 Jan 2009)
New Revision: 1246

Modified:
   trunk/apps/dsm/DSM.cpp
   trunk/apps/dsm/DSMDialog.cpp
   trunk/apps/dsm/DSMDialog.h
   trunk/apps/dsm/doc/dsm_syntax.txt
   trunk/apps/dsm/etc/dsm.conf
Log:
 o $prompts.default_fallback
 o required_prompts config 


Modified: trunk/apps/dsm/DSM.cpp
===================================================================
--- trunk/apps/dsm/DSM.cpp      2009-01-27 10:11:31 UTC (rev 1245)
+++ trunk/apps/dsm/DSM.cpp      2009-01-27 10:16:46 UTC (rev 1246)
@@ -104,6 +104,22 @@
     }
   }
 
+
+  bool has_all_prompts = true;
+  vector<string> required_prompts = 
+    explode(cfg.getParameter("required_prompts"), ",");
+  
+  for (vector<string>::iterator it=required_prompts.begin(); 
+       it != required_prompts.end(); it++) {
+    if (!prompts.hasPrompt(*it)) {
+      ERROR("required prompt '%s' not loaded.\n",
+           it->c_str());
+      has_all_prompts = false;
+    }
+  }
+  if (!has_all_prompts)
+    return -1;
+
   string prompt_sets_path = cfg.getParameter("prompts_sets_path");
 
   vector<string> prompt_sets_names = 

Modified: trunk/apps/dsm/DSMDialog.cpp
===================================================================
--- trunk/apps/dsm/DSMDialog.cpp        2009-01-27 10:11:31 UTC (rev 1245)
+++ trunk/apps/dsm/DSMDialog.cpp        2009-01-27 10:16:46 UTC (rev 1246)
@@ -34,7 +34,7 @@
                     DSMStateDiagramCollection& diags,
                     const string& startDiagName,
                     UACAuthCred* credentials)
-  : prompts(prompts), diags(diags), startDiagName(startDiagName), 
+  : prompts(prompts), default_prompts(prompts), diags(diags), 
startDiagName(startDiagName), 
     playlist(this), cred(credentials), 
     rec_file(NULL)
 {
@@ -47,10 +47,14 @@
         audiofiles.begin();it!=audiofiles.end();it++) 
     delete *it;
 
-  prompts.cleanup((long)this);
-  for (map<string, AmPromptCollection*>::iterator it=
-        prompt_sets.begin(); it != prompt_sets.end(); it++)
-    it->second->cleanup((long)this);
+  used_prompt_sets.insert(&prompts);
+  for (set<AmPromptCollection*>::iterator it=
+        used_prompt_sets.begin(); it != used_prompt_sets.end(); it++)
+    (*it)->cleanup((long)this);
+
+//   for (map<string, AmPromptCollection*>::iterator it=
+//      prompt_sets.begin(); it != prompt_sets.end(); it++)
+//     it->second->cleanup((long)this);
 }
 
 /** returns whether var exists && var==value*/
@@ -172,11 +176,18 @@
 void DSMDialog::playPrompt(const string& name, bool loop) {
   DBG("playing prompt '%s'\n", name.c_str());
   if (prompts.addToPlaylist(name,  (long)this, playlist, 
-                           /*front =*/ false, loop)) 
-    SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
-  else
+                           /*front =*/ false, loop))  {
+    if ((var["prompts.default_fallback"] != "yes") ||
+      default_prompts.addToPlaylist(name,  (long)this, playlist, 
+                                   /*front =*/ false, loop)) {
+      SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);
+    } else {
+      used_prompt_sets.insert(&default_prompts);
+      SET_ERRNO(DSM_ERRNO_OK);    
+    }      
+  } else {
     SET_ERRNO(DSM_ERRNO_OK);
-
+  }
 }
 
 void DSMDialog::closePlaylist(bool notify) {
@@ -259,6 +270,7 @@
   }
 
   DBG("setting prompt set '%s'\n", name.c_str());
+  used_prompt_sets.insert(&prompts);
   prompts = *it->second;
   SET_ERRNO(DSM_ERRNO_OK);
 }

Modified: trunk/apps/dsm/DSMDialog.h
===================================================================
--- trunk/apps/dsm/DSMDialog.h  2009-01-27 10:11:31 UTC (rev 1245)
+++ trunk/apps/dsm/DSMDialog.h  2009-01-27 10:16:46 UTC (rev 1246)
@@ -35,6 +35,8 @@
 #include "DSMStateEngine.h"
 #include "DSMStateDiagramCollection.h"
 
+#include <set>
+
 class DSMDialog : public AmSession,
                  public DSMSession,
                  public CredentialHolder
@@ -43,6 +45,7 @@
   
   DSMStateEngine engine;
   AmPromptCollection& prompts;
+  AmPromptCollection& default_prompts;
   DSMStateDiagramCollection& diags;
   string startDiagName;
   AmPlaylist playlist;
@@ -50,6 +53,7 @@
   vector<AmAudio*> audiofiles;
   AmAudioFile* rec_file;
   map<string, AmPromptCollection*> prompt_sets;
+  std::set<AmPromptCollection*> used_prompt_sets;
 
   bool checkVar(const string& var_name, const string& var_val);
 public:
@@ -75,6 +79,7 @@
 
   // DSMSession interface
   void playPrompt(const string& name, bool loop = false);
+
   void closePlaylist(bool notify);
   void playFile(const string& name, bool loop);
   void recordFile(const string& name);

Modified: trunk/apps/dsm/doc/dsm_syntax.txt
===================================================================
--- trunk/apps/dsm/doc/dsm_syntax.txt   2009-01-27 10:11:31 UTC (rev 1245)
+++ trunk/apps/dsm/doc/dsm_syntax.txt   2009-01-27 10:16:46 UTC (rev 1246)
@@ -35,6 +35,8 @@
 
  playPrompt(param)
    from promptCollection, e.g. playPrompt("hello");
+   if $prompts.default_fallback=yes, default prompt set is tried if
+   prompt not found in current prompt set
  playFile(filename)
  recordFile(filename)
  stopRecord()

Modified: trunk/apps/dsm/etc/dsm.conf
===================================================================
--- trunk/apps/dsm/etc/dsm.conf 2009-01-27 10:11:31 UTC (rev 1245)
+++ trunk/apps/dsm/etc/dsm.conf 2009-01-27 10:16:46 UTC (rev 1246)
@@ -21,6 +21,9 @@
 # prompts files (for prompt collection
 
load_prompts=/usr/local/etc/sems/etc/dsm_in_prompts.conf,/usr/local/etc/sems/etc/dsm_out_prompts.conf
 
+# prompts which must be loaded (or else...)
+#required_prompts=welcome,error
+
 #load prompt sets config from this path
 #prompts_sets_path=/usr/local/etc/sems/etc/
 

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to