Debian Codegraph @

xbmc/storage/IStorageProvider.h

raw
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_OPTICAL_DRIVE
17 #include "cdioSupport.h"
18 #endif
19
20 namespace MEDIA_DETECT
21 {
22 namespace STORAGE
23 {
24 /*! \brief Abstracts a generic storage device type*/
25 enum class Type
26 {
27 UNKNOWN, /*!< the storage type is unknown */
28 OPTICAL /*!< an optical device (e.g. DVD or Bluray) */
29 };
30
31 /*! \brief Abstracts a generic storage device */
32 struct StorageDevice
33 {
34 /*! Device name/label */
35 std::string label{};
36 /*! Device mountpoint/path */
37 std::string path{};
38 /*! The storage type (e.g. OPTICAL) */
39 STORAGE::Type type{STORAGE::Type::UNKNOWN};
40 };
41 } // namespace STORAGE
42 } // namespace MEDIA_DETECT
43
44 class IStorageEventsCallback
45 {
46 public:
47 virtual ~IStorageEventsCallback() = default;
48
49 /*! \brief Callback executed when a new storage device is added
50 * @param device the storage device
51 */
52 virtual void OnStorageAdded(const MEDIA_DETECT::STORAGE::StorageDevice& device) = 0;
53
54 /*! \brief Callback executed when a new storage device is safely removed
55 * @param device the storage device
56 */
57 virtual void OnStorageSafelyRemoved(const MEDIA_DETECT::STORAGE::StorageDevice& device) = 0;
58
59 /*! \brief Callback executed when a new storage device is unsafely removed
60 * @param device the storage device
61 */
62 virtual void OnStorageUnsafelyRemoved(const MEDIA_DETECT::STORAGE::StorageDevice& device) = 0;
63 };
64
65 class IStorageProvider
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_OPTICAL_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
90 /**\brief Called by media manager to create platform storage provider
91 *
92 * This method used to create platform specified storage provider
93 */
94 static std::unique_ptr<IStorageProvider> CreateInstance();
95 };