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/>.
25 #include "MediaSource.h" // for VECSOURCES
26 #include "utils/Job.h"
27 #include "IStorageProvider.h"
28 #include "threads/CriticalSection.h"
31 #define TRAY_CLOSED_NO_MEDIA 64
32 #define TRAY_CLOSED_MEDIA_PRESENT 96
34 #define DRIVE_OPEN 0 // Open...
35 #define DRIVE_NOT_READY 1 // Opening.. Closing...
37 #define DRIVE_CLOSED_NO_MEDIA 3 // CLOSED...but no media in drive
38 #define DRIVE_CLOSED_MEDIA_PRESENT 4 // Will be send once when the drive just have closed
39 #define DRIVE_NONE 5 // system doesn't have an optical drive
41 class CNetworkLocation
44 CNetworkLocation() { id
= 0; };
49 class CMediaManager
: public IStorageEventsCallback
, public IJobCallback
60 void GetLocalDrives(VECSOURCES
&localDrives
, bool includeQ
= true);
61 void GetRemovableDrives(VECSOURCES
&removableDrives
);
62 void GetNetworkLocations(VECSOURCES
&locations
, bool autolocations
= true);
64 bool AddNetworkLocation(const std::string
&path
);
65 bool HasLocation(const std::string
& path
) const;
66 bool RemoveLocation(const std::string
& path
);
67 bool SetLocationPath(const std::string
& oldPath
, const std::string
& newPath
);
69 void AddAutoSource(const CMediaSource
&share
, bool bAutorun
=false);
70 void RemoveAutoSource(const CMediaSource
&share
);
71 bool IsDiscInDrive(const std::string
& devicePath
="");
72 bool IsAudio(const std::string
& devicePath
="");
73 bool HasOpticalDrive();
74 std::string
TranslateDevicePath(const std::string
& devicePath
, bool bReturnAsDevice
=false);
75 DWORD
GetDriveStatus(const std::string
& devicePath
="");
77 MEDIA_DETECT::CCdInfo
* GetCdInfo(const std::string
& devicePath
="");
78 bool RemoveCdInfo(const std::string
& devicePath
="");
79 std::string
GetDiskLabel(const std::string
& devicePath
="");
80 std::string
GetDiskUniqueId(const std::string
& devicePath
="");
82 std::string
GetDiscPath();
83 void SetHasOpticalDrive(bool bstatus
);
85 bool Eject(const std::string
& mountpath
);
86 void EjectTray( const bool bEject
=true, const char cDriveLetter
='\0' );
87 void CloseTray(const char cDriveLetter
='\0');
88 void ToggleTray(const char cDriveLetter
='\0');
92 std::vector
<std::string
> GetDiskUsage();
94 virtual void OnStorageAdded(const std::string
&label
, const std::string
&path
);
95 virtual void OnStorageSafelyRemoved(const std::string
&label
);
96 virtual void OnStorageUnsafelyRemoved(const std::string
&label
);
98 virtual void OnJobComplete(unsigned int jobID
, bool success
, CJob
*job
) { }
100 std::vector
<CNetworkLocation
> m_locations
;
102 CCriticalSection m_muAutoSource
, m_CritSecStorageProvider
;
104 std::map
<std::string
,MEDIA_DETECT::CCdInfo
*> m_mapCdInfo
;
107 std::string m_strFirstAvailDrive
;
110 IStorageProvider
*m_platformStorage
;
113 extern class CMediaManager g_mediaManager
;