diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/platform/linux/storage/UDisksProvider.h | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/platform/linux/storage/UDisksProvider.h')
-rw-r--r-- | xbmc/platform/linux/storage/UDisksProvider.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/xbmc/platform/linux/storage/UDisksProvider.h b/xbmc/platform/linux/storage/UDisksProvider.h new file mode 100644 index 0000000..c5372f8 --- /dev/null +++ b/xbmc/platform/linux/storage/UDisksProvider.h @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DBusUtil.h" +#include "storage/IStorageProvider.h" + +#include <string> +#include <vector> + +class CUDiskDevice +{ +public: + CUDiskDevice(const char *DeviceKitUDI); + ~CUDiskDevice() = default; + + void Update(); + + bool Mount(); + bool UnMount(); + + /*! \brief Check if the device is approved/whitelisted + * @return true if the device is approved/whitelisted, false otherwise + */ + bool IsApproved() const; + + /*! \brief Get the storage type of this device + * @return the storage type (e.g. OPTICAL) or UNKNOWN if + * the type couldn't be detected + */ + MEDIA_DETECT::STORAGE::Type GetStorageType() const; + + /*! \brief Check if the device is optical + * @return true if the device is optical, false otherwise + */ + bool IsOptical() const; + + /*! \brief Check if the device is mounted + * @return true if the device is mounted, false otherwise + */ + bool IsMounted() const; + + /*! \brief Check if the device is internal to the system + * @return true if the device is internal to the system, false otherwise + */ + bool IsSystemInternal() const; + + /*! \brief Get the device display name/label + * @return the device display name/label + */ + std::string GetDisplayName() const; + + /*! \brief Get the device mount point + * @return the device mount point + */ + std::string GetMountPoint() const; + + /*! \brief Get a representation of the device as a readable string + * @return device as a string + */ + std::string ToString() const; + + /*! \brief Get a representation of the device as a media share + * @return the media share + */ + CMediaSource ToMediaShare() const; + + /*! \brief Get a representation of the device as a storage device abstraction + * @return the storage device abstraction of the device + */ + MEDIA_DETECT::STORAGE::StorageDevice ToStorageDevice() const; + +private: + std::string m_UDI; + std::string m_DeviceKitUDI; + std::string m_MountPath; + std::string m_FileSystem; + std::string m_Label; + bool m_isMounted; + bool m_isMountedByUs; + bool m_isRemovable; + bool m_isPartition; + bool m_isFileSystem; + bool m_isSystemInternal; + bool m_isOptical; + int64_t m_PartitionSize; +}; + +class CUDisksProvider : public IStorageProvider +{ +public: + CUDisksProvider(); + ~CUDisksProvider() override; + + void Initialize() override; + void Stop() override { } + + void GetLocalDrives(VECSOURCES &localDrives) override { GetDisks(localDrives, false); } + void GetRemovableDrives(VECSOURCES &removableDrives) override { GetDisks(removableDrives, true); } + + bool Eject(const std::string& mountpath) override; + + std::vector<std::string> GetDiskUsage() override; + + bool PumpDriveChangeEvents(IStorageEventsCallback *callback) override; + + static bool HasUDisks(); +private: + typedef std::map<std::string, CUDiskDevice *> DeviceMap; + typedef std::pair<std::string, CUDiskDevice *> DevicePair; + + void DeviceAdded(const char *object, IStorageEventsCallback *callback); + void DeviceRemoved(const char *object, IStorageEventsCallback *callback); + void DeviceChanged(const char *object, IStorageEventsCallback *callback); + + std::vector<std::string> EnumerateDisks(); + + void GetDisks(VECSOURCES& devices, bool EnumerateRemovable); + + int m_DaemonVersion; + + DeviceMap m_AvailableDevices; + + CDBusConnection m_connection; +}; |