xbmc
IStorageProvider.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "MediaSource.h"
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 #ifdef HAS_DVD_DRIVE
17 #include "cdioSupport.h"
18 #endif
19 
20 namespace MEDIA_DETECT
21 {
22 namespace STORAGE
23 {
25 enum class Type
26 {
27  UNKNOWN,
28  OPTICAL
29 };
30 
33 {
35  std::string label{};
37  std::string path{};
39  STORAGE::Type type{STORAGE::Type::UNKNOWN};
40 };
41 } // namespace STORAGE
42 } // namespace MEDIA_DETECT
43 
45 {
46 public:
47  virtual ~IStorageEventsCallback() = default;
48 
52  virtual void OnStorageAdded(const MEDIA_DETECT::STORAGE::StorageDevice& device) = 0;
53 
57  virtual void OnStorageSafelyRemoved(const MEDIA_DETECT::STORAGE::StorageDevice& device) = 0;
58 
62  virtual void OnStorageUnsafelyRemoved(const MEDIA_DETECT::STORAGE::StorageDevice& device) = 0;
63 };
64 
66 {
67 public:
68  virtual ~IStorageProvider() = default;
69 
70  virtual void Initialize() = 0;
71  virtual void Stop() = 0;
72 
73  virtual void GetLocalDrives(VECSOURCES &localDrives) = 0;
74  virtual void GetRemovableDrives(VECSOURCES &removableDrives) = 0;
75  virtual std::string GetFirstOpticalDeviceFileName()
76  {
77 #ifdef HAS_DVD_DRIVE
78  return std::string(MEDIA_DETECT::CLibcdio::GetInstance()->GetDeviceFileName());
79 #else
80  return "";
81 #endif
82  }
83 
84  virtual bool Eject(const std::string& mountpath) = 0;
85 
86  virtual std::vector<std::string> GetDiskUsage() = 0;
87 
88  virtual bool PumpDriveChangeEvents(IStorageEventsCallback *callback) = 0;
89 
94  static std::unique_ptr<IStorageProvider> CreateInstance();
95 };
Definition: Application.h:59
Abstracts a generic storage device.
Definition: IStorageProvider.h:32
Definition: IStorageProvider.h:65
Definition: IStorageProvider.h:44