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 == "CD-ROM") {
50 return Solid::OpticalDisc::CdRom;
51 } else if (type == "CD-R") {
52 return Solid::OpticalDisc::CdRecordable;
53 } else if (type == "CD-RW") {
54 return Solid::OpticalDisc::CdRewritable;
55 } else if (type == "DVD-ROM") {
56 return Solid::OpticalDisc::DvdRom;
57 } else if (type == "DVD-RAM") {
58 return Solid::OpticalDisc::DvdRam;
59 } else if (type == "DVD-R") {
60 return Solid::OpticalDisc::DvdRecordable;
61 } else if (type == "DVD-RW") {
62 return Solid::OpticalDisc::DvdRewritable;
63 } else if (type == "DVD+R") {
64 return Solid::OpticalDisc::DvdPlusRecordable;
65 } else if (type == "DVD+RW") {
66 return Solid::OpticalDisc::DvdPlusRewritable;
67 } else if (type == "BD-ROM") {
68 return Solid::OpticalDisc::BluRayRom;
69 } else if (type == "BD-R") {
70 return Solid::OpticalDisc::BluRayRecordable;
71 } else if (type == "BD-RE") {
72 return Solid::OpticalDisc::BluRayRewritable;
73 } else if (type == "HD DVD-ROM") {
74 return Solid::OpticalDisc::HdDvdRom;
75 } else if (type == "HD DVD-R") {
76 return Solid::OpticalDisc::HdDvdRecordable;
77 } else if (type == "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.
Type type(const QSqlDatabase &db)
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 May 3 2024 11:47:59 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.