void CGUIWindowMusicBase::OnPrepareFileItems(CFileItemList &items) { CGUIMediaWindow::OnPrepareFileItems(items); if (!items.IsMusicDb()) RetrieveMusicInfo(); }
bool CGUIWindowMusicBase::CheckFilterAdvanced(CFileItemList &items) { CStdString content = items.GetContent(); if (items.IsMusicDb() && (content.Equals("artists") || content.Equals("albums") || content.Equals("songs"))) return true; return false; }
bool CGUIWindowMusicBase::CheckFilterAdvanced(CFileItemList &items) const { std::string content = items.GetContent(); if ((items.IsMusicDb() || CanContainFilter(m_strFilterPath)) && (StringUtils::EqualsNoCase(content, "artists") || StringUtils::EqualsNoCase(content, "albums") || StringUtils::EqualsNoCase(content, "songs"))) return true; return false; }
void CGUIWindowMusicBase::OnRetrieveMusicInfo(CFileItemList& items) { if (items.GetFolderCount()==items.Size() || items.IsMusicDb() || (!g_guiSettings.GetBool("musicfiles.usetags") && !items.IsCDDA())) { return; } // Start the music info loader thread m_musicInfoLoader.SetProgressCallback(m_dlgProgress); m_musicInfoLoader.Load(items); bool bShowProgress=!m_gWindowManager.HasModalDialog(); bool bProgressVisible=false; DWORD dwTick=timeGetTime(); while (m_musicInfoLoader.IsLoading()) { if (bShowProgress) { // Do we have to init a progress dialog? DWORD dwElapsed=timeGetTime()-dwTick; if (!bProgressVisible && dwElapsed>1500 && m_dlgProgress) { // tag loading takes more then 1.5 secs, show a progress dialog CURL url(items.m_strPath); CStdString strStrippedPath; url.GetURLWithoutUserDetails(strStrippedPath); m_dlgProgress->SetHeading(189); m_dlgProgress->SetLine(0, 505); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, strStrippedPath ); m_dlgProgress->StartModal(); m_dlgProgress->ShowProgressBar(true); bProgressVisible = true; } if (bProgressVisible && m_dlgProgress && !m_dlgProgress->IsCanceled()) { // keep GUI alive m_dlgProgress->Progress(); } } // if (bShowProgress) Sleep(1); } // while (m_musicInfoLoader.IsLoading()) if (bProgressVisible && m_dlgProgress) m_dlgProgress->Close(); }
void CGUIWindowMusicBase::OnRetrieveMusicInfo(CFileItemList& items) { if (items.GetFolderCount()==items.Size() || items.IsMusicDb() || (!CSettings::Get().GetBool("musicfiles.usetags") && !items.IsCDDA())) { return; } // Start the music info loader thread m_musicInfoLoader.SetProgressCallback(m_dlgProgress); m_musicInfoLoader.Load(items); bool bShowProgress=!g_windowManager.HasModalDialog(); bool bProgressVisible=false; unsigned int tick=XbmcThreads::SystemClockMillis(); while (m_musicInfoLoader.IsLoading()) { if (bShowProgress) { // Do we have to init a progress dialog? unsigned int elapsed=XbmcThreads::SystemClockMillis()-tick; if (!bProgressVisible && elapsed>1500 && m_dlgProgress) { // tag loading takes more then 1.5 secs, show a progress dialog CURL url(items.GetPath()); std::string strStrippedPath = url.GetWithoutUserDetails(); m_dlgProgress->SetHeading(189); m_dlgProgress->SetLine(0, 505); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, strStrippedPath ); m_dlgProgress->StartModal(); m_dlgProgress->ShowProgressBar(true); bProgressVisible = true; } if (bProgressVisible && m_dlgProgress && !m_dlgProgress->IsCanceled()) { // keep GUI alive m_dlgProgress->Progress(); } } // if (bShowProgress) Sleep(1); } // while (m_musicInfoLoader.IsLoading()) if (bProgressVisible && m_dlgProgress) m_dlgProgress->Close(); }
void CGUIWindowMusicBase::OnRetrieveMusicInfo(CFileItemList& items) { if (items.GetFolderCount()==items.Size() || items.IsMusicDb() || (!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MUSICFILES_USETAGS) && !items.IsCDDA())) { return; } // Start the music info loader thread m_musicInfoLoader.SetProgressCallback(m_dlgProgress); m_musicInfoLoader.Load(items); bool bShowProgress=!g_windowManager.HasModalDialog(); bool bProgressVisible=false; unsigned int tick=XbmcThreads::SystemClockMillis(); while (m_musicInfoLoader.IsLoading()) { if (bShowProgress) { // Do we have to init a progress dialog? unsigned int elapsed=XbmcThreads::SystemClockMillis()-tick; if (!bProgressVisible && elapsed>1500 && m_dlgProgress) { // tag loading takes more then 1.5 secs, show a progress dialog CURL url(items.GetPath()); m_dlgProgress->SetHeading(CVariant{189}); m_dlgProgress->SetLine(0, CVariant{505}); m_dlgProgress->SetLine(1, CVariant{""}); m_dlgProgress->SetLine(2, CVariant{url.GetWithoutUserDetails()}); m_dlgProgress->Open(); m_dlgProgress->ShowProgressBar(true); bProgressVisible = true; } if (bProgressVisible && m_dlgProgress && !m_dlgProgress->IsCanceled()) { // keep GUI alive m_dlgProgress->Progress(); } } // if (bShowProgress) Sleep(1); } // while (m_musicInfoLoader.IsLoading()) if (bProgressVisible && m_dlgProgress) m_dlgProgress->Close(); }
bool CGUIWindowMusicNav::GetDirectory(const CStdString &strDirectory, CFileItemList &items) { if (m_bDisplayEmptyDatabaseMessage) return true; if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); bool bResult = CGUIWindowMusicBase::GetDirectory(strDirectory, items); if (bResult) { if (items.IsPlayList()) OnRetrieveMusicInfo(items); if (!items.IsMusicDb()) { items.SetCachedMusicThumbs(); m_thumbLoader.Load(*m_vecItems); } } // update our content in the info manager if (strDirectory.Left(10).Equals("videodb://")) { CVideoDatabaseDirectory dir; VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(strDirectory); if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS) items.SetContent("musicvideos"); } else if (items.GetContent().IsEmpty()) { CMusicDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(strDirectory); if (node == NODE_TYPE_ALBUM) items.SetContent("albums"); else if (node == NODE_TYPE_ARTIST) items.SetContent("artists"); else if (node == NODE_TYPE_SONG) items.SetContent("songs"); } // clear the filter m_filter.Empty(); return bResult; }
bool CGUIWindowMusicNav::GetDirectory(const CStdString &strDirectory, CFileItemList &items) { if (m_bDisplayEmptyDatabaseMessage) return true; if (strDirectory.IsEmpty()) AddSearchFolder(); if (m_thumbLoader.IsLoading()) m_thumbLoader.StopThread(); bool bResult = CGUIWindowMusicBase::GetDirectory(strDirectory, items); if (bResult) { if (items.IsPlayList()) OnRetrieveMusicInfo(items); if (!items.IsMusicDb()) { items.SetCachedMusicThumbs(); m_thumbLoader.Load(*m_vecItems); } } // update our content in the info manager if (strDirectory.Left(10).Equals("videodb://")) { CVideoDatabaseDirectory dir; VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(strDirectory); if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS) items.SetContent("musicvideos"); } else if (strDirectory.Left(10).Equals("musicdb://")) { CMusicDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(strDirectory); if (node == NODE_TYPE_ALBUM || node == NODE_TYPE_ALBUM_RECENTLY_ADDED || node == NODE_TYPE_ALBUM_RECENTLY_PLAYED || node == NODE_TYPE_ALBUM_TOP100 || node == NODE_TYPE_ALBUM_COMPILATIONS || node == NODE_TYPE_YEAR_ALBUM) items.SetContent("albums"); else if (node == NODE_TYPE_ARTIST) items.SetContent("artists"); else if (node == NODE_TYPE_SONG || node == NODE_TYPE_SONG_TOP100 || node == NODE_TYPE_SINGLES) items.SetContent("songs"); else if (node == NODE_TYPE_GENRE) items.SetContent("genres"); else if (node == NODE_TYPE_YEAR) items.SetContent("years"); } else if (strDirectory.Equals("special://musicplaylists")) items.SetContent("playlists"); else if (strDirectory.Equals("plugin://music/")) items.SetContent("plugins"); else if (items.IsPlayList()) items.SetContent("songs"); return bResult; }
bool CDirectory::GetDirectory(const CURL& url, CFileItemList &items, const CHints &hints, bool allowThreads) { try { CURL realURL = URIUtils::SubstitutePath(url); std::shared_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL)); if (!pDirectory.get()) return false; // check our cache for this path if (g_directoryCache.GetDirectory(realURL.Get(), items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE)) items.SetURL(url); else { // need to clear the cache (in case the directory fetch fails) // and (re)fetch the folder if (!(hints.flags & DIR_FLAG_BYPASS_CACHE)) g_directoryCache.ClearDirectory(realURL.Get()); pDirectory->SetFlags(hints.flags); bool result = false, cancel = false; while (!result && !cancel) { const std::string pathToUrl(url.Get()); if (g_application.IsCurrentThread() && allowThreads && !URIUtils::IsSpecial(pathToUrl)) { CSingleExit ex(g_graphicsContext); CGetDirectory get(pDirectory, realURL, url); if(!get.Wait(TIME_TO_BUSY_DIALOG)) { CGUIDialogBusy* dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); if (dialog) { dialog->Open(); while(!get.Wait(10)) { CSingleLock lock(g_graphicsContext); // update progress float progress = pDirectory->GetProgress(); if (progress > 0) dialog->SetProgress(progress); if (dialog->IsCanceled()) { cancel = true; pDirectory->CancelDirectory(); break; } lock.Leave(); // prevent an occasional deadlock on exit g_windowManager.ProcessRenderLoop(false); } dialog->Close(); } } result = get.GetDirectory(items); } else { items.SetURL(url); result = pDirectory->GetDirectory(realURL, items); } if (!result) { if (!cancel && g_application.IsCurrentThread() && pDirectory->ProcessRequirements()) continue; CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, url.GetRedacted().c_str()); return false; } } // cache the directory, if necessary if (!(hints.flags & DIR_FLAG_BYPASS_CACHE)) g_directoryCache.SetDirectory(realURL.Get(), items, pDirectory->GetCacheType(url)); } // now filter for allowed files if (!pDirectory->AllowAll()) { pDirectory->SetMask(hints.mask); for (int i = 0; i < items.Size(); ++i) { CFileItemPtr item = items[i]; if (!item->m_bIsFolder && !pDirectory->IsAllowed(item->GetURL())) { items.Remove(i); i--; // don't confuse loop } } } // filter hidden files // TODO: we shouldn't be checking the gui setting here, callers should use getHidden instead if (!CSettings::Get().GetBool("filelists.showhidden") && !(hints.flags & DIR_FLAG_GET_HIDDEN)) { for (int i = 0; i < items.Size(); ++i) { if (items[i]->GetProperty("file:hidden").asBoolean()) { items.Remove(i); i--; // don't confuse loop } } } // Should any of the files we read be treated as a directory? // Disable for database folders, as they already contain the extracted items if (!(hints.flags & DIR_FLAG_NO_FILE_DIRS) && !items.IsMusicDb() && !items.IsVideoDb() && !items.IsSmartPlayList()) FilterFileDirectories(items, hints.mask); // Correct items for path substitution const std::string pathToUrl(url.Get()); const std::string pathToUrl2(realURL.Get()); if (pathToUrl != pathToUrl2) { for (int i = 0; i < items.Size(); ++i) { CFileItemPtr item = items[i]; item->SetPath(URIUtils::SubstitutePath(item->GetPath(), true)); } } return true; } XBMCCOMMONS_HANDLE_UNCHECKED catch (...) { CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__); } CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, url.GetRedacted().c_str()); return false; }
bool CGUIWindowMusicNav::GetDirectory(const std::string &strDirectory, CFileItemList &items) { if (m_bDisplayEmptyDatabaseMessage) return true; if (strDirectory.empty()) AddSearchFolder(); bool bResult = CGUIWindowMusicBase::GetDirectory(strDirectory, items); if (bResult) { if (items.IsPlayList()) OnRetrieveMusicInfo(items); } // update our content in the info manager if (StringUtils::StartsWithNoCase(strDirectory, "videodb://") || items.IsVideoDb()) { CVideoDatabaseDirectory dir; VIDEODATABASEDIRECTORY::NODE_TYPE node = dir.GetDirectoryChildType(strDirectory); if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_MUSICVIDEOS || node == VIDEODATABASEDIRECTORY::NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS) items.SetContent("musicvideos"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_GENRE) items.SetContent("genres"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_COUNTRY) items.SetContent("countries"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_ACTOR) items.SetContent("artists"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_DIRECTOR) items.SetContent("directors"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_STUDIO) items.SetContent("studios"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_YEAR) items.SetContent("years"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_MUSICVIDEOS_ALBUM) items.SetContent("albums"); else if (node == VIDEODATABASEDIRECTORY::NODE_TYPE_TAGS) items.SetContent("tags"); } else if (StringUtils::StartsWithNoCase(strDirectory, "musicdb://") || items.IsMusicDb()) { CMusicDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(strDirectory); if (node == NODE_TYPE_ALBUM || node == NODE_TYPE_ALBUM_RECENTLY_ADDED || node == NODE_TYPE_ALBUM_RECENTLY_PLAYED || node == NODE_TYPE_ALBUM_TOP100 || node == NODE_TYPE_ALBUM_COMPILATIONS || node == NODE_TYPE_YEAR_ALBUM) items.SetContent("albums"); else if (node == NODE_TYPE_ARTIST) items.SetContent("artists"); else if (node == NODE_TYPE_SONG || node == NODE_TYPE_SONG_TOP100 || node == NODE_TYPE_SINGLES || node == NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS || node == NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS || node == NODE_TYPE_ALBUM_COMPILATIONS_SONGS || node == NODE_TYPE_ALBUM_TOP100_SONGS || node == NODE_TYPE_YEAR_SONG) items.SetContent("songs"); else if (node == NODE_TYPE_GENRE) items.SetContent("genres"); else if (node == NODE_TYPE_YEAR) items.SetContent("years"); } else if (URIUtils::PathEquals(strDirectory, "special://musicplaylists/")) items.SetContent("playlists"); else if (URIUtils::PathEquals(strDirectory, "plugin://music/")) items.SetContent("plugins"); else if (items.IsPlayList()) items.SetContent("songs"); return bResult; }
bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, CStdString strMask /*=""*/, bool bUseFileDirectories /* = true */, bool allowPrompting /* = false */, DIR_CACHE_TYPE cacheDirectory /* = DIR_CACHE_NEVER */, bool extFileInfo /* = true */) { try { auto_ptr<IDirectory> pDirectory(CFactoryDirectory::Create(strPath)); if (!pDirectory.get()) return false; // check our cache for this path if (g_directoryCache.GetDirectory(strPath, items, cacheDirectory == DIR_CACHE_ALWAYS)) items.m_strPath = strPath; else { // need to clear the cache (in case the directory fetch fails) // and (re)fetch the folder if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.ClearDirectory(strPath); pDirectory->SetAllowPrompting(allowPrompting); pDirectory->SetCacheDirectory(cacheDirectory); pDirectory->SetUseFileDirectories(bUseFileDirectories); pDirectory->SetExtFileInfo(extFileInfo); items.m_strPath = strPath; if (!pDirectory->GetDirectory(strPath, items)) { CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; } // cache the directory, if necessary if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.SetDirectory(strPath, items, pDirectory->GetCacheType(strPath)); } // now filter for allowed files pDirectory->SetMask(strMask); for (int i = 0; i < items.Size(); ++i) { CFileItemPtr item = items[i]; if ((!item->m_bIsFolder && !pDirectory->IsAllowed(item->m_strPath)) || (item->GetPropertyBOOL("file:hidden") && !g_guiSettings.GetBool("filelists.showhidden"))) { items.Remove(i); i--; // don't confuse loop } } // Should any of the files we read be treated as a directory? // Disable for database folders, as they already contain the extracted items if (bUseFileDirectories && !items.IsMusicDb() && !items.IsVideoDb() && !items.IsSmartPlayList()) { for (int i=0; i< items.Size(); ++i) { CFileItemPtr pItem=items[i]; if ((!pItem->m_bIsFolder) && (!pItem->IsInternetStream())) { auto_ptr<IFileDirectory> pDirectory(CFactoryFileDirectory::Create(pItem->m_strPath,pItem.get(),strMask)); if (pDirectory.get()) pItem->m_bIsFolder = true; else if (pItem->m_bIsFolder) { items.Remove(i); i--; // don't confuse loop } } } } return true; } #ifndef _LINUX catch (const win32_exception &e) { e.writelog(__FUNCTION__); } #endif catch (...) { CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__); } CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; }
bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, CStdString strMask /*=""*/, bool bUseFileDirectories /* = true */, bool allowPrompting /* = false */, DIR_CACHE_TYPE cacheDirectory /* = DIR_CACHE_ONCE */, bool extFileInfo /* = true */, bool allowThreads /* = false */, bool getHidden /* = false */) { try { CStdString realPath = URIUtils::SubstitutePath(strPath); boost::shared_ptr<IDirectory> pDirectory(CFactoryDirectory::Create(realPath)); if (!pDirectory.get()) return false; // check our cache for this path if (g_directoryCache.GetDirectory(strPath, items, cacheDirectory == DIR_CACHE_ALWAYS)) items.SetPath(strPath); else { // need to clear the cache (in case the directory fetch fails) // and (re)fetch the folder if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.ClearDirectory(strPath); pDirectory->SetAllowPrompting(allowPrompting); pDirectory->SetCacheDirectory(cacheDirectory); pDirectory->SetUseFileDirectories(bUseFileDirectories); pDirectory->SetExtFileInfo(extFileInfo); bool result = false, cancel = false; while (!result && !cancel) { if (g_application.IsCurrentThread() && allowThreads && !URIUtils::IsSpecial(strPath)) { CSingleExit ex(g_graphicsContext); CGetDirectory get(pDirectory, realPath); if(!get.Wait(TIME_TO_BUSY_DIALOG)) { CGUIDialogBusy* dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); dialog->Show(); while(!get.Wait(10)) { CSingleLock lock(g_graphicsContext); if(dialog->IsCanceled()) { cancel = true; break; } g_windowManager.ProcessRenderLoop(false); } if(dialog) dialog->Close(); } result = get.GetDirectory(items); } else { items.SetPath(strPath); result = pDirectory->GetDirectory(realPath, items); } if (!result) { if (!cancel && g_application.IsCurrentThread() && pDirectory->ProcessRequirements()) continue; CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; } } // cache the directory, if necessary if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.SetDirectory(strPath, items, pDirectory->GetCacheType(strPath)); } // now filter for allowed files pDirectory->SetMask(strMask); for (int i = 0; i < items.Size(); ++i) { CFileItemPtr item = items[i]; // TODO: we shouldn't be checking the gui setting here; // callers should use getHidden instead if ((!item->m_bIsFolder && !pDirectory->IsAllowed(item->GetPath())) || (item->GetPropertyBOOL("file:hidden") && !getHidden && !g_guiSettings.GetBool("filelists.showhidden"))) { items.Remove(i); i--; // don't confuse loop } } // Should any of the files we read be treated as a directory? // Disable for database folders, as they already contain the extracted items if (bUseFileDirectories && !items.IsMusicDb() && !items.IsVideoDb() && !items.IsSmartPlayList()) FilterFileDirectories(items, strMask); return true; } #ifndef _LINUX catch (const win32_exception &e) { e.writelog(__FUNCTION__); } #endif catch (...) { CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__); } CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; }