[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / storage / linux / UDisksProvider.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://www.xbmc.org
5  *
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)
9  *  any later version.
10  *
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.
15  *
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/>.
19  *
20  */
21 #include "storage/IStorageProvider.h"
22 #ifdef HAS_DBUS
23 #include "DBusUtil.h"
24
25 class CUDiskDevice
26 {
27 public:
28   CUDiskDevice(const char *DeviceKitUDI);
29   ~CUDiskDevice() { }
30
31   void Update();
32
33   bool Mount();
34   bool UnMount();
35
36   bool IsApproved();
37
38   CStdString toString();
39
40   CMediaSource ToMediaShare();
41
42   CStdString m_UDI, m_DeviceKitUDI, m_MountPath, m_FileSystem, m_Label;
43   bool m_isMounted, m_isMountedByUs, m_isRemovable, m_isPartition, m_isFileSystem, m_isSystemInternal, m_isOptical;
44   float m_PartitionSizeGiB;
45 };
46
47 class CUDisksProvider : public IStorageProvider
48 {
49 public:
50   CUDisksProvider();
51   virtual ~CUDisksProvider();
52
53   virtual void Initialize();
54   virtual void Stop() { }
55
56   virtual void GetLocalDrives(VECSOURCES &localDrives) { GetDisks(localDrives, false); }
57   virtual void GetRemovableDrives(VECSOURCES &removableDrives) { GetDisks(removableDrives, true); }
58
59   virtual bool Eject(CStdString mountpath);
60
61   virtual std::vector<CStdString> GetDiskUsage();
62
63   virtual bool PumpDriveChangeEvents(IStorageEventsCallback *callback);
64
65   static bool HasUDisks();
66 private:
67   typedef std::map<CStdString, CUDiskDevice *> DeviceMap;
68   typedef std::pair<CStdString, CUDiskDevice *> DevicePair;
69
70   void DeviceAdded(const char *object, IStorageEventsCallback *callback);
71   void DeviceRemoved(const char *object, IStorageEventsCallback *callback);
72   void DeviceChanged(const char *object, IStorageEventsCallback *callback);
73
74   std::vector<CStdString> EnumerateDisks();
75
76   void GetDisks(VECSOURCES& devices, bool EnumerateRemovable);
77
78   int m_DaemonVersion;
79
80   DeviceMap m_AvailableDevices;
81
82   DBusConnection *m_connection;
83   DBusError m_error;
84 };
85 #endif