const CStdString &CGUISettings::GetString(const char *strSetting, bool bPrompt) const { ASSERT(settingsMap.size()); constMapIter it = settingsMap.find(CStdString(strSetting).ToLower()); if (it != settingsMap.end()) { CSettingString* result = ((CSettingString *)(*it).second); if (result->GetData() == "select folder" || result->GetData() == "select writable folder") { CStdString strData = ""; if (bPrompt) { VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares,g_localizeStrings.Get(result->GetLabel()),strData,result->GetData() == "select writable folder")) { result->SetData(strData); g_settings.Save(); } else return StringUtils::EmptyString; } else return StringUtils::EmptyString; } return result->GetData(); } // Assert here and write debug output CLog::Log(LOGDEBUG,"Error: Requested setting (%s) was not found. It must be case-sensitive", strSetting); //ASSERT(false); // hardcoded return value so that compiler is happy return StringUtils::EmptyString; }
void CPeripheral::SetSetting(const CStdString &strKey, const CStdString &strValue) { map<CStdString, CSetting *>::iterator it = m_settings.find(strKey); if (it != m_settings.end()) { if ((*it).second->GetType() == SETTINGS_TYPE_STRING) { CSettingString *stringSetting = (CSettingString *) (*it).second; if (stringSetting) { bool bChanged(!stringSetting->GetData().Equals(strValue)); stringSetting->SetData(strValue); if (bChanged && m_bInitialised) OnSettingChanged(strKey); } } else if ((*it).second->GetType() == SETTINGS_TYPE_INT) SetSetting(strKey, (int) (strValue.IsEmpty() ? 0 : atoi(strValue.c_str()))); else if ((*it).second->GetType() == SETTINGS_TYPE_FLOAT) SetSetting(strKey, (float) (strValue.IsEmpty() ? 0 : atof(strValue.c_str()))); else if ((*it).second->GetType() == SETTINGS_TYPE_BOOL) SetSetting(strKey, strValue.Equals("1")); } }