bool CAddonMgr::CheckUserDirs(const cp_cfg_element_t *settings) { if (!settings) return false; const cp_cfg_element_t *userdirs = GetExtElement((cp_cfg_element_t *)settings, "userdirs"); if (!userdirs) return false; ELEMENTS elements; if (!GetExtElements((cp_cfg_element_t *)userdirs, "userdir", elements)) return false; ELEMENTS::iterator itr = elements.begin(); while (itr != elements.end()) { CStdString path = GetExtValue(*itr++, "@path"); if (!CFile::Exists(path)) { if (!CUtil::CreateDirectoryEx(path)) { CLog::Log(LOGERROR, "CAddonMgr::CheckUserDirs: Unable to create directory %s.", path.c_str()); return false; } } } return true; }
bool CAddonMgr::GetExtElements(cp_cfg_element_t *base, const char *path, ELEMENTS &elements) { if (!base || !path) return false; for (unsigned int i = 0; i < base->num_children; i++) { CStdString temp = base->children[i].name; if (!temp.compare(path)) elements.push_back(&base->children[i]); } return !elements.empty(); }
CSkinInfo::CSkinInfo(const cp_extension_t *ext) : CAddon(ext), m_version("") { ELEMENTS elements; if (CAddonMgr::Get().GetExtElements(ext->configuration, "res", elements)) { for (ELEMENTS::iterator i = elements.begin(); i != elements.end(); ++i) { int width = atoi(CAddonMgr::Get().GetExtValue(*i, "@width").c_str()); int height = atoi(CAddonMgr::Get().GetExtValue(*i, "@height").c_str()); bool defRes = CAddonMgr::Get().GetExtValue(*i, "@default") == "true"; std::string folder = CAddonMgr::Get().GetExtValue(*i, "@folder"); float aspect = 0; std::string strAspect = CAddonMgr::Get().GetExtValue(*i, "@aspect"); vector<string> fracs = StringUtils::Split(strAspect, ":"); if (fracs.size() == 2) aspect = (float)(atof(fracs[0].c_str())/atof(fracs[1].c_str())); if (width > 0 && height > 0) { RESOLUTION_INFO res(width, height, aspect, folder); res.strId = strAspect; // for skin usage, store aspect string in strId if (defRes) m_defaultRes = res; m_resolutions.push_back(res); } } } else { // no resolutions specified -> backward compatibility std::string defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultwideresolution"); if (defaultWide.empty()) defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultresolution"); TranslateResolution(defaultWide, m_defaultRes); } std::string str = CAddonMgr::Get().GetExtValue(ext->configuration, "@effectslowdown"); if (!str.empty()) m_effectsSlowDown = (float)atof(str.c_str()); else m_effectsSlowDown = 1.f; str = CAddonMgr::Get().GetExtValue(ext->configuration, "@debugging"); m_debugging = !strcmp(str.c_str(), "true"); LoadStartupWindows(ext); // figure out the version m_version = GetDependencyVersion("xbmc.gui"); }
CSkinInfo::CSkinInfo(const cp_extension_t *ext) : CAddon(ext) { ELEMENTS elements; if (CAddonMgr::Get().GetExtElements(ext->configuration, "res", elements)) { for (ELEMENTS::iterator i = elements.begin(); i != elements.end(); ++i) { int width = atoi(CAddonMgr::Get().GetExtValue(*i, "@width")); int height = atoi(CAddonMgr::Get().GetExtValue(*i, "@height")); bool defRes = CAddonMgr::Get().GetExtValue(*i, "@default").Equals("true"); CStdString folder = CAddonMgr::Get().GetExtValue(*i, "@folder"); float aspect = 0; CStdStringArray fracs; StringUtils::SplitString(CAddonMgr::Get().GetExtValue(*i, "@aspect"), ":", fracs); if (fracs.size() == 2) aspect = (float)(atof(fracs[0].c_str())/atof(fracs[1].c_str())); if (width > 0 && height > 0) { RESOLUTION_INFO res(width, height, aspect, folder); if (defRes) m_defaultRes = res; m_resolutions.push_back(res); } } } else { // no resolutions specified -> backward compatibility CStdString defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultwideresolution"); if (defaultWide.IsEmpty()) defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultresolution"); TranslateResolution(defaultWide, m_defaultRes); } CStdString str = CAddonMgr::Get().GetExtValue(ext->configuration, "@effectslowdown"); if (!str.IsEmpty()) m_effectsSlowDown = (float)atof(str.c_str()); else m_effectsSlowDown = 1.f; str = CAddonMgr::Get().GetExtValue(ext->configuration, "@debugging"); m_debugging = !strcmp(str.c_str(), "true"); m_onlyAnimateToHome = true; LoadStartupWindows(ext); m_Version = 2.11; }