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.
12 #include "FileItemList.h"
13 #include "threads/CriticalSection.h"
14 #include "utils/EventStream.h"
18 #include <unordered_map>
21 class CFavouritesService
24 explicit CFavouritesService(std::string userDataFolder
);
25 virtual ~CFavouritesService() = default;
28 void ReInit(std::string userDataFolder
);
30 bool IsFavourited(const CFileItem
& item
, int contextWindow
) const;
31 std::shared_ptr
<CFileItem
> GetFavourite(const CFileItem
& item
, int contextWindow
) const;
32 std::shared_ptr
<CFileItem
> ResolveFavourite(const CFileItem
& favItem
) const;
35 void GetAll(CFileItemList
& items
) const;
36 bool AddOrRemove(const CFileItem
& item
, int contextWindow
);
37 bool Save(const CFileItemList
& items
);
39 /*! \brief Refresh favourites for directory providers, e.g. the GUI needs to be updated
41 void RefreshFavourites();
43 struct FavouritesUpdated
{ };
45 CEventStream
<FavouritesUpdated
>& Events() { return m_events
; }
48 CFavouritesService() = delete;
49 CFavouritesService(const CFavouritesService
&) = delete;
50 CFavouritesService
& operator=(const CFavouritesService
&) = delete;
51 CFavouritesService(CFavouritesService
&&) = delete;
52 CFavouritesService
& operator=(CFavouritesService
&&) = delete;
57 std::string m_userDataFolder
;
58 CFileItemList m_favourites
;
59 mutable std::unordered_map
<std::string
, std::shared_ptr
<CFileItem
>> m_targets
;
60 CEventSource
<FavouritesUpdated
> m_events
;
61 mutable CCriticalSection m_criticalSection
;