Solid

iokitopticaldisc.cpp
1/*
2 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "iokitopticaldisc.h"
8
9#include <CoreFoundation/CoreFoundation.h>
10
11using namespace Solid::Backends::IOKit;
12
13IOKitOpticalDisc::IOKitOpticalDisc(IOKitDevice *device)
14 : IOKitVolume(device)
15{
16}
17
18IOKitOpticalDisc::IOKitOpticalDisc(const IOKitDevice *device)
19 : IOKitVolume(device)
20{
21}
22
23IOKitOpticalDisc::~IOKitOpticalDisc()
24{
25}
26
27QString IOKitOpticalDisc::device() const
28{
29 const QString devName = m_device->property(QLatin1String("BSD Name")).toString();
30 if (devName.startsWith(QLatin1Char('r'))) {
31 return QStringLiteral("/dev/") + devName;
32 } else {
33 return QStringLiteral("/dev/r") + devName;
34 }
35}
36
37Solid::OpticalDisc::ContentTypes IOKitOpticalDisc::availableContent() const
38{
39 if (fsType() == QStringLiteral("cddafs")) {
40 return Solid::OpticalDisc::Audio;
41 }
42 return Solid::OpticalDisc::Data;
43}
44
45Solid::OpticalDisc::DiscType IOKitOpticalDisc::discType() const
46{
47 QString type = m_device->property(QStringLiteral("Type")).toString();
48
49 if (type == QLatin1String("CD-ROM")) {
50 return Solid::OpticalDisc::CdRom;
51 } else if (type == QLatin1String("CD-R")) {
52 return Solid::OpticalDisc::CdRecordable;
53 } else if (type == QLatin1String("CD-RW")) {
54 return Solid::OpticalDisc::CdRewritable;
55 } else if (type == QLatin1String("DVD-ROM")) {
56 return Solid::OpticalDisc::DvdRom;
57 } else if (type == QLatin1String("DVD-RAM")) {
58 return Solid::OpticalDisc::DvdRam;
59 } else if (type == QLatin1String("DVD-R")) {
60 return Solid::OpticalDisc::DvdRecordable;
61 } else if (type == QLatin1String("DVD-RW")) {
62 return Solid::OpticalDisc::DvdRewritable;
63 } else if (type == QLatin1String("DVD+R")) {
64 return Solid::OpticalDisc::DvdPlusRecordable;
65 } else if (type == QLatin1String("DVD+RW")) {
66 return Solid::OpticalDisc::DvdPlusRewritable;
67 } else if (type == QLatin1String("BD-ROM")) {
68 return Solid::OpticalDisc::BluRayRom;
69 } else if (type == QLatin1String("BD-R")) {
70 return Solid::OpticalDisc::BluRayRecordable;
71 } else if (type == QLatin1String("BD-RE")) {
72 return Solid::OpticalDisc::BluRayRewritable;
73 } else if (type == QLatin1String("HD DVD-ROM")) {
74 return Solid::OpticalDisc::HdDvdRom;
75 } else if (type == QLatin1String("HD DVD-R")) {
76 return Solid::OpticalDisc::HdDvdRecordable;
77 } else if (type == QLatin1String("HD DVD-RW")) {
78 return Solid::OpticalDisc::HdDvdRewritable;
79 } else {
80 return Solid::OpticalDisc::UnknownDiscType;
81 }
82}
83
84bool IOKitOpticalDisc::isAppendable() const
85{
86 // TODO!
87 return isRewritable();
88}
89
90bool IOKitOpticalDisc::isBlank() const
91{
92 // TODO!
93 return isRewritable();
94}
95
96bool IOKitOpticalDisc::isRewritable() const
97{
98 return m_device->property(QStringLiteral("Writable")).toBool();
99}
100
101qulonglong IOKitOpticalDisc::capacity() const
102{
103 return size();
104}
105
106#include "moc_iokitopticaldisc.cpp"
DiscType
This enum type defines the type of optical disc it can be.
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
bool toBool() const const
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:01:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.