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.
9 #include "PVRThumbLoader.h"
12 #include "FileItemList.h"
13 #include "ServiceBroker.h"
14 #include "TextureCache.h"
15 #include "pvr/PVRManager.h"
16 #include "pvr/filesystem/PVRGUIDirectory.h"
17 #include "settings/AdvancedSettings.h"
18 #include "settings/Settings.h"
19 #include "settings/SettingsComponent.h"
20 #include "utils/StringUtils.h"
21 #include "utils/log.h"
27 bool CPVRThumbLoader::LoadItem(CFileItem
* item
)
29 bool result
= LoadItemCached(item
);
30 result
|= LoadItemLookup(item
);
34 bool CPVRThumbLoader::LoadItemCached(CFileItem
* item
)
36 return FillThumb(*item
);
39 bool CPVRThumbLoader::LoadItemLookup(CFileItem
* item
)
44 void CPVRThumbLoader::OnLoaderFinish()
48 m_bInvalidated
= false;
49 CServiceBroker::GetPVRManager().PublishEvent(PVREvent::ChannelGroupsInvalidated
);
51 CThumbLoader::OnLoaderFinish();
54 void CPVRThumbLoader::ClearCachedImage(CFileItem
& item
)
56 const std::string thumb
= item
.GetArt("thumb");
59 CServiceBroker::GetTextureCache()->ClearCachedImage(thumb
);
60 if (m_textureDatabase
->Open())
62 m_textureDatabase
->ClearTextureForPath(item
.GetPath(), "thumb");
63 m_textureDatabase
->Close();
65 item
.SetArt("thumb", "");
66 m_bInvalidated
= true;
70 void CPVRThumbLoader::ClearCachedImages(const CFileItemList
& items
)
72 for (auto& item
: items
)
73 ClearCachedImage(*item
);
76 bool CPVRThumbLoader::FillThumb(CFileItem
& item
)
78 // see whether we have a cached image for this item
79 std::string thumb
= GetCachedImage(item
, "thumb");
82 if (item
.IsPVRChannelGroup())
83 thumb
= CreateChannelGroupThumb(item
);
85 CLog::LogF(LOGERROR
, "Unsupported PVR item '{}'", item
.GetPath());
89 SetCachedImage(item
, "thumb", thumb
);
90 m_bInvalidated
= true;
97 item
.SetArt("thumb", thumb
);
101 std::string
CPVRThumbLoader::CreateChannelGroupThumb(const CFileItem
& channelGroupItem
)
103 return StringUtils::Format("{}?ts={}", // append timestamp to Thumb URL to enforce texture refresh
104 CTextureUtils::GetWrappedImageURL(channelGroupItem
.GetPath(), "pvr"),