2 * Copyright (C) 2014-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.
11 #include "threads/CriticalSection.h"
12 #include "utils/JobManager.h"
19 class CGUIDialogProgressBarHandle
;
20 class CVideoLibraryJob
;
23 \brief Queue for video 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 CVideoLibraryQueue
: protected CJobQueue
31 ~CVideoLibraryQueue() override
;
34 \brief Gets the singleton instance of the video library queue.
36 static CVideoLibraryQueue
& GetInstance();
39 \brief Enqueue a library scan job.
41 \param[in] directory Directory to scan
42 \param[in] scanAll Ignore exclude setting for items. Defaults to false
43 \param[in] showProgress Whether or not to show a progress dialog. Defaults to true
45 void ScanLibrary(const std::string
& directory
, bool scanAll
= false, bool showProgress
= true);
48 \brief Check if a library scan is in progress.
50 \return True if a scan is in progress, false otherwise
52 bool IsScanningLibrary() const;
55 \brief Stop and dequeue all scanning jobs.
57 void StopLibraryScanning();
60 \brief Enqueue a library cleaning job.
62 \param[in] paths Set with database IDs of paths to be cleaned
63 \param[in] asynchronous Run the clean job asynchronously. Defaults to true
64 \param[in] progressBar Progress bar to update in GUI. Defaults to NULL (no progress bar to update)
65 \return True if the video library cleaning job has started, false otherwise
67 bool CleanLibrary(const std::set
<int>& paths
= std::set
<int>(),
68 bool asynchronous
= true,
69 CGUIDialogProgressBarHandle
* progressBar
= NULL
);
72 \brief Executes a library cleaning with a modal dialog.
74 \param[in] paths Set with database IDs of paths to be cleaned
75 \return True if the video library cleaning job has started, false otherwise
77 bool CleanLibraryModal(const std::set
<int>& paths
= std::set
<int>());
80 \brief Enqueues a job to refresh the details of the given item.
82 \param[inout] item Video item to be refreshed
83 \param[in] ignoreNfo Whether or not to ignore local NFO files
84 \param[in] forceRefresh Whether to force a complete refresh (including NFO or internet lookup)
85 \param[in] refreshAll Whether to refresh all sub-items (in case of a tvshow)
86 \param[in] searchTitle Title to use for the search (instead of determining it from the item's filename/path)
88 void RefreshItem(std::shared_ptr
<CFileItem
> item
,
89 bool ignoreNfo
= false,
90 bool forceRefresh
= true,
91 bool refreshAll
= false,
92 const std::string
& searchTitle
= "");
95 \brief Refreshes the details of the given item with a modal dialog.
97 \param[inout] item Video item to be refreshed
98 \param[in] forceRefresh Whether to force a complete refresh (including NFO or internet lookup)
99 \param[in] refreshAll Whether to refresh all sub-items (in case of a tvshow)
100 \return True if the item has been successfully refreshed, false otherwise.
102 bool RefreshItemModal(std::shared_ptr
<CFileItem
> item
,
103 bool forceRefresh
= true,
104 bool refreshAll
= false);
107 \brief Queue a watched status update job.
109 \param[in] item Item to update watched status for
110 \param[in] watched New watched status
112 void MarkAsWatched(const std::shared_ptr
<CFileItem
>& item
, bool watched
);
115 \brief Queue a reset resume point job.
117 \param[in] item Item to reset the resume point for
119 void ResetResumePoint(const std::shared_ptr
<CFileItem
>& item
);
122 \brief Adds the given job to the queue.
124 \param[in] job Video library job to be queued.
126 void AddJob(CVideoLibraryJob
*job
);
129 \brief Cancels the given job and removes it from the queue.
131 \param[in] job Video library job to be canceled and removed from the queue.
133 void CancelJob(CVideoLibraryJob
*job
);
136 \brief Cancels all running and queued jobs.
138 void CancelAllJobs();
141 \brief Whether any jobs are running or not.
143 bool IsRunning() const;
146 // implementation of IJobCallback
147 void OnJobComplete(unsigned int jobID
, bool success
, CJob
*job
) override
;
150 \brief Notifies all to refresh the current listings.
155 CVideoLibraryQueue();
156 CVideoLibraryQueue(const CVideoLibraryQueue
&) = delete;
157 CVideoLibraryQueue
const& operator=(CVideoLibraryQueue
const&) = delete;
159 typedef std::set
<CVideoLibraryJob
*> VideoLibraryJobs
;
160 typedef std::map
<std::string
, VideoLibraryJobs
> VideoLibraryJobMap
;
161 VideoLibraryJobMap m_jobs
;
162 CCriticalSection m_critical
;
164 bool m_modal
= false;
165 bool m_cleaning
= false;