[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / storage / linux / LinuxStorageProvider.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 #include "HALProvider.h"
23 #include "DeviceKitDisksProvider.h"
24 #include "UDisksProvider.h"
25 #include "PosixMountProvider.h"
26
27 class CLinuxStorageProvider : public IStorageProvider
28 {
29 public:
30   CLinuxStorageProvider()
31   {
32     m_instance = NULL;
33
34 #ifdef HAS_DBUS
35     if (CUDisksProvider::HasUDisks())
36       m_instance = new CUDisksProvider();
37     else if (CDeviceKitDisksProvider::HasDeviceKitDisks())
38       m_instance = new CDeviceKitDisksProvider();
39 #endif
40 #ifdef HAS_HAL
41     if (m_instance == NULL)
42       m_instance = new CHALProvider();
43 #endif
44
45     if (m_instance == NULL)
46       m_instance = new CPosixMountProvider();
47   }
48
49   virtual ~CLinuxStorageProvider()
50   {
51     delete m_instance;
52   }
53
54   virtual void Initialize()
55   {
56     m_instance->Initialize();
57   }
58
59   virtual void Stop()
60   {
61     m_instance->Stop();
62   }
63
64   virtual void GetLocalDrives(VECSOURCES &localDrives)
65   {
66     // Home directory
67     CMediaSource share;
68     share.strPath = getenv("HOME");
69     share.strName = g_localizeStrings.Get(21440);
70     share.m_ignore = true;
71     share.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
72     localDrives.push_back(share);
73     share.strPath = "/";
74     share.strName = g_localizeStrings.Get(21453);
75     localDrives.push_back(share);
76
77     m_instance->GetLocalDrives(localDrives);
78   }
79
80   virtual void GetRemovableDrives(VECSOURCES &removableDrives)
81   {
82     m_instance->GetRemovableDrives(removableDrives);
83   }
84
85   virtual bool Eject(CStdString mountpath)
86   {
87     return m_instance->Eject(mountpath);
88   }
89
90   virtual std::vector<CStdString> GetDiskUsage()
91   {
92     return m_instance->GetDiskUsage();
93   }
94
95   virtual bool PumpDriveChangeEvents(IStorageEventsCallback *callback)
96   {
97     return m_instance->PumpDriveChangeEvents(callback);
98   }
99
100 private:
101   IStorageProvider *m_instance;
102 };