diff --git a/apps/voicebox/Voicebox.cpp b/apps/voicebox/Voicebox.cpp index 443b68c3..db0f8a1e 100644 --- a/apps/voicebox/Voicebox.cpp +++ b/apps/voicebox/Voicebox.cpp @@ -69,7 +69,7 @@ AmPromptCollection* VoiceboxFactory::getPrompts(const string& domain, map::iterator l_it = d_it->second.find(language); if (l_it != d_it->second.end()) { - // get the optios to the dom/lang combination + // get the options to the dom/lang combination po = PromptOptions(false, false); map >::iterator d_oit = prompt_options.find(domain); @@ -85,6 +85,21 @@ AmPromptCollection* VoiceboxFactory::getPrompts(const string& domain, return NULL; } +AmPromptCollection* VoiceboxFactory::findPrompts(const string& domain, + const string& language, + PromptOptions& po) { + AmPromptCollection* res = getPrompts(domain, language, po); + if (res) return res; + + // best hit: + if ((res = getPrompts(domain, default_language, po))!=NULL) return res; + if ((res = getPrompts(domain, "", po))!=NULL) return res; + + if ((res = getPrompts("", language, po))!=NULL) return res; + if ((res = getPrompts("", default_language, po))!=NULL) return res; + return getPrompts("", "", po); +} + AmPromptCollection* VoiceboxFactory::loadPrompts(string prompt_base_path, string domain, string language, bool load_digits) { @@ -301,7 +316,7 @@ AmSession* VoiceboxFactory::onInvite(const AmSipRequest& req) language = default_language; PromptOptions po(false, false); - AmPromptCollection* pc = getPrompts(domain, language, po); + AmPromptCollection* pc = findPrompts(domain, language, po); if (NULL == pc) throw AmSession::Exception(500, APP_NAME ": no menu for domain/language"); diff --git a/apps/voicebox/Voicebox.h b/apps/voicebox/Voicebox.h index 25806aaa..9dee22e8 100644 --- a/apps/voicebox/Voicebox.h +++ b/apps/voicebox/Voicebox.h @@ -49,6 +49,12 @@ class VoiceboxFactory AmPromptCollection* getPrompts(const string& domain, const string& language, PromptOptions& po); + + /** finds prompts from specific to default prompts */ + AmPromptCollection* findPrompts(const string& domain, + const string& language, + PromptOptions& po); + AmPromptCollection* loadPrompts(string prompt_base_path, string domain, string language, bool load_digits);