2 * Copyright (C) 2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "SettingAddon.h"
22 #include "addons/Addon.h"
23 #include "settings/lib/SettingsManager.h"
24 #include "utils/log.h"
25 #include "utils/XBMCTinyXML.h"
26 #include "utils/XMLUtils.h"
28 #define XML_ELM_DEFAULT "default"
30 CSettingAddon::CSettingAddon(const std::string &id, CSettingsManager *settingsManager /* = NULL */)
31 : CSettingString(id, settingsManager),
32 m_addonType(ADDON::ADDON_UNKNOWN)
35 CSettingAddon::CSettingAddon(const std::string &id, const CSettingAddon &setting)
36 : CSettingString(id, setting)
41 CSetting* CSettingAddon::Clone(const std::string &id) const
43 return new CSettingAddon(id, *this);
46 bool CSettingAddon::Deserialize(const TiXmlNode *node, bool update /* = false */)
48 CExclusiveLock lock(m_critical);
50 if (!CSettingString::Deserialize(node, update))
53 if (m_control != NULL &&
54 (m_control->GetType() != "button" || m_control->GetFormat() != "addon"))
56 CLog::Log(LOGERROR, "CSettingAddon: invalid <control> of \"%s\"", m_id.c_str());
61 CStdString strAddonType;
62 const TiXmlNode *constraints = node->FirstChild("constraints");
63 if (constraints != NULL)
66 if (XMLUtils::GetString(constraints, "addontype", strAddonType) && !strAddonType.empty())
68 m_addonType = ADDON::TranslateType(strAddonType);
69 if (m_addonType != ADDON::ADDON_UNKNOWN)
76 CLog::Log(LOGERROR, "CSettingAddon: error reading the addontype value \"%s\" of \"%s\"", strAddonType.c_str(), m_id.c_str());
83 void CSettingAddon::copy(const CSettingAddon &setting)
85 CSettingString::Copy(setting);
87 CExclusiveLock lock(m_critical);
88 m_addonType = setting.m_addonType;