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 "ServiceBroker.h"
13 #include "TextureCache.h"
14 #include "pvr/PVRManager.h"
15 #include "pvr/filesystem/PVRGUIDirectory.h"
16 #include "settings/AdvancedSettings.h"
17 #include "settings/Settings.h"
18 #include "settings/SettingsComponent.h"
19 #include "utils/StringUtils.h"
20 #include "utils/log.h"
26 bool CPVRThumbLoader::LoadItem(CFileItem
* item
)
28 bool result
= LoadItemCached(item
);
29 result
|= LoadItemLookup(item
);
33 bool CPVRThumbLoader::LoadItemCached(CFileItem
* item
)
35 return FillThumb(*item
);
38 bool CPVRThumbLoader::LoadItemLookup(CFileItem
* item
)
43 void CPVRThumbLoader::OnLoaderFinish()
47 m_bInvalidated
= false;
48 CServiceBroker::GetPVRManager().PublishEvent(PVREvent::ChannelGroupsInvalidated
);
50 CThumbLoader::OnLoaderFinish();
53 void CPVRThumbLoader::ClearCachedImage(CFileItem
& item
)
55 const std::string thumb
= item
.GetArt("thumb");
58 CServiceBroker::GetTextureCache()->ClearCachedImage(thumb
);
59 if (m_textureDatabase
->Open())
61 m_textureDatabase
->ClearTextureForPath(item
.GetPath(), "thumb");
62 m_textureDatabase
->Close();
64 item
.SetArt("thumb", "");
65 m_bInvalidated
= true;
69 void CPVRThumbLoader::ClearCachedImages(const CFileItemList
& items
)
71 for (auto& item
: items
)
72 ClearCachedImage(*item
);
75 bool CPVRThumbLoader::FillThumb(CFileItem
& item
)
77 // see whether we have a cached image for this item
78 std::string thumb
= GetCachedImage(item
, "thumb");
81 if (item
.IsPVRChannelGroup())
82 thumb
= CreateChannelGroupThumb(item
);
84 CLog::LogF(LOGERROR
, "Unsupported PVR item '{}'", item
.GetPath());
88 SetCachedImage(item
, "thumb", thumb
);
89 m_bInvalidated
= true;
96 item
.SetArt("thumb", thumb
);
100 std::string
CPVRThumbLoader::CreateChannelGroupThumb(const CFileItem
& channelGroupItem
)
102 return StringUtils::Format("{}?ts={}", // append timestamp to Thumb URL to enforce texture refresh
103 CTextureUtils::GetWrappedImageURL(channelGroupItem
.GetPath(), "pvr"),