[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / filesystem / SourcesDirectory.cpp
blobb83ee2ed499a0d37ab9e4d55e206f2794bc83b86
1 /*
2 * Copyright (C) 2005-2020 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 #include "SourcesDirectory.h"
11 #include "FileItem.h"
12 #include "ServiceBroker.h"
13 #include "URL.h"
14 #include "Util.h"
15 #include "guilib/TextureManager.h"
16 #include "media/MediaLockState.h"
17 #include "profiles/ProfileManager.h"
18 #include "settings/MediaSourceSettings.h"
19 #include "storage/MediaManager.h"
20 #include "utils/FileUtils.h"
21 #include "utils/URIUtils.h"
23 using namespace XFILE;
25 CSourcesDirectory::CSourcesDirectory(void) = default;
27 CSourcesDirectory::~CSourcesDirectory(void) = default;
29 bool CSourcesDirectory::GetDirectory(const CURL& url, CFileItemList &items)
31 // break up our path
32 // format is: sources://<type>/
33 std::string type(url.GetFileName());
34 URIUtils::RemoveSlashAtEnd(type);
36 VECSOURCES sources;
37 VECSOURCES *sourcesFromType = CMediaSourceSettings::GetInstance().GetSources(type);
38 if (!sourcesFromType)
39 return false;
41 sources = *sourcesFromType;
42 CServiceBroker::GetMediaManager().GetRemovableDrives(sources);
44 return GetDirectory(sources, items);
47 bool CSourcesDirectory::GetDirectory(const VECSOURCES &sources, CFileItemList &items)
49 for (unsigned int i = 0; i < sources.size(); ++i)
51 const CMediaSource& share = sources[i];
52 CFileItemPtr pItem(new CFileItem(share));
53 if (URIUtils::IsProtocol(pItem->GetPath(), "musicsearch"))
54 pItem->SetCanQueue(false);
56 std::string strIcon;
57 // We have the real DVD-ROM, set icon on disktype
58 if (share.m_iDriveType == CMediaSource::SOURCE_TYPE_DVD && share.m_strThumbnailImage.empty())
60 CUtil::GetDVDDriveIcon( pItem->GetPath(), strIcon );
61 // CDetectDVDMedia::SetNewDVDShareUrl() caches disc thumb as special://temp/dvdicon.tbn
62 std::string strThumb = "special://temp/dvdicon.tbn";
63 if (CFileUtils::Exists(strThumb))
64 pItem->SetArt("thumb", strThumb);
66 else if (URIUtils::IsProtocol(pItem->GetPath(), "addons"))
67 strIcon = "DefaultHardDisk.png";
68 else if ( pItem->IsPath("special://musicplaylists/")
69 || pItem->IsPath("special://videoplaylists/"))
70 strIcon = "DefaultPlaylist.png";
71 else if ( pItem->IsVideoDb()
72 || pItem->IsMusicDb()
73 || pItem->IsPlugin()
74 || pItem->IsPath("musicsearch://"))
75 strIcon = "DefaultFolder.png";
76 else if (pItem->IsRemote())
77 strIcon = "DefaultNetwork.png";
78 else if (pItem->IsISO9660())
79 strIcon = "DefaultDVDRom.png";
80 else if (pItem->IsDVD())
81 strIcon = "DefaultDVDFull.png";
82 else if (pItem->IsBluray())
83 strIcon = "DefaultBluray.png";
84 else if (pItem->IsCDDA())
85 strIcon = "DefaultCDDA.png";
86 else if (pItem->IsRemovable() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture("DefaultRemovableDisk.png"))
87 strIcon = "DefaultRemovableDisk.png";
88 else
89 strIcon = "DefaultHardDisk.png";
91 pItem->SetArt("icon", strIcon);
92 if (share.m_iHasLock == LOCK_STATE_LOCKED &&
93 m_profileManager->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
94 pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_LOCKED);
95 else
96 pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_NONE);
98 items.Add(pItem);
100 return true;
103 bool CSourcesDirectory::Exists(const CURL& url)
105 return true;