o $prompts.default_fallback

o required_prompts config 


git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1246 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 17 years ago
parent 67c1ffed32
commit e44d2a100f

@ -104,6 +104,22 @@ int DSMFactory::onLoad()
}
}
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 =

@ -34,7 +34,7 @@ DSMDialog::DSMDialog(AmPromptCollection& prompts,
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 @@ DSMDialog::~DSMDialog()
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 @@ inline UACAuthCred* DSMDialog::getCredentials() {
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 @@ void DSMDialog::setPromptSet(const string& name) {
}
DBG("setting prompt set '%s'\n", name.c_str());
used_prompt_sets.insert(&prompts);
prompts = *it->second;
SET_ERRNO(DSM_ERRNO_OK);
}

@ -35,6 +35,8 @@
#include "DSMStateEngine.h"
#include "DSMStateDiagramCollection.h"
#include <set>
class DSMDialog : public AmSession,
public DSMSession,
public CredentialHolder
@ -43,6 +45,7 @@ class DSMDialog : public AmSession,
DSMStateEngine engine;
AmPromptCollection& prompts;
AmPromptCollection& default_prompts;
DSMStateDiagramCollection& diags;
string startDiagName;
AmPlaylist playlist;
@ -50,6 +53,7 @@ class DSMDialog : public AmSession,
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 @@ public:
// 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);

@ -35,6 +35,8 @@ actions:
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()

@ -21,6 +21,9 @@ outbound_start_diag=outbound_call
# 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/

Loading…
Cancel
Save