void CGUIDialogContentSettings::OnWindowLoaded() { CGUIDialogSettings::OnWindowLoaded(); CFileItemList items; if (m_info.strContent.Equals("albums")) CDirectory::GetDirectory("special://xbmc/system/scrapers/music/",items,".xml",false); else CDirectory::GetDirectory("special://xbmc/system/scrapers/video/",items,".xml",false); for (int i=0;i<items.Size();++i) { if (!items[i]->m_bIsFolder) { TiXmlDocument doc; doc.LoadFile(items[i]->m_strPath); if (doc.RootElement()) { bool IsDefaultScraper = false; const char* content = doc.RootElement()->Attribute("content"); const char* name = doc.RootElement()->Attribute("name"); const char* thumb = doc.RootElement()->Attribute("thumb"); if (content && name) { SScraperInfo info; info.strTitle = name; info.strPath = CUtil::GetFileName(items[i]->m_strPath); if (thumb) info.strThumb = thumb; info.strContent = content; info.settings = m_scraperSettings; if ( info.strPath == g_guiSettings.GetString("musiclibrary.defaultscraper") || info.strPath == g_guiSettings.GetString("scrapers.moviedefault") || info.strPath == g_guiSettings.GetString("scrapers.tvshowdefault") || info.strPath == g_guiSettings.GetString("scrapers.musicvideodefault")) { IsDefaultScraper = true; } map<CStdString,vector<SScraperInfo> >::iterator iter=m_scrapers.find(content); if (iter != m_scrapers.end()) { if (IsDefaultScraper) iter->second.insert(iter->second.begin(),info); else iter->second.push_back(info); } else { vector<SScraperInfo> vec; vec.push_back(info); m_scrapers.insert(make_pair(content,vec)); } } } } } // now select the correct scraper if (!m_info.strContent.IsEmpty()) { map<CStdString,vector<SScraperInfo> >::iterator iter = m_scrapers.find(m_info.strContent); if (iter != m_scrapers.end()) { for (vector<SScraperInfo>::iterator iter2 = iter->second.begin();iter2 != iter->second.end();++iter2) { if (iter2->strPath == m_info.strPath) { m_info = *iter2; break; } } } } CScraperParser parser; CStdString strPath; if (!m_info.strContent.IsEmpty()) strPath="special://xbmc/system/scrapers/video/"+m_info.strPath; if (!strPath.IsEmpty() && parser.Load(strPath) && parser.HasFunction("GetSettings")) CONTROL_ENABLE(CONTROL_SCRAPER_SETTINGS); else CONTROL_DISABLE(CONTROL_SCRAPER_SETTINGS); }
bool CGUIDialogContentSettings::OnMessage(CGUIMessage &message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_DEINIT: { m_scrapers.clear(); m_vecItems->Clear(); CGUIDialogSettings::OnMessage(message); } break; case GUI_MSG_ITEM_SELECT: { if (message.GetControlId() == CONTROL_SCRAPER_LIST) { if (!m_info.strContent.IsEmpty()) m_info = m_scrapers[m_info.strContent][message.GetParam1()]; } } break; case GUI_MSG_CLICKED: int iControl = message.GetSenderId(); if (iControl == 500) Close(); if (iControl == 501) { m_bNeedSave = false; Close(); } if (iControl == CONTROL_CONTENT_TYPE) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED,GetID(),CONTROL_CONTENT_TYPE); m_gWindowManager.SendMessage(msg); int iSelected = msg.GetParam1(); m_bNeedSave = true; CStdString strLabel; switch (iSelected) { case 0: m_info.strContent.Empty(); m_info.strPath.Empty(); m_info.strThumb.Empty(); m_info.strTitle.Empty(); OnSettingChanged(0); SetupPage(); break; case 1: strLabel = g_localizeStrings.Get(20342); m_info = FindDefault("movies", g_guiSettings.GetString("scrapers.moviedefault")); CreateSettings(); SetupPage(); break; case 2: strLabel = g_localizeStrings.Get(20343); m_info = FindDefault("tvshows", g_guiSettings.GetString("scrapers.tvshowdefault")); CreateSettings(); SetupPage(); break; case 3: strLabel = g_localizeStrings.Get(20389); m_info = FindDefault("musicvideos", g_guiSettings.GetString("scrapers.musicvideodefault")); CreateSettings(); SetupPage(); break; case 4: strLabel = g_localizeStrings.Get(132); m_info = FindDefault("albums", g_guiSettings.GetString("musiclibrary.defaultscraper")); CreateSettings(); SetupPage(); break; } } if (iControl == CONTROL_SCRAPER_LIST) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED,GetID(),CONTROL_SCRAPER_LIST); m_gWindowManager.SendMessage(msg); int iSelected = msg.GetParam1(); m_info = m_scrapers[m_info.strContent][iSelected]; FillListControl(); SET_CONTROL_FOCUS(30,0); } if (iControl == CONTROL_SCRAPER_SETTINGS) { if (m_info.settings.LoadSettingsXML("special://xbmc/system/scrapers/video/"+m_info.strPath)) { CGUIDialogPluginSettings::ShowAndGetInput(m_info); m_bNeedSave = true; return true; } return false; } CScraperParser parser; CStdString strPath; if (!m_info.strContent.IsEmpty()) strPath="special://xbmc/system/scrapers/video/"+m_info.strPath; if (!strPath.IsEmpty() && parser.Load(strPath) && parser.HasFunction("GetSettings")) CONTROL_ENABLE(CONTROL_SCRAPER_SETTINGS); else CONTROL_DISABLE(CONTROL_SCRAPER_SETTINGS); break; } return CGUIDialogSettings::OnMessage(message); }
void CGUIDialogContentSettings::OnWindowLoaded() { CGUIDialogSettings::OnWindowLoaded(); CFileItemList items; if (m_info.strContent.Equals("albums")) CDirectory::GetDirectory(_P("q:\\system\\scrapers\\music"),items,".xml",false); else CDirectory::GetDirectory(_P("q:\\system\\scrapers\\video"),items,".xml",false); for (int i=0; i<items.Size(); ++i) { if (!items[i]->m_bIsFolder) { TiXmlDocument doc; doc.LoadFile(items[i]->m_strPath); if (doc.RootElement()) { const char* content = doc.RootElement()->Attribute("content"); const char* name = doc.RootElement()->Attribute("name"); const char* thumb = doc.RootElement()->Attribute("thumb"); if (content && name) { SScraperInfo info; info.strTitle = name; info.strPath = CUtil::GetFileName(items[i]->m_strPath); if (thumb) info.strThumb = thumb; info.strContent = content; info.settings = m_scraperSettings; std::map<CStdString,std::vector<SScraperInfo> >::iterator iter=m_scrapers.find(content); if (iter != m_scrapers.end()) iter->second.push_back(info); else { std::vector<SScraperInfo> vec; vec.push_back(info); m_scrapers.insert(std::make_pair<CStdString,std::vector<SScraperInfo> >(content,vec)); } } } } } // now select the correct scraper if (!m_info.strContent.IsEmpty()) { std::map<CStdString,std::vector<SScraperInfo> >::iterator iter = m_scrapers.find(m_info.strContent); if (iter != m_scrapers.end()) { for (std::vector<SScraperInfo>::iterator iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) { if (iter2->strPath == m_info.strPath) { m_info = *iter2; break; } } } } CScraperParser parser; CStdString strPath; if (!m_info.strContent.IsEmpty()) strPath="q:\\system\\scrapers\\video\\"+m_info.strPath; if (!strPath.IsEmpty() && parser.Load(strPath) && parser.HasFunction("GetSettings")) { CONTROL_ENABLE(CONTROL_SCRAPER_SETTINGS) } else { CONTROL_DISABLE(CONTROL_SCRAPER_SETTINGS) } }