Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/iokit/iokitopticaldisc.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright 2006 Kevin Ottens <ervin@kde.org> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #include "iokitopticaldisc.h" | ||||
22 | | ||||
23 | #include <QDebug> | ||||
24 | | ||||
25 | #include <CoreFoundation/CoreFoundation.h> | ||||
26 | | ||||
27 | using namespace Solid::Backends::IOKit; | ||||
28 | | ||||
29 | IOKitOpticalDisc::IOKitOpticalDisc(IOKitDevice *device) | ||||
30 | : IOKitVolume(device) | ||||
31 | { | ||||
32 | } | ||||
33 | | ||||
34 | IOKitOpticalDisc::IOKitOpticalDisc(const IOKitDevice *device) | ||||
35 | : IOKitVolume(device) | ||||
36 | { | ||||
37 | } | ||||
38 | | ||||
39 | IOKitOpticalDisc::~IOKitOpticalDisc() | ||||
40 | { | ||||
41 | } | ||||
42 | | ||||
43 | QString IOKitOpticalDisc::device() const | ||||
44 | { | ||||
45 | const QString devName = m_device->property(QLatin1String("BSD Name")).toString(); | ||||
46 | if (devName.startsWith(QLatin1Char('r'))) { | ||||
47 | return QStringLiteral("/dev/") + devName; | ||||
48 | } else { | ||||
49 | return QStringLiteral("/dev/r") + devName; | ||||
50 | } | ||||
51 | } | ||||
52 | | ||||
53 | Solid::OpticalDisc::ContentTypes IOKitOpticalDisc::availableContent() const | ||||
54 | { | ||||
55 | if (fsType() == QStringLiteral("cddafs")) { | ||||
56 | return Solid::OpticalDisc::Audio; | ||||
57 | } | ||||
58 | return Solid::OpticalDisc::Data; | ||||
59 | } | ||||
60 | | ||||
61 | Solid::OpticalDisc::DiscType IOKitOpticalDisc::discType() const | ||||
62 | { | ||||
63 | QString type = m_device->property(QStringLiteral("Type")).toString(); | ||||
64 | | ||||
65 | if (type == "CD-ROM") { | ||||
66 | return Solid::OpticalDisc::CdRom; | ||||
67 | } else if (type == "CD-R") { | ||||
68 | return Solid::OpticalDisc::CdRecordable; | ||||
69 | } else if (type == "CD-RW") { | ||||
70 | return Solid::OpticalDisc::CdRewritable; | ||||
71 | } else if (type == "DVD-ROM") { | ||||
72 | return Solid::OpticalDisc::DvdRom; | ||||
73 | } else if (type == "DVD-RAM") { | ||||
74 | return Solid::OpticalDisc::DvdRam; | ||||
75 | } else if (type == "DVD-R") { | ||||
76 | return Solid::OpticalDisc::DvdRecordable; | ||||
77 | } else if (type == "DVD-RW") { | ||||
78 | return Solid::OpticalDisc::DvdRewritable; | ||||
79 | } else if (type == "DVD+R") { | ||||
80 | return Solid::OpticalDisc::DvdPlusRecordable; | ||||
81 | } else if (type == "DVD+RW") { | ||||
82 | return Solid::OpticalDisc::DvdPlusRewritable; | ||||
83 | } else if (type == "BD-ROM") { | ||||
84 | return Solid::OpticalDisc::BluRayRom; | ||||
85 | } else if (type == "BD-R") { | ||||
86 | return Solid::OpticalDisc::BluRayRecordable; | ||||
87 | } else if (type == "BD-RE") { | ||||
88 | return Solid::OpticalDisc::BluRayRewritable; | ||||
89 | } else if (type == "HD DVD-ROM") { | ||||
90 | return Solid::OpticalDisc::HdDvdRom; | ||||
91 | } else if (type == "HD DVD-R") { | ||||
92 | return Solid::OpticalDisc::HdDvdRecordable; | ||||
93 | } else if (type == "HD DVD-RW") { | ||||
94 | return Solid::OpticalDisc::HdDvdRewritable; | ||||
95 | } else { | ||||
96 | return Solid::OpticalDisc::UnknownDiscType; | ||||
97 | } | ||||
98 | } | ||||
99 | | ||||
100 | bool IOKitOpticalDisc::isAppendable() const | ||||
101 | { | ||||
102 | // TODO! | ||||
103 | return isRewritable(); | ||||
104 | } | ||||
105 | | ||||
106 | bool IOKitOpticalDisc::isBlank() const | ||||
107 | { | ||||
108 | // TODO! | ||||
109 | return isRewritable(); | ||||
110 | } | ||||
111 | | ||||
112 | bool IOKitOpticalDisc::isRewritable() const | ||||
113 | { | ||||
114 | return m_device->property(QStringLiteral("Writable")).toBool(); | ||||
115 | } | ||||
116 | | ||||
117 | qulonglong IOKitOpticalDisc::capacity() const | ||||
118 | { | ||||
119 | return size(); | ||||
120 | } |