2 * Copyright (C) 2013-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 "IListProvider.h"
12 #include "addons/AddonEvents.h"
13 #include "addons/RepositoryUpdater.h"
14 #include "favourites/FavouritesService.h"
15 #include "guilib/GUIStaticItem.h"
16 #include "interfaces/IAnnouncer.h"
17 #include "threads/CriticalSection.h"
18 #include "utils/Job.h"
32 enum class InfoTagType
41 class CDirectoryProvider
:
44 public ANNOUNCEMENT::IAnnouncer
57 AUTO
, // add browse item if list is longer than given limit
61 CDirectoryProvider(const TiXmlElement
*element
, int parentID
);
62 explicit CDirectoryProvider(const CDirectoryProvider
& other
);
63 ~CDirectoryProvider() override
;
65 // Implementation of IListProvider
66 std::unique_ptr
<IListProvider
> Clone() override
;
67 bool Update(bool forceRefresh
) override
;
68 void Announce(ANNOUNCEMENT::AnnouncementFlag flag
,
69 const std::string
& sender
,
70 const std::string
& message
,
71 const CVariant
& data
) override
;
72 void Fetch(std::vector
<std::shared_ptr
<CGUIListItem
>>& items
) override
;
73 void Reset() override
;
74 bool OnClick(const std::shared_ptr
<CGUIListItem
>& item
) override
;
75 bool OnPlay(const std::shared_ptr
<CGUIListItem
>& item
) override
;
76 bool OnInfo(const std::shared_ptr
<CGUIListItem
>& item
) override
;
77 bool OnContextMenu(const std::shared_ptr
<CGUIListItem
>& item
) override
;
78 bool IsUpdating() const override
;
79 void FreeResources(bool immediately
) override
;
81 // callback from directory job
82 void OnJobComplete(unsigned int jobID
, bool success
, CJob
*job
) override
;
84 UpdateState m_updateState
= OK
;
85 unsigned int m_jobID
= 0;
86 KODI::GUILIB::GUIINFO::CGUIInfoLabel m_url
;
87 KODI::GUILIB::GUIINFO::CGUIInfoLabel m_target
;
88 KODI::GUILIB::GUIINFO::CGUIInfoLabel m_sortMethod
;
89 KODI::GUILIB::GUIINFO::CGUIInfoLabel m_sortOrder
;
90 KODI::GUILIB::GUIINFO::CGUIInfoLabel m_limit
;
91 KODI::GUILIB::GUIINFO::CGUIInfoLabel m_browse
;
92 std::string m_currentUrl
;
93 std::string m_currentTarget
; ///< \brief node.target property on the list as a whole
94 SortDescription m_currentSort
;
95 unsigned int m_currentLimit
{0};
96 BrowseMode m_currentBrowse
{BrowseMode::AUTO
};
97 std::vector
<CGUIStaticItemPtr
> m_items
;
98 std::vector
<InfoTagType
> m_itemTypes
;
99 mutable CCriticalSection m_section
;
105 void OnAddonEvent(const ADDON::AddonEvent
& event
);
106 void OnAddonRepositoryEvent(const ADDON::CRepositoryUpdater::RepositoryUpdated
& event
);
107 void OnPVRManagerEvent(const PVR::PVREvent
& event
);
108 void OnFavouritesEvent(const CFavouritesService::FavouritesUpdated
& event
);
109 std::string
GetTarget(const CFileItem
& item
) const;
111 CCriticalSection m_subscriptionSection
;
112 bool m_isSubscribed
{false};