/*! \brief Progress callback from rar manager. \return true to continue processing, false to cancel. */ bool progress(int progress, const char *text) { bool cont(true); if ((shown || showTime.IsTimePast()) && g_application.IsCurrentThread()) { // grab the busy and show it CGUIDialogProgress* dlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (dlg) { if (!shown) { dlg->SetHeading(CVariant{heading}); dlg->Open(); } if (progress >= 0) { dlg->ShowProgressBar(true); dlg->SetPercentage(progress); } if (text) dlg->SetLine(1, CVariant{text}); cont = !dlg->IsCanceled(); shown = true; // tell render loop to spin dlg->Progress(); } } return cont; };
void CGUIWindowPVRBase::OnInitWindow(void) { if (!g_PVRManager.IsStarted() || !g_PVRClients->HasConnectedClients()) { // wait until the PVR manager has been started CGUIDialogProgress* dialog = static_cast<CGUIDialogProgress*>(g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS)); if (dialog) { dialog->SetHeading(CVariant{19235}); dialog->SetText(CVariant{19045}); dialog->ShowProgressBar(false); dialog->Open(); // do not block the gfx context while waiting CSingleExit exit(g_graphicsContext); CEvent event(true); while(!event.WaitMSec(1)) { if (g_PVRManager.IsStarted() && g_PVRClients->HasConnectedClients()) event.Set(); if (dialog->IsCanceled()) { // return to previous window if canceled dialog->Close(); g_windowManager.PreviousWindow(); return; } g_windowManager.ProcessRenderLoop(false); } dialog->Close(); } } { // set window group to playing group CPVRChannelGroupPtr group = g_PVRManager.GetPlayingGroup(m_bRadio); CSingleLock lock(m_critSection); if (m_group != group) m_viewControl.SetSelectedItem(0); m_group = group; } SetProperty("IsRadio", m_bRadio ? "true" : ""); m_vecItems->SetPath(GetDirectoryPath()); CGUIMediaWindow::OnInitWindow(); // mark item as selected by channel path m_viewControl.SetSelectedItem(GetSelectedItemPath(m_bRadio)); }
void CGUIDialogPVRChannelManager::SaveList(void) { if (!m_bContainsChanges) return; /* display the progress dialog */ CGUIDialogProgress* pDlgProgress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); pDlgProgress->SetHeading(CVariant{190}); pDlgProgress->SetLine(0, CVariant{""}); pDlgProgress->SetLine(1, CVariant{328}); pDlgProgress->SetLine(2, CVariant{""}); pDlgProgress->Open(); pDlgProgress->Progress(); pDlgProgress->SetPercentage(0); /* persist all channels */ unsigned int iNextChannelNumber(0); CPVRChannelGroupPtr group = CServiceBroker::GetPVRManager().ChannelGroups()->GetGroupAll(m_bIsRadio); if (!group) return; for (int iListPtr = 0; iListPtr < m_channelItems->Size(); ++iListPtr) { CFileItemPtr pItem = m_channelItems->Get(iListPtr); if (!pItem->HasPVRChannelInfoTag()) continue; if (pItem->GetProperty("SupportsSettings").asBoolean()) RenameChannel(pItem); PersistChannel(pItem, group, &iNextChannelNumber); pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size()); } group->SortAndRenumber(); group->Persist(); m_bContainsChanges = false; SetItemsUnchanged(); pDlgProgress->Close(); }
void CGUIWindowPVRSearch::OnPrepareFileItems(CFileItemList &items) { bool bAddSpecialSearchItem = items.IsEmpty(); if (m_bSearchConfirmed) { m_bSearchConfirmed = false; bAddSpecialSearchItem = true; CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (dlgProgress) { dlgProgress->SetHeading(CVariant{194}); // "Searching..." dlgProgress->SetText(CVariant{m_searchfilter.m_strSearchTerm}); dlgProgress->Open(); dlgProgress->Progress(); } // TODO should we limit the find similar search to the selected group? g_EpgContainer.GetEPGSearch(items, m_searchfilter); if (dlgProgress) dlgProgress->Close(); if (items.IsEmpty()) CGUIDialogOK::ShowAndGetInput(CVariant{194}, // "Searching..." CVariant{284}); // "No results found" } if (bAddSpecialSearchItem) { CFileItemPtr item(new CFileItem("pvr://guide/searchresults/search/", true)); item->SetLabel(g_localizeStrings.Get(19140)); // "Search..." item->SetLabelPreformated(true); item->SetSpecialSort(SortSpecialOnTop); items.Add(item); } }
void CMusicLibraryQueue::CleanLibrary(bool showDialog /* = false */) { CGUIDialogProgress* progress = NULL; if (showDialog) { progress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(CVariant{ 700 }); progress->SetPercentage(0); progress->Open(); progress->ShowProgressBar(true); } } CMusicLibraryCleaningJob* cleaningJob = new CMusicLibraryCleaningJob(progress); AddJob(cleaningJob); // Wait for cleaning to complete or be canceled, but render every 20ms so that the // pointer movements work on dialog even when cleaning is reporting progress infrequently if (progress) progress->Wait(20); }
void CMusicLibraryQueue::ExportLibrary(const CLibExportSettings& settings, bool showDialog /* = false */) { CGUIDialogProgress* progress = NULL; if (showDialog) { progress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(CVariant{ 20196 }); //"Export music library" progress->SetText(CVariant{ 650 }); //"Exporting" progress->SetPercentage(0); progress->Open(); progress->ShowProgressBar(true); } } CMusicLibraryExportJob* exportJob = new CMusicLibraryExportJob(settings, progress); if (showDialog) { AddJob(exportJob); // Wait for export to complete or be canceled, but render every 10ms so that the // pointer movements work on dialog even when export is reporting progress infrequently if (progress) progress->Wait(); } else { m_modal = true; exportJob->DoWork(); delete exportJob; m_modal = false; Refresh(); } }
void CMusicLibraryQueue::CleanLibraryModal() { // We can't perform a modal library cleaning if other jobs are running if (IsRunning()) return; CGUIDialogProgress* progress = nullptr; progress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(CVariant{ 700 }); progress->SetPercentage(0); progress->Open(); progress->ShowProgressBar(true); } m_modal = true; m_cleaning = true; CMusicLibraryCleaningJob cleaningJob(progress); cleaningJob.DoWork(); m_cleaning = false; m_modal = false; Refresh(); }
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */) { if (list < 0 || list >= 2) return ; bool bDeselect = SelectItem(list, item); // calculate the position for our menu float posX = 200; float posY = 100; const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list); if (pList) { posX = pList->GetXPosition() + pList->GetWidth() / 2; posY = pList->GetYPosition() + pList->GetHeight() / 2; } CFileItemPtr pItem = m_vecItems[list]->Get(item); if (!pItem.get()) return; if (m_Directory[list]->IsVirtualDirectoryRoot()) { if (item < 0) { // TODO: We should add the option here for shares to be added if there aren't any return ; } // and do the popup menu if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY)) { m_rootDir.SetSources(*CMediaSourceSettings::GetInstance().GetSources("files")); if (m_Directory[1 - list]->IsVirtualDirectoryRoot()) Refresh(); else Refresh(list); return ; } pItem->Select(false); return ; } // popup the context menu bool showEntry = false; if (item >= m_vecItems[list]->Size()) item = -1; if (item >= 0) showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0)); // determine available players std::vector<std::string>players; CPlayerCoreFactory::GetInstance().GetPlayers(*pItem, players); // add the needed buttons CContextButtons choices; if (item >= 0) { //The ".." item is not selectable. Take that into account when figuring out if all items are selected int notSelectable = CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_SHOWPARENTDIRITEMS) ? 1 : 0; if (NumSelected(list) < m_vecItems[list]->Size() - notSelectable) choices.Add(CONTROL_BTNSELECTALL, 188); // SelectAll if (!pItem->IsParentFolder()) choices.Add(CONTROL_BTNFAVOURITES, XFILE::CFavouritesDirectory::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite if (players.size() > 1) choices.Add(CONTROL_BTNPLAYWITH, 15213); if (CanRename(list) && !pItem->IsParentFolder()) choices.Add(CONTROL_BTNRENAME, 118); if (CanDelete(list) && showEntry) choices.Add(CONTROL_BTNDELETE, 117); if (CanCopy(list) && showEntry) choices.Add(CONTROL_BTNCOPY, 115); if (CanMove(list) && showEntry) choices.Add(CONTROL_BTNMOVE, 116); } if (CanNewFolder(list)) choices.Add(CONTROL_BTNNEWFOLDER, 20309); if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder()) choices.Add(CONTROL_BTNCALCSIZE, 13393); choices.Add(CONTROL_BTNGOTOROOT, 20128); choices.Add(CONTROL_BTNSWITCHMEDIA, 523); if (CJobManager::GetInstance().IsProcessing("filemanager")) choices.Add(CONTROL_BTNCANCELJOB, 167); int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices); if (btnid == CONTROL_BTNSELECTALL) { OnSelectAll(list); bDeselect=false; } if (btnid == CONTROL_BTNFAVOURITES) { XFILE::CFavouritesDirectory::AddOrRemove(pItem.get(), GetID()); return; } if (btnid == CONTROL_BTNPLAYWITH) { std::vector<std::string>players; CPlayerCoreFactory::GetInstance().GetPlayers(*pItem, players); std::string player = CPlayerCoreFactory::GetInstance().SelectPlayerDialog(players); if (!player.empty()) OnStart(pItem.get(), player); } if (btnid == CONTROL_BTNRENAME) OnRename(list); if (btnid == CONTROL_BTNDELETE) OnDelete(list); if (btnid == CONTROL_BTNCOPY) OnCopy(list); if (btnid == CONTROL_BTNMOVE) OnMove(list); if (btnid == CONTROL_BTNNEWFOLDER) OnNewFolder(list); if (btnid == CONTROL_BTNCALCSIZE) { // setup the progress dialog, and show it CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(CVariant{13394}); for (int i=0; i < 3; i++) progress->SetLine(i, CVariant{""}); progress->Open(); } // Calculate folder size for each selected item for (int i=0; i<m_vecItems[list]->Size(); ++i) { CFileItemPtr pItem2=m_vecItems[list]->Get(i); if (pItem2->m_bIsFolder && pItem2->IsSelected()) { int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress); if (folderSize >= 0) { pItem2->m_dwSize = folderSize; if (folderSize == 0) pItem2->SetLabel2(StringUtils::SizeToString(folderSize)); else pItem2->SetFileSizeLabel(); } } } if (progress) progress->Close(); } if (btnid == CONTROL_BTNGOTOROOT) { Update(list,""); return; } if (btnid == CONTROL_BTNSWITCHMEDIA) { CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath()); return; } if (btnid == CONTROL_BTNCANCELJOB) CancelJobs(); if (bDeselect && item >= 0 && item < m_vecItems[list]->Size()) { // deselect item as we didn't do anything pItem->Select(false); } }
bool CMultiPathDirectory::GetDirectory(const CURL& url, CFileItemList &items) { CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", url.GetRedacted().c_str()); std::vector<std::string> vecPaths; if (!GetPaths(url, vecPaths)) return false; XbmcThreads::EndTime progressTime(3000); // 3 seconds before showing progress bar CGUIDialogProgress* dlgProgress = NULL; unsigned int iFailures = 0; for (unsigned int i = 0; i < vecPaths.size(); ++i) { // show the progress dialog if we have passed our time limit if (progressTime.IsTimePast() && !dlgProgress) { dlgProgress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); if (dlgProgress) { dlgProgress->SetHeading(CVariant{15310}); dlgProgress->SetLine(0, CVariant{15311}); dlgProgress->SetLine(1, CVariant{""}); dlgProgress->SetLine(2, CVariant{""}); dlgProgress->Open(); dlgProgress->ShowProgressBar(true); dlgProgress->SetProgressMax((int)vecPaths.size()*2); dlgProgress->Progress(); } } if (dlgProgress) { CURL url(vecPaths[i]); dlgProgress->SetLine(1, CVariant{url.GetWithoutUserDetails()}); dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } CFileItemList tempItems; CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str()); if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_flags)) items.Append(tempItems); else { CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str()); iFailures++; } if (dlgProgress) { dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } } if (dlgProgress) dlgProgress->Close(); if (iFailures == vecPaths.size()) return false; // merge like-named folders into a sub multipath:// style url MergeItems(items); return true; }
void CPVRManager::ResetDatabase(bool bResetEPGOnly /* = false */) { CLog::Log(LOGNOTICE,"PVRManager - %s - clearing the PVR database", __FUNCTION__); g_EpgContainer.Stop(); CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); pDlgProgress->SetHeading(CVariant{313}); pDlgProgress->SetLine(0, CVariant{g_localizeStrings.Get(19187)}); // All data in the PVR database is being erased pDlgProgress->SetLine(1, CVariant{""}); pDlgProgress->SetLine(2, CVariant{""}); pDlgProgress->Open(); pDlgProgress->Progress(); if (m_addons->IsPlaying()) { CLog::Log(LOGNOTICE,"PVRManager - %s - stopping playback", __FUNCTION__); CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_STOP); } pDlgProgress->SetPercentage(10); pDlgProgress->Progress(); /* reset the EPG pointers */ if (m_database) m_database->ResetEPG(); /* stop the thread */ Stop(); pDlgProgress->SetPercentage(20); pDlgProgress->Progress(); if (!m_database) m_database = new CPVRDatabase; if (m_database && m_database->Open()) { /* clean the EPG database */ g_EpgContainer.Reset(); pDlgProgress->SetPercentage(30); pDlgProgress->Progress(); if (!bResetEPGOnly) { m_database->DeleteChannelGroups(); pDlgProgress->SetPercentage(50); pDlgProgress->Progress(); /* delete all channels */ m_database->DeleteChannels(); pDlgProgress->SetPercentage(70); pDlgProgress->Progress(); /* delete all channel and recording settings */ CVideoDatabase videoDatabase; if (videoDatabase.Open()) { videoDatabase.EraseVideoSettings("pvr://channels/"); videoDatabase.EraseVideoSettings(CPVRRecordingsPath::PATH_RECORDINGS); videoDatabase.Close(); } pDlgProgress->SetPercentage(80); pDlgProgress->Progress(); /* delete all client information */ pDlgProgress->SetPercentage(90); pDlgProgress->Progress(); } m_database->Close(); } CLog::Log(LOGNOTICE,"PVRManager - %s - %s database cleared", __FUNCTION__, bResetEPGOnly ? "EPG" : "PVR and EPG"); CLog::Log(LOGNOTICE,"PVRManager - %s - restarting the PVRManager", __FUNCTION__); m_database->Open(); Cleanup(); Start(); pDlgProgress->SetPercentage(100); pDlgProgress->Close(); }
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */) { if (list < 0 || list >= 2) return ; bool bDeselect = SelectItem(list, item); // calculate the position for our menu float posX = 200; float posY = 100; const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list); if (pList) { posX = pList->GetXPosition() + pList->GetWidth() / 2; posY = pList->GetYPosition() + pList->GetHeight() / 2; } CFileItemPtr pItem = m_vecItems[list]->Get(item); if (!pItem.get()) return; if (m_Directory[list]->IsVirtualDirectoryRoot()) { if (item < 0) { // TODO: We should add the option here for shares to be added if there aren't any return ; } // and do the popup menu if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY)) { m_rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files")); if (m_Directory[1 - list]->IsVirtualDirectoryRoot()) Refresh(); else Refresh(list); return ; } pItem->Select(false); return ; } // popup the context menu bool showEntry = false; if (item >= m_vecItems[list]->Size()) item = -1; if (item >= 0) showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0)); // determine available players VECPLAYERCORES vecCores; CPlayerCoreFactory::Get().GetPlayers(*pItem, vecCores); // add the needed buttons CContextButtons choices; if (item >= 0) { //The ".." item is not selectable. Take that into account when figuring out if all items are selected int notSelectable = CSettings::Get().GetBool("filelists.showparentdiritems") ? 1 : 0; if (NumSelected(list) < m_vecItems[list]->Size() - notSelectable) choices.Add(1, 188); // SelectAll if (!pItem->IsParentFolder()) choices.Add(2, XFILE::CFavouritesDirectory::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite if (vecCores.size() > 1) choices.Add(3, 15213); // Play Using... if (CanRename(list) && !pItem->IsParentFolder()) choices.Add(4, 118); // Rename if (CanDelete(list) && showEntry) choices.Add(5, 117); // Delete if (CanCopy(list) && showEntry) choices.Add(6, 115); // Copy if (CanMove(list) && showEntry) choices.Add(7, 116); // Move } if (CanNewFolder(list)) choices.Add(8, 20309); // New Folder if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder()) choices.Add(9, 13393); // Calculate Size choices.Add(11, 20128); // Go To Root choices.Add(12, 523); // switch media if (CJobManager::GetInstance().IsProcessing("filemanager")) choices.Add(13, 167); int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices); if (btnid == 1) { OnSelectAll(list); bDeselect=false; } if (btnid == 2) { XFILE::CFavouritesDirectory::AddOrRemove(pItem.get(), GetID()); return; } if (btnid == 3) { VECPLAYERCORES vecCores; CPlayerCoreFactory::Get().GetPlayers(*pItem, vecCores); g_application.m_eForcedNextPlayer = CPlayerCoreFactory::Get().SelectPlayerDialog(vecCores); if (g_application.m_eForcedNextPlayer != EPC_NONE) OnStart(pItem.get()); } if (btnid == 4) OnRename(list); if (btnid == 5) OnDelete(list); if (btnid == 6) OnCopy(list); if (btnid == 7) OnMove(list); if (btnid == 8) OnNewFolder(list); if (btnid == 9) { // setup the progress dialog, and show it CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (progress) { progress->SetHeading(CVariant{13394}); for (int i=0; i < 3; i++) progress->SetLine(i, CVariant{""}); progress->Open(); } // Calculate folder size for each selected item for (int i=0; i<m_vecItems[list]->Size(); ++i) { CFileItemPtr pItem2=m_vecItems[list]->Get(i); if (pItem2->m_bIsFolder && pItem2->IsSelected()) { int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress); if (folderSize >= 0) { pItem2->m_dwSize = folderSize; if (folderSize == 0) pItem2->SetLabel2(StringUtils::SizeToString(folderSize)); else pItem2->SetFileSizeLabel(); } } } if (progress) progress->Close(); } if (btnid == 11) { Update(list,""); return; } if (btnid == 12) { CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath()); return; } if (btnid == 13) CancelJobs(); if (bDeselect && item >= 0 && item < m_vecItems[list]->Size()) { // deselect item as we didn't do anything pItem->Select(false); } }
bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const std::string& strXspPath /*= ""*/) { // Filter using our PartyMode xml file CSmartPlaylist playlist; std::string partyModePath; bool playlistLoaded; m_bIsVideo = context == PARTYMODECONTEXT_VIDEO; if (!strXspPath.empty()) //if a path to a smartplaylist is supplied use it partyModePath = strXspPath; else if (m_bIsVideo) partyModePath = CProfilesManager::Get().GetUserDataItem("PartyMode-Video.xsp"); else partyModePath = CProfilesManager::Get().GetUserDataItem("PartyMode.xsp"); playlistLoaded=playlist.Load(partyModePath); if ( playlistLoaded ) { m_type = playlist.GetType(); if (context == PARTYMODECONTEXT_UNKNOWN) { //get it from the xsp file m_bIsVideo = (StringUtils::EqualsNoCase(m_type, "video") || StringUtils::EqualsNoCase(m_type, "musicvideos") || StringUtils::EqualsNoCase(m_type, "mixed")); } if (StringUtils::EqualsNoCase(m_type, "mixed")) playlist.SetType("songs"); if (StringUtils::EqualsNoCase(m_type, "mixed")) playlist.SetType("video"); playlist.SetType(m_type); } else { m_strCurrentFilterMusic.clear(); m_strCurrentFilterVideo.clear(); m_type = m_bIsVideo ? "musicvideos" : "songs"; } CGUIDialogProgress* pDialog = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); int iHeading = (m_bIsVideo ? 20250 : 20121); int iLine0 = (m_bIsVideo ? 20251 : 20123); pDialog->SetHeading(CVariant{iHeading}); pDialog->SetLine(0, CVariant{iLine0}); pDialog->SetLine(1, CVariant{""}); pDialog->SetLine(2, CVariant{""}); pDialog->Open(); ClearState(); unsigned int time = XbmcThreads::SystemClockMillis(); vector< pair<int,int> > songIDs; if (StringUtils::EqualsNoCase(m_type, "songs") || StringUtils::EqualsNoCase(m_type, "mixed")) { CMusicDatabase db; if (db.Open()) { set<std::string> playlists; if ( playlistLoaded ) m_strCurrentFilterMusic = playlist.GetWhereClause(db, playlists); CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterMusic.c_str()); m_iMatchingSongs = (int)db.GetSongIDs(m_strCurrentFilterMusic, songIDs); if (m_iMatchingSongs < 1 && StringUtils::EqualsNoCase(m_type, "songs")) { pDialog->Close(); db.Close(); OnError(16031, (std::string)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } db.Close(); } if (StringUtils::EqualsNoCase(m_type, "musicvideos") || StringUtils::EqualsNoCase(m_type, "mixed")) { vector< pair<int,int> > songIDs2; CVideoDatabase db; if (db.Open()) { set<std::string> playlists; if ( playlistLoaded ) m_strCurrentFilterVideo = playlist.GetWhereClause(db, playlists); CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterVideo.c_str()); m_iMatchingSongs += (int)db.GetMusicVideoIDs(m_strCurrentFilterVideo, songIDs2); if (m_iMatchingSongs < 1) { pDialog->Close(); db.Close(); OnError(16031, (std::string)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } db.Close(); songIDs.insert(songIDs.end(),songIDs2.begin(),songIDs2.end()); } // calculate history size if (m_iMatchingSongs < 50) m_songsInHistory = 0; else m_songsInHistory = (int)(m_iMatchingSongs/2); if (m_songsInHistory > 200) m_songsInHistory = 200; CLog::Log(LOGINFO,"PARTY MODE MANAGER: Matching songs = %i, History size = %i", m_iMatchingSongs, m_songsInHistory); CLog::Log(LOGINFO,"PARTY MODE MANAGER: Party mode enabled!"); int iPlaylist = m_bIsVideo ? PLAYLIST_VIDEO : PLAYLIST_MUSIC; g_playlistPlayer.ClearPlaylist(iPlaylist); g_playlistPlayer.SetShuffle(iPlaylist, false); g_playlistPlayer.SetRepeat(iPlaylist, PLAYLIST::REPEAT_NONE); pDialog->SetLine(0, CVariant{m_bIsVideo ? 20252 : 20124}); pDialog->Progress(); // add initial songs if (!AddInitialSongs(songIDs)) { pDialog->Close(); return false; } CLog::Log(LOGDEBUG, "%s time for song fetch: %u", __FUNCTION__, XbmcThreads::SystemClockMillis() - time); // start playing g_playlistPlayer.SetCurrentPlaylist(iPlaylist); Play(0); pDialog->Close(); // open now playing window if (StringUtils::EqualsNoCase(m_type, "songs")) { if (g_windowManager.GetActiveWindow() != WINDOW_MUSIC_PLAYLIST) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); } // done m_bEnabled = true; Announce(); return true; }
bool CPluginDirectory::WaitOnScriptResult(const std::string &scriptPath, int scriptId, const std::string &scriptName, bool retrievingDir) { const unsigned int timeBeforeProgressBar = 1500; const unsigned int timeToKillScript = 1000; unsigned int startTime = XbmcThreads::SystemClockMillis(); CGUIDialogProgress *progressBar = NULL; bool cancelled = false; bool inMainAppThread = g_application.IsCurrentThread(); CLog::Log(LOGDEBUG, "%s - waiting on the %s (id=%d) plugin...", __FUNCTION__, scriptName.c_str(), scriptId); while (true) { { CSingleExit ex(g_graphicsContext); // check if the python script is finished if (m_fetchComplete.WaitMSec(20)) { // python has returned CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure"); break; } } // check our script is still running if (!CScriptInvocationManager::Get().IsRunning(scriptId)) { // check whether we exited normally if (!m_fetchComplete.WaitMSec(0)) { // python didn't return correctly CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__); m_success = false; } break; } // check whether we should pop up the progress dialog if (!retrievingDir && !progressBar && XbmcThreads::SystemClockMillis() - startTime > timeBeforeProgressBar) { // loading takes more then 1.5 secs, show a progress dialog progressBar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); // if script has shown progressbar don't override it if (progressBar && progressBar->IsActive()) { startTime = XbmcThreads::SystemClockMillis(); progressBar = NULL; } if (progressBar) { progressBar->SetHeading(CVariant{scriptName}); progressBar->SetLine(0, CVariant{10214}); progressBar->SetLine(1, CVariant{""}); progressBar->SetLine(2, CVariant{""}); progressBar->ShowProgressBar(false); progressBar->Open(); } } if (progressBar) { // update the progress bar and check for user cancel progressBar->Progress(); if (progressBar->IsCanceled()) { // user has cancelled our process - cancel our process m_cancelled = true; } } else // if the progressBar exists and we call StartModal or Progress we get the // ProcessRenderLoop call anyway. if (inMainAppThread) g_windowManager.ProcessRenderLoop(); if (!cancelled && m_cancelled) { cancelled = true; startTime = XbmcThreads::SystemClockMillis(); } if ((cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript) || g_application.m_bStop) { // cancel our script if (scriptId != -1 && CScriptInvocationManager::Get().IsRunning(scriptId)) { CLog::Log(LOGDEBUG, "%s- cancelling plugin %s (id=%d)", __FUNCTION__, scriptName.c_str(), scriptId); CScriptInvocationManager::Get().Stop(scriptId); break; } } } if (progressBar) CApplicationMessenger::Get().PostMsg(TMSG_GUI_WINDOW_CLOSE, -1, 0, static_cast<void*>(progressBar)); return !cancelled && m_success; }
void CGUIDialogMusicInfo::RefreshInfo() { // Double check we have permission (button should be hidden when not) const CProfilesManager &profileManager = CServiceBroker::GetProfileManager(); if (!profileManager.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser) return; // Check if scanning if (g_application.IsMusicScanning()) { HELPERS::ShowOKDialogText(CVariant{ 189 }, CVariant{ 14057 }); return; } CGUIDialogProgress* dlgProgress = CServiceBroker::GetGUI()->GetWindowManager(). GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); if (!dlgProgress) return; if (m_bArtistInfo) { // Show dialog box indicating we're searching for the artist dlgProgress->SetHeading(CVariant{ 21889 }); dlgProgress->SetLine(0, CVariant{ m_artist.strArtist }); dlgProgress->SetLine(1, CVariant{ "" }); dlgProgress->SetLine(2, CVariant{ "" }); } else { // Show dialog box indicating we're searching for the album dlgProgress->SetHeading(CVariant{ 185 }); dlgProgress->SetLine(0, CVariant{ m_album.strAlbum }); dlgProgress->SetLine(1, CVariant{ m_album.strArtistDesc }); dlgProgress->SetLine(2, CVariant{ "" }); } dlgProgress->Open(); SetScrapedInfo(false); // Start separate job to scrape info and fill list of art types. CJobManager::GetInstance().AddJob(new CRefreshInfoJob(dlgProgress), nullptr, CJob::PRIORITY_HIGH); // Wait for refresh to complete or be canceled, but render every 10ms so that the // pointer movements works on dialog even when job is reporting progress infrequently if (dlgProgress) dlgProgress->Wait(10); if (dlgProgress->IsCanceled()) { return; } // Show message when scraper was unsuccesfull if (!HasScrapedInfo()) { if (m_bArtistInfo) HELPERS::ShowOKDialogText(CVariant{ 21889 }, CVariant{ 20199 }); else HELPERS::ShowOKDialogText(CVariant{ 185 }, CVariant{ 500 }); return; } // Show new values on screen Update(); m_hasRefreshed = true; if (dlgProgress) dlgProgress->Close(); }