Solid

iokitvolume.cpp
1/*
2 SPDX-FileCopyrightText: 2017 René J.V. Bertin <rjvbertin@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "iokitvolume.h"
8#include "iokitgenericinterface.h"
9
10#include <CoreFoundation/CoreFoundation.h>
11
12using namespace Solid::Backends::IOKit;
13
14IOKitVolume::IOKitVolume(IOKitDevice *device)
15 : Block(device)
16 , daDict(new DADictionary(device))
17{
18}
19
20IOKitVolume::IOKitVolume(const IOKitDevice *device)
21 : Block(device)
22 , daDict(new DADictionary(device))
23{
24}
25
26IOKitVolume::~IOKitVolume()
27{
28 delete daDict;
29}
30
31bool IOKitVolume::isIgnored() const
32{
33 // ignore storage volumes that aren't mounted
34 bool isIgnored = m_device->property(QStringLiteral("Open")).toBool() == false;
35 m_device->setProperty("isIgnored", isIgnored);
36 m_device->setProperty("isMounted", !isIgnored);
37 return isIgnored;
38}
39
40Solid::StorageVolume::UsageType IOKitVolume::usage() const
41{
42 const QString content = m_device->property(QStringLiteral("Content")).toString();
43 if (content == QStringLiteral("CD_DA")) {
44 // this is (probably) a CD track
45 return Solid::StorageVolume::Other;
46 }
47 if (content.contains(QStringLiteral("partition_scheme"))) {
48 return Solid::StorageVolume::PartitionTable;
49 }
50 return Solid::StorageVolume::FileSystem;
51}
52
53QString IOKitVolume::fsType() const
54{
55 return daDict->stringForKey(kDADiskDescriptionVolumeKindKey);
56}
57
58QString IOKitVolume::label() const
59{
60 return daDict->stringForKey(kDADiskDescriptionVolumeNameKey);
61}
62
63QString IOKitVolume::uuid() const
64{
65 return m_device->property(QStringLiteral("UUID")).toString();
66}
67
68qulonglong IOKitVolume::size() const
69{
70 return m_device->property(QStringLiteral("Size")).toULongLong();
71}
72
73QString IOKitVolume::encryptedContainerUdi() const
74{
75 return QString();
76}
77
78QString IOKitVolume::vendor() const
79{
80 return daDict->stringForKey(kDADiskDescriptionDeviceVendorKey);
81}
82
83QString IOKitVolume::product() const
84{
85 return daDict->stringForKey(kDADiskDescriptionDeviceModelKey);
86}
87
88QString IOKitVolume::description() const
89{
90 return daDict->stringForKey(kDADiskDescriptionMediaNameKey);
91}
92
93DADiskRef IOKitVolume::daRef() const
94{
95 return daDict->daRef;
96}
97
98#include "moc_iokitvolume.cpp"
UsageType
This enum type defines the how a volume is used.
bool setProperty(const char *name, QVariant &&value)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool toBool() const const
QString toString() const const
qulonglong toULongLong(bool *ok) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:56:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.