3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "MediaSource.h" // for VECSOURCES
24 #include "utils/Job.h"
25 #include "IStorageProvider.h"
26 #include "threads/CriticalSection.h"
29 using namespace MEDIA_DETECT;
33 #define TRAY_CLOSED_NO_MEDIA 64
34 #define TRAY_CLOSED_MEDIA_PRESENT 96
36 #define DRIVE_OPEN 0 // Open...
37 #define DRIVE_NOT_READY 1 // Opening.. Closing...
39 #define DRIVE_CLOSED_NO_MEDIA 3 // CLOSED...but no media in drive
40 #define DRIVE_CLOSED_MEDIA_PRESENT 4 // Will be send once when the drive just have closed
41 #define DRIVE_NONE 5 // system doesn't have an optical drive
43 class CNetworkLocation
46 CNetworkLocation() { id = 0; };
51 class CMediaManager : public IStorageEventsCallback, public IJobCallback
62 void GetLocalDrives(VECSOURCES &localDrives, bool includeQ = true);
63 void GetRemovableDrives(VECSOURCES &removableDrives);
64 void GetNetworkLocations(VECSOURCES &locations, bool autolocations = true);
66 bool AddNetworkLocation(const CStdString &path);
67 bool HasLocation(const CStdString& path) const;
68 bool RemoveLocation(const CStdString& path);
69 bool SetLocationPath(const CStdString& oldPath, const CStdString& newPath);
71 void AddAutoSource(const CMediaSource &share, bool bAutorun=false);
72 void RemoveAutoSource(const CMediaSource &share);
73 bool IsDiscInDrive(const CStdString& devicePath="");
74 bool IsAudio(const CStdString& devicePath="");
75 bool HasOpticalDrive();
76 CStdString TranslateDevicePath(const CStdString& devicePath, bool bReturnAsDevice=false);
77 DWORD GetDriveStatus(const CStdString& devicePath="");
79 CCdInfo* GetCdInfo(const CStdString& devicePath="");
80 bool RemoveCdInfo(const CStdString& devicePath="");
81 CStdString GetDiskLabel(const CStdString& devicePath="");
82 CStdString GetDiskUniqueId(const CStdString& devicePath="");
84 CStdString GetDiscPath();
85 void SetHasOpticalDrive(bool bstatus);
87 bool Eject(CStdString mountpath);
88 void EjectTray( const bool bEject=true, const char cDriveLetter='\0' );
89 void CloseTray(const char cDriveLetter='\0');
90 void ToggleTray(const char cDriveLetter='\0');
94 std::vector<CStdString> GetDiskUsage();
96 virtual void OnStorageAdded(const CStdString &label, const CStdString &path);
97 virtual void OnStorageSafelyRemoved(const CStdString &label);
98 virtual void OnStorageUnsafelyRemoved(const CStdString &label);
100 virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job) { }
102 std::vector<CNetworkLocation> m_locations;
104 CCriticalSection m_muAutoSource, m_CritSecStorageProvider;
106 std::map<CStdString,CCdInfo*> m_mapCdInfo;
109 CStdString m_strFirstAvailDrive;
112 IStorageProvider *m_platformStorage;
115 extern class CMediaManager g_mediaManager;