Merge pull request #26350 from jjd-uk/estuary_media_align
[xbmc.git] / xbmc / music / MusicLibraryQueue.h
blob9e521418d9fda9006618083a8cfa1b53bf064f5f
1 /*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "settings/LibExportSettings.h"
12 #include "threads/CriticalSection.h"
13 #include "utils/JobManager.h"
15 #include <map>
16 #include <set>
18 class CGUIDialogProgressBarHandle;
19 class CMusicLibraryJob;
20 class CGUIDialogProgress;
22 /*!
23 \brief Queue for music library jobs.
25 The queue can only process a single job at any time and every job will be
26 executed at the lowest priority.
28 class CMusicLibraryQueue : protected CJobQueue
30 public:
31 ~CMusicLibraryQueue() override;
33 /*!
34 \brief Gets the singleton instance of the music library queue.
36 static CMusicLibraryQueue& GetInstance();
38 /*!
39 \brief Enqueue a music library export job.
40 \param[in] settings Library export settings
41 \param[in] showDialog Show a progress dialog while (asynchronously) exporting, otherwise export in synchronous
43 void ExportLibrary(const CLibExportSettings& settings, bool showDialog = false);
45 /*!
46 \brief Enqueue a music library import job.
47 \param[in] xmlFile xml file to import
48 \param[in] showDialog Show a progress dialog while (asynchronously) exporting, otherwise export in synchronous
50 void ImportLibrary(const std::string& xmlFile, bool showDialog = false);
52 /*!
53 \brief Enqueue a music library update job, scanning tags embedded in music files and optionally scraping additional data.
54 \param[in] strDirectory Directory to scan or "" (empty string) for a global scan.
55 \param[in] flags Flags for controlling the scanning process. See xbmc/music/infoscanner/MusicInfoScanner.h for possible values.
56 \param[in] showProgress Whether or not to show a progress dialog. Defaults to true
58 void ScanLibrary(const std::string& strDirectory, int flags = 0, bool showProgress = true);
60 /*!
61 \brief Enqueue an album scraping job fetching additional album data.
62 \param[in] strDirectory Virtual path that identifies which albums to process or "" (empty string) for all albums
63 \param[in] refresh Whether or not to refresh data for albums that have previously been scraped
65 void StartAlbumScan(const std::string& strDirectory, bool refresh = false);
67 /*!
68 \brief Enqueue an artist scraping job fetching additional artist data.
69 \param[in] strDirectory Virtual path that identifies which artists to process or "" (empty string) for all artists
70 \param[in] refresh Whether or not to refresh data for artists that have previously been scraped
72 void StartArtistScan(const std::string& strDirectory, bool refresh = false);
74 /*!
75 \brief Check if a library scan or cleaning is in progress.
76 \return True if a scan or clean is in progress, false otherwise
78 bool IsScanningLibrary() const;
80 /*!
81 \brief Stop and dequeue all scanning jobs.
83 void StopLibraryScanning();
85 /*!
86 \brief Enqueue an asynchronous library cleaning job.
87 \param[in] showDialog Show a model progress dialog while cleaning. Default is false.
89 void CleanLibrary(bool showDialog = false);
91 /*!
92 \brief Adds the given job to the queue.
93 \param[in] job Music library job to be queued.
95 void AddJob(CMusicLibraryJob *job);
97 /*!
98 \brief Cancels the given job and removes it from the queue.
99 \param[in] job Music library job to be canceled and removed from the queue.
101 void CancelJob(CMusicLibraryJob *job);
104 \brief Cancels all running and queued jobs.
106 void CancelAllJobs();
109 \brief Whether any jobs are running or not.
111 bool IsRunning() const;
113 protected:
114 // implementation of IJobCallback
115 void OnJobComplete(unsigned int jobID, bool success, CJob *job) override;
118 \brief Notifies all to refresh the current listings.
120 void Refresh();
122 private:
123 CMusicLibraryQueue();
124 CMusicLibraryQueue(const CMusicLibraryQueue&);
125 CMusicLibraryQueue const& operator=(CMusicLibraryQueue const&);
127 typedef std::set<CMusicLibraryJob*> MusicLibraryJobs;
128 typedef std::map<std::string, MusicLibraryJobs> MusicLibraryJobMap;
129 MusicLibraryJobMap m_jobs;
130 CCriticalSection m_critical;
132 bool m_modal = false;
133 bool m_cleaning = false;