[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / addons / RepositoryUpdater.h
blob67448074a915ad424bc97636f30e86c73b88a861
1 /*
2 * Copyright (C) 2015-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/lib/ISettingCallback.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/Timer.h"
14 #include "utils/EventStream.h"
15 #include "utils/Job.h"
17 #include <memory>
18 #include <vector>
20 class CDateTime;
22 namespace ADDON
25 class CAddonMgr;
27 class CRepository;
28 using RepositoryPtr = std::shared_ptr<CRepository>;
30 class CRepositoryUpdateJob;
32 struct AddonEvent;
34 class CRepositoryUpdater : private ITimerCallback, private IJobCallback, public ISettingCallback
36 public:
37 explicit CRepositoryUpdater(CAddonMgr& addonMgr);
38 ~CRepositoryUpdater() override;
40 void Start();
42 /**
43 * Check a single repository for updates.
45 void CheckForUpdates(const ADDON::RepositoryPtr& repo, bool showProgress=false);
47 /**
48 * Check all repositories for updates.
50 bool CheckForUpdates(bool showProgress=false);
52 /**
53 * Wait for any pending/in-progress updates to complete.
55 void Await();
57 enum class UpdateScheduleType
59 /*! Update should be scheduled as the first update after application start or setting change. */
60 First,
61 /*! Update should be scheduled as a regular update during application runtime. */
62 Regular
65 /**
66 * Schedule an automatic update to run based on settings and previous update
67 * times. May be called when there are external changes this updater must know
68 * about. Any previously scheduled update will be cancelled.
70 void ScheduleUpdate(UpdateScheduleType scheduleType);
72 /**
73 * Returns the time of the last check (oldest). Invalid time if never checked.
75 CDateTime LastUpdated() const;
78 void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
80 struct RepositoryUpdated { };
82 CEventStream<RepositoryUpdated>& Events() { return m_events; }
84 private:
85 CRepositoryUpdater(const CRepositoryUpdater&) = delete;
86 CRepositoryUpdater(CRepositoryUpdater&&) = delete;
87 CRepositoryUpdater& operator=(const CRepositoryUpdater&) = delete;
88 CRepositoryUpdater& operator=(CRepositoryUpdater&&) = delete;
90 void OnJobComplete(unsigned int jobID, bool success, CJob *job) override;
92 void OnTimeout() override;
94 void OnEvent(const ADDON::AddonEvent& event);
96 CDateTime ClosestNextCheck() const;
98 CCriticalSection m_criticalSection;
99 CTimer m_timer;
100 CEvent m_doneEvent;
101 std::vector<CRepositoryUpdateJob*> m_jobs;
102 CAddonMgr& m_addonMgr;
104 CEventSource<RepositoryUpdated> m_events;