2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "SourcesDirectory.h"
22 #include "utils/URIUtils.h"
27 #include "profiles/ProfilesManager.h"
28 #include "settings/MediaSourceSettings.h"
29 #include "guilib/TextureManager.h"
30 #include "storage/MediaManager.h"
31 #include "utils/StringUtils.h"
33 using namespace XFILE;
35 CSourcesDirectory::CSourcesDirectory(void)
39 CSourcesDirectory::~CSourcesDirectory(void)
43 bool CSourcesDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
46 // format is: sources://<type>/
48 CStdString type(url.GetFileName());
49 URIUtils::RemoveSlashAtEnd(type);
52 VECSOURCES *sourcesFromType = CMediaSourceSettings::Get().GetSources(type);
54 sources = *sourcesFromType;
55 g_mediaManager.GetRemovableDrives(sources);
60 return GetDirectory(sources, items);
63 bool CSourcesDirectory::GetDirectory(const VECSOURCES &sources, CFileItemList &items)
65 for (unsigned int i = 0; i < sources.size(); ++i)
67 const CMediaSource& share = sources[i];
68 CFileItemPtr pItem(new CFileItem(share));
69 if (StringUtils::StartsWithNoCase(pItem->GetPath(), "musicsearch://"))
70 pItem->SetCanQueue(false);
73 // We have the real DVD-ROM, set icon on disktype
74 if (share.m_iDriveType == CMediaSource::SOURCE_TYPE_DVD && share.m_strThumbnailImage.empty())
76 CUtil::GetDVDDriveIcon( pItem->GetPath(), strIcon );
77 // CDetectDVDMedia::SetNewDVDShareUrl() caches disc thumb as special://temp/dvdicon.tbn
78 CStdString strThumb = "special://temp/dvdicon.tbn";
79 if (XFILE::CFile::Exists(strThumb))
80 pItem->SetArt("thumb", strThumb);
82 else if (StringUtils::StartsWith(pItem->GetPath(), "addons://"))
83 strIcon = "DefaultHardDisk.png";
84 else if ( pItem->IsVideoDb()
87 || pItem->GetPath() == "special://musicplaylists/"
88 || pItem->GetPath() == "special://videoplaylists/"
89 || pItem->GetPath() == "musicsearch://")
90 strIcon = "DefaultFolder.png";
91 else if (pItem->IsRemote())
92 strIcon = "DefaultNetwork.png";
93 else if (pItem->IsISO9660())
94 strIcon = "DefaultDVDRom.png";
95 else if (pItem->IsDVD())
96 strIcon = "DefaultDVDRom.png";
97 else if (pItem->IsCDDA())
98 strIcon = "DefaultCDDA.png";
99 else if (pItem->IsRemovable() && g_TextureManager.HasTexture("DefaultRemovableDisk.png"))
100 strIcon = "DefaultRemovableDisk.png";
102 strIcon = "DefaultHardDisk.png";
104 pItem->SetIconImage(strIcon);
105 if (share.m_iHasLock == 2 && CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE)
106 pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_LOCKED);
108 pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_NONE);
115 bool CSourcesDirectory::Exists(const char* strPath)