void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat) { PVR_MENUHOOKS *hooks = NULL; // get client id if (iClientID < 0 && cat == PVR_MENUHOOK_SETTING) { PVR_CLIENTMAP clients; GetConnectedClients(clients); if (clients.size() == 1) { iClientID = clients.begin()->first; } else if (clients.size() > 1) { // have user select client CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(19196); PVR_CLIENTMAP_ITR itrClients; for (itrClients = clients.begin(); itrClients != clients.end(); itrClients++) { pDialog->Add(itrClients->second->GetBackendName()); } pDialog->DoModal(); int selection = pDialog->GetSelectedLabel(); if (selection >= 0) { itrClients = clients.begin(); for (int i = 0; i < selection; i++) itrClients++; iClientID = itrClients->first; } } } if (iClientID < 0) iClientID = GetPlayingClientID(); PVR_CLIENT client; if (GetConnectedClient(iClientID, client) && client->HaveMenuHooks(cat)) { hooks = client->GetMenuHooks(); std::vector<int> hookIDs; CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(19196); for (unsigned int i = 0; i < hooks->size(); i++) pDialog->Add(client->GetString(hooks->at(i).iLocalizedStringId)); pDialog->DoModal(); int selection = pDialog->GetSelectedLabel(); if (selection >= 0) client->CallMenuHook(hooks->at(selection)); } }
PVR_ERROR CPVRClients::DeleteAllRecordingsFromTrash() { PVR_ERROR error(PVR_ERROR_NO_ERROR); PVR_CLIENTMAP clients; GetConnectedClients(clients); std::vector<PVR_CLIENT> suppClients; for (PVR_CLIENTMAP_CITR itrClients = clients.begin(); itrClients != clients.end(); ++itrClients) { if (itrClients->second->SupportsRecordingsUndelete() && itrClients->second->GetRecordingsAmount(true) > 0) suppClients.push_back(itrClients->second); } int selection = 0; if (suppClients.size() > 1) { // have user select client CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(CVariant{19292}); //Delete all permanently pDialog->Add(g_localizeStrings.Get(24032)); // All Add-ons PVR_CLIENTMAP_CITR itrClients; for (itrClients = clients.begin(); itrClients != clients.end(); ++itrClients) { if (itrClients->second->SupportsRecordingsUndelete() && itrClients->second->GetRecordingsAmount(true) > 0) pDialog->Add(itrClients->second->GetBackendName()); } pDialog->Open(); selection = pDialog->GetSelectedItem(); } if (selection == 0) { typedef std::vector<PVR_CLIENT>::const_iterator suppClientsCITR; for (suppClientsCITR itrSuppClients = suppClients.begin(); itrSuppClients != suppClients.end(); ++itrSuppClients) { PVR_ERROR currentError = (*itrSuppClients)->DeleteAllRecordingsFromTrash(); if (currentError != PVR_ERROR_NO_ERROR) { CLog::Log(LOGERROR, "PVR - %s - cannot delete all recordings from client '%d': %s",__FUNCTION__, (*itrSuppClients)->GetID(), CPVRClient::ToString(currentError)); error = currentError; } } } else if (selection >= 1 && selection <= (int)suppClients.size()) { PVR_ERROR currentError = suppClients[selection-1]->DeleteAllRecordingsFromTrash(); if (currentError != PVR_ERROR_NO_ERROR) { CLog::Log(LOGERROR, "PVR - %s - cannot delete all recordings from client '%d': %s",__FUNCTION__, suppClients[selection-1]->GetID(), CPVRClient::ToString(currentError)); error = currentError; } } return error; }
bool CGUIDialogMusicOSD::OnAction(const CAction &action) { switch (action.GetID()) { case ACTION_SHOW_OSD: Close(); return true; case ACTION_SET_RATING: { CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (dialog) { dialog->SetHeading(CVariant{ 38023 }); dialog->Add(g_localizeStrings.Get(38022)); for (int i = 1; i <= 10; i++) dialog->Add(StringUtils::Format("%s: %i", g_localizeStrings.Get(563).c_str(), i)); auto track = g_application.CurrentFileItemPtr(); dialog->SetSelected(track->GetMusicInfoTag()->GetUserrating()); dialog->Open(); int userrating = dialog->GetSelectedItem(); if (userrating < 0) userrating = 0; if (userrating > 10) userrating = 10; if (userrating != track->GetMusicInfoTag()->GetUserrating()) { track->GetMusicInfoTag()->SetUserrating(userrating); // send a message to all windows to tell them to update the fileitem (eg playlistplayer, media windows) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_ITEM, 0, track); g_windowManager.SendMessage(msg); CMusicDatabase db; if (db.Open()) { db.SetSongUserrating(track->GetMusicInfoTag()->GetURL(), userrating); db.Close(); } } } return true; } default: break; } return CGUIDialog::OnAction(action); }
std::vector<int>* Dialog::multiselect(const String& heading, const std::vector<String>& options, int autoclose) { DelayedCallGuard dcguard(languageHook); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (pDialog == nullptr) throw WindowException("Error: Window is NULL"); pDialog->Reset(); pDialog->SetMultiSelection(true); pDialog->SetHeading(CVariant{heading}); for (const auto& option : options) pDialog->Add(option); if (autoclose > 0) pDialog->SetAutoClose(autoclose); pDialog->Open(); if (pDialog->IsConfirmed()) return new std::vector<int>(pDialog->GetSelectedItems()); else return nullptr; }
void CPVRClients::ProcessMenuHooks(int iClientID) { PVR_MENUHOOKS *hooks = NULL; CSingleLock lock(m_critSection); if (iClientID < 0) iClientID = GetPlayingClientID(); if (GetMenuHooks(iClientID, hooks)) { boost::shared_ptr<CPVRClient> client = m_clientMap.find(iClientID)->second; lock.Leave(); std::vector<long> hookIDs; CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(19196); for (unsigned int i = 0; i < hooks->size(); i++) pDialog->Add(client->GetString(hooks->at(i).string_id)); pDialog->DoModal(); int selection = pDialog->GetSelectedLabel(); if (selection >= 0) { client->CallMenuHook(hooks->at(selection)); } } else { CLog::Log(LOGERROR, "PVR - %s - cannot find client %d",__FUNCTION__, iClientID); } }
void CPVRClients::ProcessMenuHooks(int iClientID) { PVR_MENUHOOKS *hooks = NULL; if (iClientID < 0) iClientID = GetPlayingClientID(); if (GetMenuHooks(iClientID, hooks)) { boost::shared_ptr<CPVRClient> client; if (!GetValidClient(iClientID, client)) return; std::vector<int> hookIDs; CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(19196); for (unsigned int i = 0; i < hooks->size(); i++) pDialog->Add(client->GetString(hooks->at(i).iLocalizedStringId)); pDialog->DoModal(); int selection = pDialog->GetSelectedLabel(); if (selection >= 0) { client->CallMenuHook(hooks->at(selection)); } } else { CLog::Log(LOGERROR, "PVR - %s - cannot find client %d",__FUNCTION__, iClientID); } }
void CGUIDialogSmartPlaylistRule::OnField() { const auto fields = CSmartPlaylistRule::GetFields(m_type); CGUIDialogSelect* dialog = g_windowManager.GetWindow<CGUIDialogSelect>(); dialog->Reset(); dialog->SetHeading(CVariant{20427}); int selected = -1; for (auto field = fields.begin(); field != fields.end(); field++) { dialog->Add(CSmartPlaylistRule::GetLocalizedField(*field)); if (*field == m_rule.m_field) selected = std::distance(fields.begin(), field); } if (selected > -1) dialog->SetSelected(selected); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == selected) return; m_rule.m_field = fields[newSelected]; // check if operator is still valid. if not, reset to first valid one std::vector< std::pair<std::string, int> > validOperators = GetValidOperators(m_rule); bool isValid = false; for (auto op : validOperators) if (std::get<0>(op) == std::get<0>(OperatorLabel(m_rule.m_operator))) isValid = true; if (!isValid) m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)std::get<1>(validOperators[0]); m_rule.SetParameter(""); UpdateButtons(); }
bool CGUIDialogPVRChannelManager::OnClickButtonNewChannel() { int iSelection = 0; if (g_PVRClients->ConnectedClientAmount() > 1) { CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (!pDlgSelect) return false; pDlgSelect->SetHeading(19213); // Select Client PVR_CLIENT_ITR itr; for (itr = m_clientsWithSettingsList.begin() ; itr != m_clientsWithSettingsList.end(); ++itr) pDlgSelect->Add((*itr)->Name()); pDlgSelect->DoModal(); iSelection = pDlgSelect->GetSelectedLabel(); } if (iSelection >= 0 && iSelection < (int)m_clientsWithSettingsList.size()) { int iClientID = m_clientsWithSettingsList[iSelection]->GetID(); CPVRChannelPtr channel(new CPVRChannel(m_bIsRadio)); channel->SetChannelName(g_localizeStrings.Get(19204)); // New channel channel->SetEPGEnabled(g_PVRClients->SupportsEPG(iClientID)); channel->SetClientID(iClientID); if (g_PVRClients->OpenDialogChannelAdd(channel)) Update(); else CGUIDialogOK::ShowAndGetInput(2103, 0, 16029, 0); // Add-on error;Check the log file for details. } return true; }
int Interface_GUIDialogSelect::open(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, unsigned int autoclose) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogSelect::%s - invalid data", __FUNCTION__); return -1; } CGUIDialogSelect* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!heading || !entries || !dialog) { CLog::Log(LOGERROR, "Interface_GUIDialogSelect::%s - invalid handler data (heading='%p', entries='%p', " "dialog='%p') on addon '%s'", __FUNCTION__, heading, static_cast<const void*>(entries), static_cast<void*>(dialog), addon->ID().c_str()); return -1; } dialog->Reset(); dialog->SetHeading(CVariant{heading}); for (unsigned int i = 0; i < size; ++i) dialog->Add(entries[i]); if (selected > 0) dialog->SetSelected(selected); if (autoclose > 0) dialog->SetAutoClose(autoclose); dialog->Open(); return dialog->GetSelectedItem(); }
void CPVRClients::ProcessMenuHooks(int iClientID) { PVR_MENUHOOKS *hooks = NULL; if (iClientID < 0) iClientID = GetPlayingClientID(); boost::shared_ptr<CPVRClient> client; if (GetConnectedClient(iClientID, client) && client->HaveMenuHooks()) { hooks = client->GetMenuHooks(); std::vector<int> hookIDs; CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(19196); for (unsigned int i = 0; i < hooks->size(); i++) pDialog->Add(client->GetString(hooks->at(i).iLocalizedStringId)); pDialog->DoModal(); int selection = pDialog->GetSelectedLabel(); if (selection >= 0) client->CallMenuHook(hooks->at(selection)); } }
RENDER_STEREO_MODE CStereoscopicsManager::GetStereoModeByUserChoice(const std::string &heading) { RENDER_STEREO_MODE mode = GetStereoMode(); // if no stereo mode is set already, suggest mode of current video by preselecting it if (mode == RENDER_STEREO_MODE_OFF && g_infoManager.EvaluateBool("videoplayer.isstereoscopic")) mode = GetStereoModeOfPlayingVideo(); CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); if (heading.empty()) pDlgSelect->SetHeading(CVariant{g_localizeStrings.Get(36528)}); else pDlgSelect->SetHeading(CVariant{heading}); // prepare selectable stereo modes std::vector<RENDER_STEREO_MODE> selectableModes; for (int i = RENDER_STEREO_MODE_OFF; i < RENDER_STEREO_MODE_COUNT; i++) { RENDER_STEREO_MODE selectableMode = (RENDER_STEREO_MODE) i; if (g_Windowing.SupportsStereo(selectableMode)) { selectableModes.push_back(selectableMode); std::string label = GetLabelForStereoMode((RENDER_STEREO_MODE) i); pDlgSelect->Add( label ); if (mode == selectableMode) pDlgSelect->SetSelected( label ); } // inject AUTO pseudo mode after OFF if (i == RENDER_STEREO_MODE_OFF) { selectableModes.push_back(RENDER_STEREO_MODE_AUTO); pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_AUTO)); } } pDlgSelect->Open(); int iItem = pDlgSelect->GetSelectedLabel(); if (iItem > -1 && pDlgSelect->IsConfirmed()) mode = (RENDER_STEREO_MODE) selectableModes[iItem]; else mode = GetStereoMode(); return mode; }
bool Interface_GUIDialogSelect::open_multi_select(void* kodiBase, const char *heading, const char *entryIDs[], const char *entryNames[], bool entriesSelected[], unsigned int size, unsigned int autoclose) { CAddonDll* addon = static_cast<CAddonDll*>(kodiBase); if (!addon) { CLog::Log(LOGERROR, "Interface_GUIDialogMultiSelect::%s - invalid data", __FUNCTION__); return false; } CGUIDialogSelect* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!heading || !entryIDs || !entryNames || !entriesSelected || !dialog) { CLog::Log(LOGERROR, "Interface_GUIDialogMultiSelect::%s - invalid handler data (heading='%p', " "entryIDs='%p', entryNames='%p', entriesSelected='%p', dialog='%p') on addon '%s'", __FUNCTION__, heading, static_cast<const void*>(entryIDs), static_cast<const void*>(entryNames), static_cast<void*>(entriesSelected), static_cast<void*>(dialog), addon->ID().c_str()); return false; } dialog->Reset(); dialog->SetMultiSelection(true); dialog->SetHeading(CVariant{heading}); std::vector<int> selectedIndexes; for (unsigned int i = 0; i < size; ++i) { dialog->Add(entryNames[i]); if (entriesSelected[i]) selectedIndexes.push_back(i); } dialog->SetSelected(selectedIndexes); if (autoclose > 0) dialog->SetAutoClose(autoclose); dialog->Open(); if (dialog->IsConfirmed()) { for (unsigned int i = 0; i < size; ++i) entriesSelected[i] = false; selectedIndexes = dialog->GetSelectedItems(); for (unsigned int i = 0; i < selectedIndexes.size(); ++i) { if (selectedIndexes[i]) entriesSelected[selectedIndexes[i]] = true; } } return true; }
void CGUIDialogSongInfo::OnSetUserrating() { CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (dialog) { dialog->SetHeading(CVariant{ 38023 }); dialog->Add(g_localizeStrings.Get(38022)); for (int i = 1; i <= 5; i++) dialog->Add(StringUtils::Format("%s: %i", g_localizeStrings.Get(563).c_str(), i)); dialog->Open(); int iItem = dialog->GetSelectedLabel(); if (iItem < 0) return; SetUserrating('0' + iItem); // This is casting the int rating to char } }
void CGUIDialogMusicInfo::OnSetUserrating() { CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (dialog) { dialog->SetHeading(CVariant{ 38023 }); dialog->Add(g_localizeStrings.Get(38022)); for (int i = 1; i <= 10; i++) dialog->Add(StringUtils::Format("%s: %i", g_localizeStrings.Get(563).c_str(), i)); dialog->SetSelected(m_albumItem->GetMusicInfoTag()->GetUserrating()); dialog->Open(); int iItem = dialog->GetSelectedItem(); if (iItem < 0) return; SetUserrating(iItem); } }
/// \brief Search the current directory for a string got from the virtual keyboard void CGUIWindowVideoInfo::OnSearch(CStdString& strSearch) { if (m_dlgProgress) { m_dlgProgress->SetHeading(194); m_dlgProgress->SetLine(0, strSearch); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); m_dlgProgress->Progress(); } CFileItemList items; DoSearch(strSearch, items); if (items.Size()) { CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)m_gWindowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); pDlgSelect->SetHeading(283); items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); for (int i = 0; i < (int)items.Size(); i++) { CFileItem* pItem = items[i]; pDlgSelect->Add(pItem->GetLabel()); } pDlgSelect->DoModal(); int iItem = pDlgSelect->GetSelectedLabel(); if (iItem < 0) { if (m_dlgProgress) m_dlgProgress->Close(); return ; } CFileItem* pSelItem = new CFileItem(*items[iItem]); OnSearchItemFound(pSelItem); delete pSelItem; if (m_dlgProgress) m_dlgProgress->Close(); } else { if (m_dlgProgress) m_dlgProgress->Close(); CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0); } }
void CGUIDialogMusicInfo::OnSetUserrating() const { CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (dialog) { // If we refresh and then try to set the rating there will be an items already here... dialog->Reset(); dialog->SetHeading(CVariant{ 38023 }); dialog->Add(g_localizeStrings.Get(38022)); for (int i = 1; i <= 10; i++) dialog->Add(StringUtils::Format("%s: %i", g_localizeStrings.Get(563).c_str(), i)); dialog->SetSelected(m_albumItem->GetMusicInfoTag()->GetUserrating()); dialog->Open(); int iItem = dialog->GetSelectedItem(); if (iItem < 0) return; SetUserrating(iItem); } }
/// \brief Search the current directory for a string got from the virtual keyboard void CGUIDialogVideoInfo::OnSearch(CStdString& strSearch) { CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(194); progress->SetLine(0, strSearch); progress->SetLine(1, ""); progress->SetLine(2, ""); progress->StartModal(); progress->Progress(); } CFileItemList items; DoSearch(strSearch, items); if (progress) progress->Close(); if (items.Size()) { CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); pDlgSelect->SetHeading(283); for (int i = 0; i < (int)items.Size(); i++) { CFileItemPtr pItem = items[i]; pDlgSelect->Add(pItem->GetLabel()); } pDlgSelect->DoModal(); int iItem = pDlgSelect->GetSelectedLabel(); if (iItem < 0) return; CFileItem* pSelItem = new CFileItem(*items[iItem]); OnSearchItemFound(pSelItem); delete pSelItem; } else { CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0); } }
void CGUIDialogSmartPlaylistRule::OnOperator() { const auto labels = GetValidOperators(m_rule); CGUIDialogSelect* dialog = g_windowManager.GetWindow<CGUIDialogSelect>(); dialog->Reset(); dialog->SetHeading(CVariant{ 16023 }); for (auto label : labels) dialog->Add(std::get<0>(label)); dialog->SetSelected(CSmartPlaylistRule::GetLocalizedOperator(m_rule.m_operator)); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed if (!dialog->IsConfirmed() || newSelected < 0) return; m_rule.m_operator = (CDatabaseQueryRule::SEARCH_OPERATOR)std::get<1>(labels[newSelected]); UpdateButtons(); }
bool CGUIViewState::ChooseSortMethod() { CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!dialog) return false; dialog->Reset(); dialog->SetHeading(CVariant{ 39010 }); // Label "Sort by" for (auto &sortMethod : m_sortMethods) dialog->Add(g_localizeStrings.Get(sortMethod.m_buttonLabel)); dialog->SetSelected(m_currentSortMethod); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == m_currentSortMethod) return false; m_currentSortMethod = newSelected; SaveViewState(); return true; }
/*! \brief Select and set a skin bool setting. * \param params The parameters. * \details params[0] = Names of skin settings. */ static int SelectBool(const std::vector<std::string>& params) { std::vector<std::pair<std::string, std::string>> settings; CGUIDialogSelect* pDlgSelect = g_windowManager.GetWindow<CGUIDialogSelect>(); pDlgSelect->Reset(); pDlgSelect->SetHeading(CVariant{g_localizeStrings.Get(atoi(params[0].c_str()))}); for (unsigned int i = 1 ; i < params.size() ; i++) { if (params[i].find('|') != std::string::npos) { std::vector<std::string> values = StringUtils::Split(params[i], '|'); std::string label = g_localizeStrings.Get(atoi(values[0].c_str())); settings.push_back(std::make_pair(label, values[1].c_str())); pDlgSelect->Add(label); } } pDlgSelect->Open(); if(pDlgSelect->IsConfirmed()) { unsigned int iItem = pDlgSelect->GetSelectedItem(); for (unsigned int i = 0 ; i < settings.size() ; i++) { std::string item = settings[i].second; int setting = CSkinSettings::GetInstance().TranslateBool(item); if (i == iItem) CSkinSettings::GetInstance().SetBool(setting, true); else CSkinSettings::GetInstance().SetBool(setting, false); } CServiceBroker::GetSettings().Save(); } return 0; }
bool CGUIDialogPVRChannelManager::OnClickButtonNewChannel() { int iSelection = 0; if (CServiceBroker::GetPVRManager().Clients()->CreatedClientAmount() > 1) { CGUIDialogSelect* pDlgSelect = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (!pDlgSelect) return false; pDlgSelect->SetHeading(CVariant{19213}); // Select Client for (const auto client : m_clientsWithSettingsList) pDlgSelect->Add(client->Name()); pDlgSelect->Open(); iSelection = pDlgSelect->GetSelectedItem(); } if (iSelection >= 0 && iSelection < (int)m_clientsWithSettingsList.size()) { int iClientID = m_clientsWithSettingsList[iSelection]->GetID(); CPVRChannelPtr channel(new CPVRChannel(m_bIsRadio)); channel->SetChannelName(g_localizeStrings.Get(19204)); // New channel channel->SetEPGEnabled(CServiceBroker::GetPVRManager().Clients()->GetClientCapabilities(iClientID).SupportsEPG()); channel->SetClientID(iClientID); PVR_ERROR ret = CServiceBroker::GetPVRManager().Clients()->OpenDialogChannelAdd(channel); if (ret == PVR_ERROR_NO_ERROR) Update(); else if (ret == PVR_ERROR_NOT_IMPLEMENTED) CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038}); // "Information", "Not supported by the PVR backend." else CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // "Add-on error", "Check the log for more information about this message." } return true; }
void CStereoscopicsManager::OnPlaybackStarted(void) { STEREOSCOPIC_PLAYBACK_MODE playbackMode = (STEREOSCOPIC_PLAYBACK_MODE) CSettings::Get().GetInt("videoplayer.stereoscopicplaybackmode"); RENDER_STEREO_MODE mode = GetStereoMode(); // early return if playback mode should be ignored and we're in no stereoscopic mode right now if (playbackMode == STEREOSCOPIC_PLAYBACK_MODE_IGNORE && mode == RENDER_STEREO_MODE_OFF) return; if (!g_infoManager.EvaluateBool("videoplayer.isstereoscopic")) { // exit stereo mode if started item is not stereoscopic // and if user prefers to stop 3D playback when movie is finished if (mode != RENDER_STEREO_MODE_OFF && CSettings::Get().GetBool("videoplayer.quitstereomodeonstop")) SetStereoMode(RENDER_STEREO_MODE_OFF); return; } // if we're not in stereomode yet, restore previously selected stereo mode in case it was user selected if (m_stereoModeSetByUser != RENDER_STEREO_MODE_UNDEFINED) { SetStereoMode(m_stereoModeSetByUser); return; } RENDER_STEREO_MODE preferred = GetPreferredPlaybackMode(); RENDER_STEREO_MODE playing = GetStereoModeOfPlayingVideo(); if (mode != RENDER_STEREO_MODE_OFF) { // don't change mode if user selected to not exit stereomode on playback stop // users selecting this option usually have to manually switch their TV into 3D mode // and would be annoyed by having to switch TV modes when next movies comes up // @todo probably add a new setting for just this behavior if (CSettings::Get().GetBool("videoplayer.quitstereomodeonstop") == false) return; // only change to new stereo mode if not yet in preferred stereo mode if (mode == preferred || (preferred == RENDER_STEREO_MODE_AUTO && mode == playing)) return; } switch (playbackMode) { case STEREOSCOPIC_PLAYBACK_MODE_ASK: // Ask { CApplicationMessenger::Get().MediaPause(); CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlgSelect->Reset(); pDlgSelect->SetHeading(CVariant{g_localizeStrings.Get(36527)}); int idx_playing = -1; // add choices int idx_preferred = pDlgSelect->Add(g_localizeStrings.Get(36524) // preferred + " (" + GetLabelForStereoMode(preferred) + ")"); int idx_mono = pDlgSelect->Add(GetLabelForStereoMode(RENDER_STEREO_MODE_MONO)); // mono / 2d if (playing != RENDER_STEREO_MODE_OFF && playing != preferred && preferred != RENDER_STEREO_MODE_AUTO && g_Windowing.SupportsStereo(playing)) // same as movie idx_playing = pDlgSelect->Add(g_localizeStrings.Get(36532) + " (" + GetLabelForStereoMode(playing) + ")"); int idx_select = pDlgSelect->Add( g_localizeStrings.Get(36531) ); // other / select pDlgSelect->Open(); if(pDlgSelect->IsConfirmed()) { int iItem = pDlgSelect->GetSelectedLabel(); if (iItem == idx_preferred) mode = preferred; else if (iItem == idx_mono) mode = RENDER_STEREO_MODE_MONO; else if (iItem == idx_playing) mode = RENDER_STEREO_MODE_AUTO; else if (iItem == idx_select) mode = GetStereoModeByUserChoice(); SetStereoModeByUser( mode ); } CApplicationMessenger::Get().MediaUnPause(); } break; case STEREOSCOPIC_PLAYBACK_MODE_PREFERRED: // Stereoscopic SetStereoMode( preferred ); break; case 2: // Mono SetStereoMode( RENDER_STEREO_MODE_MONO ); break; default: break; } }
bool CVideoLibraryRefreshingJob::Work(CVideoDatabase &db) { if (m_item == nullptr) return false; // determine the scraper for the item's path VIDEO::SScanSettings scanSettings; ADDON::ScraperPtr scraper = db.GetScraperForPath(m_item->GetPath(), scanSettings); if (scraper == nullptr) return false; // copy the scraper in case we need it again ADDON::ScraperPtr originalScraper(scraper); // get the item's correct title std::string itemTitle = m_searchTitle; if (itemTitle.empty()) itemTitle = m_item->GetMovieName(scanSettings.parent_name); CScraperUrl scraperUrl; VIDEO::CVideoInfoScanner scanner; bool needsRefresh = m_forceRefresh; bool hasDetails = false; bool ignoreNfo = m_ignoreNfo; // run this in a loop in case we need to refresh again bool failure = false; do { if (!ignoreNfo) { // check if there's an NFO for the item CNfoFile::NFOResult nfoResult = scanner.CheckForNFOFile(m_item.get(), scanSettings.parent_name_root, scraper, scraperUrl); // if there's no NFO remember it in case we have to refresh again if (nfoResult == CNfoFile::ERROR_NFO) ignoreNfo = true; else if (nfoResult != CNfoFile::NO_NFO) hasDetails = true; // if we are performing a forced refresh ask the user to choose between using a valid NFO and a valid scraper if (needsRefresh && IsModal() && !scraper->IsNoop() && (nfoResult == CNfoFile::URL_NFO || nfoResult == CNfoFile::COMBINED_NFO || nfoResult == CNfoFile::FULL_NFO)) { int heading = 20159; if (scraper->Content() == CONTENT_MOVIES) heading = 13346; else if (scraper->Content() == CONTENT_TVSHOWS) heading = m_item->m_bIsFolder ? 20351 : 20352; else if (scraper->Content() == CONTENT_MUSICVIDEOS) heading = 20393; if (CGUIDialogYesNo::ShowAndGetInput(heading, 20446)) { hasDetails = false; ignoreNfo = true; scraperUrl.Clear(); scraper = originalScraper; } } } // no need to re-fetch the episode guide for episodes if (scraper->Content() == CONTENT_TVSHOWS && !m_item->m_bIsFolder) hasDetails = true; // if we don't have an url or need to refresh anyway do the web search if (!hasDetails && (needsRefresh || scraperUrl.m_url.empty())) { SetTitle(StringUtils::Format(g_localizeStrings.Get(197).c_str(), scraper->Name().c_str())); SetText(itemTitle); SetProgress(0); // clear any cached data from the scraper scraper->ClearCache(); // create the info downloader for the scraper CVideoInfoDownloader infoDownloader(scraper); // try to find a matching item MOVIELIST itemResultList; int result = infoDownloader.FindMovie(itemTitle, itemResultList, GetProgressDialog()); // close the progress dialog MarkFinished(); if (result > 0) { // there are multiple matches for the item if (!itemResultList.empty()) { // choose the first match if (!IsModal()) scraperUrl = itemResultList.at(0); else { // ask the user what to do CGUIDialogSelect* selectDialog = static_cast<CGUIDialogSelect*>(g_windowManager.GetWindow(WINDOW_DIALOG_SELECT)); selectDialog->Reset(); selectDialog->SetHeading(scraper->Content() == CONTENT_TVSHOWS ? 20356 : 196); for (const auto& itemResult : itemResultList) selectDialog->Add(itemResult.strTitle); selectDialog->EnableButton(true, 413); // "Manual" selectDialog->Open(); // check if the user has chosen one of the results int selectedItem = selectDialog->GetSelectedItem(); if (selectedItem >= 0) scraperUrl = itemResultList.at(selectedItem); // the user hasn't chosen one of the results and but has chosen to manually enter a title to use else if (selectDialog->IsButtonPressed()) { // ask the user to input a title to use if (!CGUIKeyboardFactory::ShowAndGetInput(itemTitle, g_localizeStrings.Get(scraper->Content() == CONTENT_TVSHOWS ? 20357 : 16009), false)) return false; // go through the whole process again needsRefresh = true; continue; } // nothing else we can do else return false; } CLog::Log(LOGDEBUG, "CVideoLibraryRefreshingJob: user selected item '%s' with URL '%s'", scraperUrl.strTitle.c_str(), scraperUrl.m_url.at(0).m_url.c_str()); } } else if (result < 0 || !VIDEO::CVideoInfoScanner::DownloadFailed(GetProgressDialog())) { failure = true; break; } } // if the URL is still empty, check whether or not we're allowed // to prompt and ask the user to input a new search title if (!hasDetails && scraperUrl.m_url.empty()) { if (IsModal()) { // ask the user to input a title to use if (!CGUIKeyboardFactory::ShowAndGetInput(itemTitle, g_localizeStrings.Get(scraper->Content() == CONTENT_TVSHOWS ? 20357 : 16009), false)) return false; // go through the whole process again needsRefresh = true; continue; } // nothing else we can do failure = true; break; } // before we start downloading all the necessary information cleanup any existing artwork and hashes CTextureDatabase textureDb; if (textureDb.Open()) { for (const auto& artwork : m_item->GetArt()) textureDb.InvalidateCachedTexture(artwork.second); textureDb.Close(); } m_item->ClearArt(); // put together the list of items to refresh std::string path = m_item->GetPath(); CFileItemList items; if (m_item->HasVideoInfoTag() && m_item->GetVideoInfoTag()->m_iDbId > 0) { // for a tvshow we need to handle all paths of it std::vector<std::string> tvshowPaths; if (CMediaTypes::IsMediaType(m_item->GetVideoInfoTag()->m_type, MediaTypeTvShow) && m_refreshAll && db.GetPathsLinkedToTvShow(m_item->GetVideoInfoTag()->m_iDbId, tvshowPaths)) { for (const auto& tvshowPath : tvshowPaths) { CFileItemPtr tvshowItem(new CFileItem(*m_item->GetVideoInfoTag())); tvshowItem->SetPath(tvshowPath); items.Add(tvshowItem); } } // otherwise just add a copy of the item else items.Add(CFileItemPtr(new CFileItem(*m_item->GetVideoInfoTag()))); // update the path to the real path (instead of a videodb:// one) path = m_item->GetVideoInfoTag()->m_strPath; } else items.Add(CFileItemPtr(new CFileItem(*m_item))); // set the proper path of the list of items to lookup items.SetPath(m_item->m_bIsFolder ? URIUtils::GetParentPath(path) : URIUtils::GetDirectory(path)); int headingLabel = 198; if (scraper->Content() == CONTENT_TVSHOWS) { if (m_item->m_bIsFolder) headingLabel = 20353; else headingLabel = 20361; } else if (scraper->Content() == CONTENT_MUSICVIDEOS) headingLabel = 20394; // prepare the progress dialog for downloading all the necessary information SetTitle(g_localizeStrings.Get(headingLabel)); SetText(scraperUrl.strTitle); SetProgress(0); // remove any existing data for the item we're going to refresh if (m_item->GetVideoInfoTag()->m_iDbId > 0) { int dbId = m_item->GetVideoInfoTag()->m_iDbId; if (scraper->Content() == CONTENT_MOVIES) db.DeleteMovie(dbId); else if (scraper->Content() == CONTENT_MUSICVIDEOS) db.DeleteMusicVideo(dbId); else if (scraper->Content() == CONTENT_TVSHOWS) { if (!m_item->m_bIsFolder) db.DeleteEpisode(dbId); else if (m_refreshAll) db.DeleteTvShow(dbId); else db.DeleteDetailsForTvShow(dbId); } } // finally download the information for the item if (!scanner.RetrieveVideoInfo(items, scanSettings.parent_name, scraper->Content(), !ignoreNfo, &scraperUrl, m_refreshAll, GetProgressDialog())) { // something went wrong MarkFinished(); // check if the user cancelled if (!IsCancelled() && IsModal()) CGUIDialogOK::ShowAndGetInput(195, itemTitle); return false; } // retrieve the updated information from the database if (scraper->Content() == CONTENT_MOVIES) db.GetMovieInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); else if (scraper->Content() == CONTENT_MUSICVIDEOS) db.GetMusicVideoInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); else if (scraper->Content() == CONTENT_TVSHOWS) { // update tvshow info to get updated episode numbers if (m_item->m_bIsFolder) db.GetTvShowInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); else db.GetEpisodeInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); } // we're finally done MarkFinished(); break; } while (needsRefresh); if (failure && IsModal()) CGUIDialogOK::ShowAndGetInput(195, itemTitle); return true; }
bool CMusicInfoScanner::DownloadArtistInfo(const CStdString& strPath, const CStdString& strArtist, bool& bCanceled, CGUIDialogProgress* pDialog) { XFILE::MUSICDATABASEDIRECTORY::CQueryParams params; XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(strPath, params); bCanceled = false; CArtist artist; m_musicDatabase.Open(); if (m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info return true; // find artist info ADDON::ScraperPtr info; if (!m_musicDatabase.GetScraperForPath(strPath, info, ADDON::ADDON_SCRAPER_ARTISTS) || !info) { m_musicDatabase.Close(); return false; } if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20320), info->Name().c_str())); m_handle->SetText(strArtist); } // clear our scraper cache info->ClearCache(); CMusicInfoScraper scraper(info); // handle nfo files CStdString strArtistPath, strNfo; m_musicDatabase.GetArtistPath(params.GetArtistId(),strArtistPath); URIUtils::AddFileToFolder(strArtistPath,"artist.nfo",strNfo); CNfoFile::NFOResult result=CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); result = nfoReader.Create(strNfo, info); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); CArtist artist; nfoReader.GetDetails(artist); m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist); map<string, string> artwork = GetArtistArtwork(params.GetArtistId(), &artist); m_musicDatabase.SetArtForItem(params.GetArtistId(), "artist", artwork); m_musicDatabase.Close(); return true; } else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO) { CScraperUrl scrUrl(nfoReader.ScraperUrl()); CMusicArtistInfo artist("nfo",scrUrl); info = nfoReader.GetScraperInfo(); CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",info->Name().c_str()); CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str()); scraper.SetScraperInfo(info); scraper.GetArtists().push_back(artist); } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.GetArtistCount()) { scraper.FindArtistInfo(strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); bCanceled = true; } Sleep(1); } } int iSelectedArtist = 0; if (result == CNfoFile::NO_NFO) { if (scraper.Succeeded() && scraper.GetArtistCount() >= 1) { // now load the first match if (pDialog && scraper.GetArtistCount() > 1) { // if we found more then 1 album, let user choose one CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (pDlg) { pDlg->SetHeading(g_localizeStrings.Get(21890)); pDlg->Reset(); pDlg->EnableButton(true, 413); // manual for (int i = 0; i < scraper.GetArtistCount(); ++i) { // set the label to artist CFileItem item(scraper.GetArtist(i).GetArtist()); CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist; if (!scraper.GetArtist(i).GetArtist().strBorn.IsEmpty()) strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")"; if (!scraper.GetArtist(i).GetArtist().genre.empty()) { CStdString genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator); if (!genres.empty()) strTemp.Format("[%s] %s", genres.c_str(), strTemp.c_str()); } item.SetLabel(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) { bCanceled = true; return false; } // manual button pressed CStdString strNewArtist = strArtist; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false; if (pDialog) { pDialog->SetLine(0, strNewArtist); pDialog->Progress(); } m_musicDatabase.Close(); return DownloadArtistInfo(strPath,strNewArtist,bCanceled,pDialog); } iSelectedArtist = pDlg->GetSelectedItem()->m_idepth; } } } else { m_musicDatabase.Close(); return false; } } scraper.LoadArtistInfo(iSelectedArtist, strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); bCanceled = true; } Sleep(1); } if (scraper.Succeeded()) { artist = scraper.GetArtist(iSelectedArtist).GetArtist(); if (result == CNfoFile::COMBINED_NFO) nfoReader.GetDetails(artist,NULL,true); m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist); } // check thumb stuff map<string, string> artwork = GetArtistArtwork(params.GetArtistId(), &artist); m_musicDatabase.SetArtForItem(params.GetArtistId(), "artist", artwork); m_musicDatabase.Close(); return true; }
void CGUIDialogContentSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) { if (setting == NULL) return; CGUIDialogSettingsManualBase::OnSettingAction(setting); const std::string &settingId = setting->GetId(); if (settingId == SETTING_CONTENT_TYPE) { std::vector<std::pair<std::string, int>> labels; if (m_content == CONTENT_ALBUMS || m_content == CONTENT_ARTISTS) { labels.push_back(std::make_pair(ADDON::TranslateContent(m_content, true), m_content)); } else { labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_NONE, true), CONTENT_NONE)); labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_MOVIES, true), CONTENT_MOVIES)); labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_TVSHOWS, true), CONTENT_TVSHOWS)); labels.push_back(std::make_pair(ADDON::TranslateContent(CONTENT_MUSICVIDEOS, true), CONTENT_MUSICVIDEOS)); } std::sort(labels.begin(), labels.end()); CGUIDialogSelect *dialog = g_windowManager.GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); if (dialog) { dialog->SetHeading(CVariant{ 20344 }); //Label "This directory contains" int iIndex = 0; int iSelected = 0; for (const auto &label : labels) { dialog->Add(label.first); if (m_content == label.second) iSelected = iIndex; iIndex++; } dialog->SetSelected(iSelected); dialog->Open(); // Selected item has not changes - in case of cancel or the user selecting the same item int newSelected = dialog->GetSelectedItem(); if (!dialog->IsConfirmed() || newSelected < 0 || newSelected == iSelected) return; auto selected = labels.at(newSelected); m_content = static_cast<CONTENT_TYPE>(selected.second); AddonPtr scraperAddon; if (!CAddonSystemSettings::GetInstance().GetActive(ADDON::ScraperTypeFromContent(m_content), scraperAddon) && m_content != CONTENT_NONE) return; m_scraper = std::dynamic_pointer_cast<CScraper>(scraperAddon); SetupView(); SetFocus(SETTING_CONTENT_TYPE); } } else if (settingId == SETTING_SCRAPER_LIST) { ADDON::TYPE type = ADDON::ScraperTypeFromContent(m_content); std::string currentScraperId; if (m_scraper != nullptr) currentScraperId = m_scraper->ID(); std::string selectedAddonId = currentScraperId; if (CGUIWindowAddonBrowser::SelectAddonID(type, selectedAddonId, false) == 1 && selectedAddonId != currentScraperId) { AddonPtr scraperAddon; CServiceBroker::GetAddonMgr().GetAddon(selectedAddonId, scraperAddon); m_scraper = std::dynamic_pointer_cast<CScraper>(scraperAddon); SetupView(); SetFocus(SETTING_SCRAPER_LIST); } } else if (settingId == SETTING_SCRAPER_SETTINGS) CGUIDialogAddonSettings::ShowForAddon(m_scraper, false); }
bool CMusicInfoScanner::DownloadArtistInfo(const CStdString& strPath, const CStdString& strArtist, CGUIDialogProgress* pDialog) { DIRECTORY::MUSICDATABASEDIRECTORY::CQueryParams params; DIRECTORY::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(strPath, params); CArtist artist; m_musicDatabase.Open(); if (m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info return true; // find artist info SScraperInfo info; if (!m_musicDatabase.GetScraperForPath(strPath,info)) { m_musicDatabase.Close(); return false; } if (m_pObserver) { m_pObserver->OnStateChanged(DOWNLOADING_ARTIST_INFO); m_pObserver->OnDirectoryChanged(strArtist); } CMusicInfoScraper scraper(info); // handle nfo files CStdString strArtistPath, strNfo; m_musicDatabase.GetArtistPath(params.GetArtistId(),strArtistPath); CUtil::AddFileToFolder(strArtistPath,"artist.nfo",strNfo); if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); CNfoFile nfoReader("albums"); if (nfoReader.Create(strNfo) == S_OK) { if (nfoReader.m_strScraper == "NFO") { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); CArtist artist; nfoReader.GetDetails(artist); m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist); m_musicDatabase.Close(); return true; } else { CScraperUrl scrUrl(nfoReader.m_strImDbUrl); CMusicArtistInfo artist("nfo",scrUrl); scraper.GetArtists().push_back(artist); } } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.GetArtistCount()) scraper.FindArtistinfo(strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); break; } Sleep(1); } if (scraper.Successfull() && scraper.GetArtistCount() >= 1) { int iSelectedArtist = 0; // now load the first match if (pDialog && scraper.GetArtistCount() > 1) { // if we found more then 1 album, let user choose one CGUIDialogSelect *pDlg = (CGUIDialogSelect*)m_gWindowManager.GetWindow(WINDOW_DIALOG_SELECT); if (pDlg) { pDlg->SetHeading(g_localizeStrings.Get(21890)); pDlg->Reset(); pDlg->EnableButton(true); pDlg->SetButtonLabel(413); // manual for (int i = 0; i < scraper.GetArtistCount(); ++i) { // set the label to artist CFileItem item(scraper.GetArtist(i).GetArtist()); CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist; if (!scraper.GetArtist(i).GetArtist().strBorn.IsEmpty()) strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")"; if (!scraper.GetArtist(i).GetArtist().strGenre.IsEmpty()) strTemp.Format("[%s] %s",scraper.GetArtist(i).GetArtist().strGenre.c_str(),strTemp.c_str()); item.SetLabel(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) return false; // manual button pressed CStdString strNewArtist = strArtist; if (!CGUIDialogKeyboard::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false; if (pDialog) { pDialog->SetLine(0, strNewArtist); pDialog->Progress(); } m_musicDatabase.Close(); return DownloadArtistInfo(strPath,strArtist,pDialog); } iSelectedArtist = pDlg->GetSelectedItem().m_idepth; } } scraper.LoadArtistinfo(iSelectedArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); break; } Sleep(1); } if (scraper.Successfull()) { artist = scraper.GetArtist(iSelectedArtist).GetArtist(); m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist); } } else { m_musicDatabase.Close(); return false; } // check thumb stuff if (artist.thumbURL.m_url.size()) { CFileItem item(strArtist); CStdString thumb = item.GetCachedArtistThumb(); if (!XFILE::CFile::Exists(thumb)) CScraperUrl::DownloadThumbnail(thumb,artist.thumbURL.m_url[0]); } m_musicDatabase.Close(); return true; }
INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDON::ScraperPtr& info, MUSIC_GRABBER::CMusicArtistInfo& artistInfo, CGUIDialogProgress* pDialog) { if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20320).c_str(), info->Name().c_str())); m_handle->SetText(artist.strArtist); } // clear our scraper cache info->ClearCache(); CMusicInfoScraper scraper(info); bool bMusicBrainz = false; if (!artist.strMusicBrainzArtistID.empty()) { CScraperUrl musicBrainzURL; if (ResolveMusicBrainz(artist.strMusicBrainzArtistID, info, musicBrainzURL)) { CMusicArtistInfo artistNfo("nfo", musicBrainzURL); scraper.GetArtists().clear(); scraper.GetArtists().push_back(artistNfo); bMusicBrainz = true; } } // handle nfo files std::string path = artist.strPath; if (path.empty()) m_musicDatabase.GetArtistPath(artist.idArtist, path); std::string strNfo = URIUtils::AddFileToFolder(path, "artist.nfo"); CNfoFile::NFOResult result=CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); result = nfoReader.Create(strNfo, info); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); nfoReader.GetDetails(artistInfo.GetArtist()); return INFO_ADDED; } else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO) { CScraperUrl scrUrl(nfoReader.ScraperUrl()); CMusicArtistInfo artistNfo("nfo",scrUrl); ADDON::ScraperPtr nfoReaderScraper = nfoReader.GetScraperInfo(); CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",nfoReaderScraper->Name().c_str()); CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str()); scraper.SetScraperInfo(nfoReaderScraper); scraper.GetArtists().push_back(artistNfo); } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.GetArtistCount()) { scraper.FindArtistInfo(artist.strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } } int iSelectedArtist = 0; if (result == CNfoFile::NO_NFO && !bMusicBrainz) { if (scraper.GetArtistCount() >= 1) { // now load the first match if (pDialog && scraper.GetArtistCount() > 1) { // if we found more then 1 album, let user choose one CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (pDlg) { pDlg->SetHeading(g_localizeStrings.Get(21890)); pDlg->Reset(); pDlg->EnableButton(true, 413); // manual for (int i = 0; i < scraper.GetArtistCount(); ++i) { // set the label to artist CFileItem item(scraper.GetArtist(i).GetArtist()); std::string strTemp=scraper.GetArtist(i).GetArtist().strArtist; if (!scraper.GetArtist(i).GetArtist().strBorn.empty()) strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")"; if (!scraper.GetArtist(i).GetArtist().genre.empty()) { std::string genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator); if (!genres.empty()) strTemp = StringUtils::Format("[%s] %s", genres.c_str(), strTemp.c_str()); } item.SetLabel(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) return INFO_CANCELLED; // manual button pressed std::string strNewArtist = artist.strArtist; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; if (pDialog) { pDialog->SetLine(0, strNewArtist); pDialog->Progress(); } CArtist newArtist; newArtist.strArtist = strNewArtist; return DownloadArtistInfo(newArtist, info, artistInfo, pDialog); } iSelectedArtist = pDlg->GetSelectedItem()->m_idepth; } } } else return INFO_NOT_FOUND; } scraper.LoadArtistInfo(iSelectedArtist, artist.strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } if (!scraper.Succeeded()) return INFO_ERROR; artistInfo = scraper.GetArtist(iSelectedArtist); if (result == CNfoFile::COMBINED_NFO) nfoReader.GetDetails(artistInfo.GetArtist(), NULL, true); return INFO_ADDED; }
bool CGUIDialogPVRChannelManager::OnClickButtonNewChannel(CGUIMessage &message) { std::vector<long> clients; CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (!pDlgSelect) return false; pDlgSelect->SetHeading(19213); // Select Client pDlgSelect->Add(g_localizeStrings.Get(19209)); clients.push_back(PVR_VIRTUAL_CLIENT_ID); PVR_CLIENTMAP clientMap; if (g_PVRClients->GetConnectedClients(clientMap) > 0) { PVR_CLIENTMAP_ITR itr; for (itr = clientMap.begin() ; itr != clientMap.end(); itr++) { clients.push_back((*itr).first); pDlgSelect->Add((*itr).second->Name()); } } pDlgSelect->DoModal(); int selection = pDlgSelect->GetSelectedLabel(); if (selection >= 0 && selection <= (int) clients.size()) { int clientID = clients[selection]; if (clientID == PVR_VIRTUAL_CLIENT_ID) { CStdString strURL = ""; if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false)) { if (!strURL.empty()) { CPVRChannel *newchannel = new CPVRChannel(m_bIsRadio); newchannel->SetChannelName(g_localizeStrings.Get(19204)); newchannel->SetEPGEnabled(false); newchannel->SetVirtual(true); newchannel->SetStreamURL(strURL); newchannel->SetClientID(PVR_VIRTUAL_CLIENT_ID); if (g_PVRChannelGroups->CreateChannel(*newchannel)) g_PVRChannelGroups->GetGroupAll(m_bIsRadio)->Persist(); CFileItemPtr channel(new CFileItem(*newchannel)); if (channel) { channel->SetProperty("ActiveChannel", true); channel->SetProperty("Name", g_localizeStrings.Get(19204)); channel->SetProperty("UseEPG", false); channel->SetProperty("Icon", newchannel->IconPath()); channel->SetProperty("EPGSource", (int)0); channel->SetProperty("ClientName", g_localizeStrings.Get(19209)); channel->SetProperty("ParentalLocked", false); m_channelItems->AddFront(channel, m_iSelected); m_viewControl.SetItems(*m_channelItems); Renumber(); } } } } else { CGUIDialogOK::ShowAndGetInput(19033,19038,0,0); } } return true; }
INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON::ScraperPtr& info, CMusicAlbumInfo& albumInfo, CGUIDialogProgress* pDialog) { if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20321).c_str(), info->Name().c_str())); m_handle->SetText(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum); } // clear our scraper cache info->ClearCache(); CMusicInfoScraper scraper(info); bool bMusicBrainz = false; if (!album.strMusicBrainzAlbumID.empty()) { CScraperUrl musicBrainzURL; if (ResolveMusicBrainz(album.strMusicBrainzAlbumID, info, musicBrainzURL)) { CMusicAlbumInfo albumNfo("nfo", musicBrainzURL); scraper.GetAlbums().clear(); scraper.GetAlbums().push_back(albumNfo); bMusicBrainz = true; } } // handle nfo files std::string path = album.strPath; if (path.empty()) m_musicDatabase.GetAlbumPath(album.idAlbum, path); std::string strNfo = URIUtils::AddFileToFolder(path, "album.nfo"); CNfoFile::NFOResult result = CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); result = nfoReader.Create(strNfo, info); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); nfoReader.GetDetails(albumInfo.GetAlbum()); return INFO_ADDED; } else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO) { CScraperUrl scrUrl(nfoReader.ScraperUrl()); CMusicAlbumInfo albumNfo("nfo",scrUrl); ADDON::ScraperPtr nfoReaderScraper = nfoReader.GetScraperInfo(); CLog::Log(LOGDEBUG,"-- nfo-scraper: %s", nfoReaderScraper->Name().c_str()); CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str()); scraper.SetScraperInfo(nfoReaderScraper); scraper.GetAlbums().clear(); scraper.GetAlbums().push_back(albumNfo); } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.CheckValidOrFallback(CSettings::Get().GetString("musiclibrary.albumsscraper"))) { // the current scraper is invalid, as is the default - bail CLog::Log(LOGERROR, "%s - current and default scrapers are invalid. Pick another one", __FUNCTION__); return INFO_ERROR; } if (!scraper.GetAlbumCount()) { scraper.FindAlbumInfo(album.strAlbum, StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } } CGUIDialogSelect *pDlg = NULL; int iSelectedAlbum=0; if (result == CNfoFile::NO_NFO && !bMusicBrainz) { iSelectedAlbum = -1; // set negative so that we can detect a failure if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1) { double bestRelevance = 0; double minRelevance = THRESHOLD; if (scraper.GetAlbumCount() > 1) // score the matches { //show dialog with all albums found if (pDialog) { pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlg->SetHeading(g_localizeStrings.Get(181).c_str()); pDlg->Reset(); pDlg->EnableButton(true, 413); // manual } for (int i = 0; i < scraper.GetAlbumCount(); ++i) { CMusicAlbumInfo& info = scraper.GetAlbum(i); double relevance = info.GetRelevance(); if (relevance < 0) relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum, album.strAlbum, StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator), StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); // if we're doing auto-selection (ie querying all albums at once, then allow 95->100% for perfect matches) // otherwise, perfect matches only if (relevance >= max(minRelevance, bestRelevance)) { // we auto-select the best of these bestRelevance = relevance; iSelectedAlbum = i; } if (pDialog) { // set the label to [relevance] album - artist std::string strTemp = StringUtils::Format("[%0.2f] %s", relevance, info.GetTitle2().c_str()); CFileItem item(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } if (relevance > .99f) // we're so close, no reason to search further break; } if (pDialog && bestRelevance < THRESHOLD) { pDlg->Sort(false); pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) return INFO_CANCELLED; // manual button pressed std::string strNewAlbum = album.strAlbum; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return INFO_CANCELLED; if (strNewAlbum == "") return INFO_CANCELLED; std::string strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator); if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; pDialog->SetLine(0, strNewAlbum); pDialog->SetLine(1, strNewArtist); pDialog->Progress(); CAlbum newAlbum = album; newAlbum.strAlbum = strNewAlbum; newAlbum.artist = StringUtils::Split(strNewArtist, g_advancedSettings.m_musicItemSeparator); return DownloadAlbumInfo(newAlbum, info, albumInfo, pDialog); } iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth; } } else { CMusicAlbumInfo& info = scraper.GetAlbum(0); double relevance = info.GetRelevance(); if (relevance < 0) relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum, album.strAlbum, StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator), StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); if (relevance < THRESHOLD) return INFO_NOT_FOUND; iSelectedAlbum = 0; } } if (iSelectedAlbum < 0) return INFO_NOT_FOUND; } scraper.LoadAlbumInfo(iSelectedAlbum); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } if (!scraper.Succeeded()) return INFO_ERROR; albumInfo = scraper.GetAlbum(iSelectedAlbum); if (result == CNfoFile::COMBINED_NFO) nfoReader.GetDetails(albumInfo.GetAlbum(), NULL, true); return INFO_ADDED; }
void CPVRClients::ProcessMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat, const CFileItem *item) { // get client id if (iClientID < 0 && cat == PVR_MENUHOOK_SETTING) { PVR_CLIENTMAP clients; GetConnectedClients(clients); if (clients.size() == 1) { iClientID = clients.begin()->first; } else if (clients.size() > 1) { // have user select client CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(CVariant{19196}); PVR_CLIENTMAP_CITR itrClients; for (itrClients = clients.begin(); itrClients != clients.end(); itrClients++) { pDialog->Add(itrClients->second->GetBackendName()); } pDialog->Open(); int selection = pDialog->GetSelectedItem(); if (selection >= 0) { itrClients = clients.begin(); for (int i = 0; i < selection; i++) itrClients++; iClientID = itrClients->first; } } } if (iClientID < 0) iClientID = GetPlayingClientID(); PVR_CLIENT client; if (GetConnectedClient(iClientID, client) && client->HaveMenuHooks(cat)) { PVR_MENUHOOKS *hooks = client->GetMenuHooks(); std::vector<int> hookIDs; int selection = 0; CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetHeading(CVariant{19196}); for (unsigned int i = 0; i < hooks->size(); i++) if (hooks->at(i).category == cat || hooks->at(i).category == PVR_MENUHOOK_ALL) { pDialog->Add(g_localizeStrings.GetAddonString(client->ID(), hooks->at(i).iLocalizedStringId)); hookIDs.push_back(i); } if (hookIDs.size() > 1) { pDialog->Open(); selection = pDialog->GetSelectedItem(); } if (selection >= 0) client->CallMenuHook(hooks->at(hookIDs.at(selection)), item); } }