Merge pull request #26264 from the-black-eagle/mka_end_durations
[xbmc.git] / xbmc / addons / Repository.h
blobbc7ad8cf9145d4d711f9af65189c264a7feb5f2d
1 /*
2 * Copyright (C) 2005-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 "addons/Addon.h"
12 #include "addons/AddonVersion.h"
13 #include "utils/Digest.h"
15 #include <memory>
16 #include <string>
17 #include <vector>
19 namespace ADDON
21 class CAddonExtensions;
23 struct RepositoryDirInfo
25 CAddonVersion minversion{""};
26 CAddonVersion maxversion{""};
27 std::string info;
28 std::string checksum;
29 KODI::UTILITY::CDigest::Type checksumType{KODI::UTILITY::CDigest::Type::INVALID};
30 std::string datadir;
31 std::string artdir;
32 KODI::UTILITY::CDigest::Type hashType{KODI::UTILITY::CDigest::Type::INVALID};
35 typedef std::vector<RepositoryDirInfo> RepositoryDirList;
37 class CRepository : public CAddon
39 public:
40 explicit CRepository(const AddonInfoPtr& addonInfo);
42 enum FetchStatus
44 STATUS_OK,
45 STATUS_NOT_MODIFIED,
46 STATUS_ERROR
49 FetchStatus FetchIfChanged(const std::string& oldChecksum,
50 std::string& checksum,
51 std::vector<AddonInfoPtr>& addons,
52 int& recheckAfter) const;
54 struct ResolveResult
56 std::string location;
57 KODI::UTILITY::TypedDigest digest;
59 ResolveResult ResolvePathAndHash(AddonPtr const& addon) const;
61 // Implementation of CAddon
62 void OnPostInstall(bool update, bool modal) override;
64 private:
65 static bool FetchChecksum(const std::string& url,
66 std::string& checksum,
67 int& recheckAfter) noexcept;
68 static bool FetchIndex(const RepositoryDirInfo& repo,
69 std::string const& digest,
70 std::vector<AddonInfoPtr>& addons) noexcept;
72 static RepositoryDirInfo ParseDirConfiguration(const CAddonExtensions& configuration);
74 RepositoryDirList m_dirs;
77 typedef std::shared_ptr<CRepository> RepositoryPtr;