change audio directory setting to language

feature/AudioLoginLogoff
Geoffrey Merck 6 years ago
parent 5b8eaaf86f
commit ea9b0e9167

@ -224,15 +224,10 @@ CSGSXLConfig::CSGSXLConfig(const std::string &pathname)
//audio
get_value(cfg, "audio.enabled", m_audioEnabled, true);
get_value(cfg, "audio.directory", m_audioDirectory, 0, 2000, "");
std::string audioDirectory = std::string(DATA_DIR) + "/" + m_audioDirectory;
get_value(cfg, "audio.language", m_audioLanguage, TL_ENGLISH_UK);
if(m_audioEnabled && !std::filesystem::exists(audioDirectory)) {
m_audioEnabled = false;
printf("Audio directory: %s does not exist\n", audioDirectory.c_str());
}
if(m_audioEnabled) {
printf("Audio enabled, auudio directory : %s\n", audioDirectory.c_str());
printf("Audio enabled\n");
} else {
printf("Audio disabled\n");
}
@ -270,6 +265,12 @@ unsigned int CSGSXLConfig::getLinkCount(const char *type)
return count;
}
void CSGSXLConfig::getAudio(bool & enabled, TEXT_LANG & lang) const
{
enabled = m_audioEnabled;
lang = m_audioLanguage;
}
bool CSGSXLConfig::hasErrors()
{
return m_hasErrors;
@ -285,6 +286,56 @@ bool CSGSXLConfig::get_value(const Config &cfg, const std::string &path, int &va
return true;
}
bool CSGSXLConfig::get_value(const Config &cfg, const std::string &path, TEXT_LANG& lang, TEXT_LANG defaultValue)
{
lang = defaultValue;
std::string value;
if(cfg.lookupValue(path, value)) {
if(value == "de_DE")
{
lang = TL_DEUTSCH;
}
else if(value == "dk_DK")
{
lang = TL_DANSK;
}
else if(value == "it_IT")
{
lang = TL_ITALIANO;
}
else if(value == "fr_FR")
{
lang = TL_FRANCAIS;
}
else if(value == "es_ES")
{
lang = TL_ESPANOL;
}
else if(value == "se_SE")
{
lang = TL_SVENSKA;
}
else if(value == "pl_PL")
{
lang = TL_POLSKI;
}
else if(value == "en_US")
{
lang = TL_ENGLISH_US;
}
else if(value == "en_GB")
{
lang = TL_ENGLISH_UK;
}
else if(value == "no_NO")
{
lang = TL_NORSK;
}
}
return true;
}
bool CSGSXLConfig::get_value(const Config &cfg, const std::string &path, bool &value, bool default_value)
{
if (! cfg.lookupValue(path, value))

@ -56,7 +56,7 @@ public:
void getRemote(bool &enabled, std::string &password, unsigned int &port) const;
void getAudio(bool & enabled, std::string &audioDir) const;
void getAudio(bool & enabled, TEXT_LANG & lang) const;
unsigned int getModCount();
unsigned int getLinkCount(const char *type);
@ -68,6 +68,7 @@ private:
bool get_value(const Config &cfg, const std::string &path, int &value, int min, int max, int default_value);
bool get_value(const Config &cfg, const std::string &path, bool &value, bool default_value);
bool get_value(const Config &cfg, const std::string &path, std::string &value, int min, int max, const std::string &default_value);
bool get_value(const Config &cfg, const std::string &path, TEXT_LANG &lang, TEXT_LANG defaultValue);
std::string m_fileName;
std::string m_callsign;
@ -80,7 +81,7 @@ private:
unsigned int m_remotePort;
bool m_audioEnabled;
std::string m_audioDirectory;
TEXT_LANG m_audioLanguage;
bool m_hasErrors;
};

@ -9,8 +9,7 @@ gateway = {
audio = {
enabled = true
# The directory containing audio files for announcement. This is relative to DATADIR (see Makefile). It is case senstitive
directory = "en_GB"
language = "en_GB"
}
# NOTHING usually needs to be specified in the ircddb section, quadnet is the default network. To make you groups available on more than Quadnet

Loading…
Cancel
Save

Powered by TurnKey Linux.