Permalink
Browse files

add flags for the music scanner instead of reading guisettings intern…

…ally
  • Loading branch information...
1 parent 33471ba commit 44a0f685b1325775e64f15b7e201efb675882be7 Jonathan Marshall committed Jul 6, 2012
View
@@ -5548,12 +5548,20 @@ void CApplication::StartVideoScan(const CStdString &strDirectory, bool scanAll)
m_videoInfoScanner->Start(strDirectory,scanAll);
}
-void CApplication::StartMusicScan(const CStdString &strDirectory)
+void CApplication::StartMusicScan(const CStdString &strDirectory, int flags)
{
if (m_musicInfoScanner->IsScanning())
return;
- if (!g_guiSettings.GetBool("musiclibrary.backgroundupdate"))
+ if (!flags)
+ { // setup default flags
+ if (g_guiSettings.GetBool("musiclibrary.downloadinfo"))
+ flags |= CMusicInfoScanner::SCAN_ONLINE;
+ if (g_guiSettings.GetBool("musiclibrary.backgroundupdate"))
+ flags |= CMusicInfoScanner::SCAN_BACKGROUND;
+ }
+
+ if (!(flags & CMusicInfoScanner::SCAN_BACKGROUND))
{
CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN);
if (musicScan)
@@ -5563,7 +5571,7 @@ void CApplication::StartMusicScan(const CStdString &strDirectory)
}
}
SaveMusicScanSettings();
- m_musicInfoScanner->Start(strDirectory);
+ m_musicInfoScanner->Start(strDirectory, flags);
}
void CApplication::StartMusicAlbumScan(const CStdString& strDirectory,
View
@@ -230,7 +230,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
void StartVideoCleanup();
void StartVideoScan(const CStdString &path, bool scanAll = false);
- void StartMusicScan(const CStdString &path);
+ void StartMusicScan(const CStdString &path, int flags = 0);
void StartMusicAlbumScan(const CStdString& strDirectory, bool refresh=false);
void StartMusicArtistScan(const CStdString& strDirectory, bool refresh=false);
@@ -65,6 +65,7 @@ CMusicInfoScanner::CMusicInfoScanner() : CThread("CMusicInfoScanner")
m_bCanInterrupt = false;
m_currentItem=0;
m_itemCount=0;
+ m_flags = 0;
}
CMusicInfoScanner::~CMusicInfoScanner()
@@ -205,11 +206,12 @@ void CMusicInfoScanner::Process()
m_pObserver->OnFinished();
}
-void CMusicInfoScanner::Start(const CStdString& strDirectory)
+void CMusicInfoScanner::Start(const CStdString& strDirectory, int flags)
{
m_pathsToScan.clear();
m_albumsScanned.clear();
m_artistsScanned.clear();
+ m_flags = flags;
if (strDirectory.IsEmpty())
{ // scan all paths in the database. We do this by scanning all paths in the db, and crossing them off the list as
@@ -565,7 +567,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
{
CStdString strArtist = m_musicDatabase.GetArtistById(*it);
m_artistsScanned.push_back(*it);
- if (!m_bStop && g_guiSettings.GetBool("musiclibrary.downloadinfo"))
+ if (!m_bStop && (m_flags & SCAN_ONLINE))
{
CStdString strPath;
strPath.Format("musicdb://2/%u/", *it);
@@ -581,7 +583,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
}
}
- if (g_guiSettings.GetBool("musiclibrary.downloadinfo"))
+ if (m_flags & SCAN_ONLINE)
{
for (set<long>::iterator it = albumsToScan.begin(); it != albumsToScan.end(); ++it)
{
@@ -44,10 +44,16 @@ class IMusicInfoScannerObserver
class CMusicInfoScanner : CThread, public IRunnable
{
public:
+ /*! \brief Flags for controlling the scanning process
+ */
+ enum SCAN_FLAGS { SCAN_NORMAL = 0,
+ SCAN_ONLINE = 1 << 0,
+ SCAN_BACKGROUND = 1 << 1 };
+
CMusicInfoScanner();
virtual ~CMusicInfoScanner();
- void Start(const CStdString& strDirectory);
+ void Start(const CStdString& strDirectory, int flags);
void FetchAlbumInfo(const CStdString& strDirectory, bool refresh=false);
void FetchArtistInfo(const CStdString& strDirectory, bool refresh=false);
bool IsScanning();
@@ -126,5 +132,6 @@ class CMusicInfoScanner : CThread, public IRunnable
std::set<CStdString> m_pathsToCount;
std::vector<long> m_artistsScanned;
std::vector<long> m_albumsScanned;
+ int m_flags;
};
}

0 comments on commit 44a0f68

Please sign in to comment.