Solid

winopticaldisc.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Patrick von Reth <vonreth@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 "winopticaldisc.h"
8#include "winopticaldrive.h"
9
10#include <ntddcdrm.h>
11#include <ntddmmc.h>
12
13using namespace Solid::Backends::Win;
14
15WinOpticalDisc::WinOpticalDisc(WinDevice *device)
16 : WinStorageVolume(device)
17 , m_discType(Solid::OpticalDisc::UnknownDiscType)
18 , m_isRewritable(false)
19{
20 // TODO: blueray etc
21 QMap<ulong, MediaProfiles> profiles = MediaProfiles::profiles(WinBlock::driveLetterFromUdi(m_device->udi()));
22
23 if (profiles[ProfileCdRecordable].active) {
24 m_discType = Solid::OpticalDisc::CdRecordable;
25 } else if (profiles[ProfileCdRewritable].active) {
26 m_discType = Solid::OpticalDisc::CdRewritable;
27 m_isRewritable = true;
28 } else if (profiles[ProfileCdrom].active) {
29 m_discType = Solid::OpticalDisc::CdRom;
30 } else if (profiles[ProfileDvdRecordable].active) {
31 m_discType = Solid::OpticalDisc::DvdRecordable;
32 } else if (profiles[ProfileDvdRewritable].active) {
33 m_discType = Solid::OpticalDisc::DvdRewritable;
34 m_isRewritable = true;
35 } else if (profiles[ProfileDvdRom].active) {
36 m_discType = Solid::OpticalDisc::DvdRom;
37 } else {
38 m_discType = Solid::OpticalDisc::UnknownDiscType;
39 }
40}
41
42WinOpticalDisc::~WinOpticalDisc()
43{
44}
45
46Solid::OpticalDisc::ContentTypes WinOpticalDisc::availableContent() const
47{
48 return Solid::OpticalDisc::NoContent;
49}
50
51Solid::OpticalDisc::DiscType WinOpticalDisc::discType() const
52{
53 return m_discType;
54}
55
56bool WinOpticalDisc::isAppendable() const
57{
58 return false;
59}
60
61bool WinOpticalDisc::isBlank() const
62{
63 wchar_t dLetter[MAX_PATH];
64 int dLetterSize = WinBlock::driveLetterFromUdi(m_device->udi()).toWCharArray(dLetter);
65 dLetter[dLetterSize] = (wchar_t)'\\';
66 dLetter[dLetterSize + 1] = 0;
67
68 ULARGE_INTEGER sizeTotal;
69 ULARGE_INTEGER sizeFree;
70 if (GetDiskFreeSpaceEx(dLetter, &sizeFree, &sizeTotal, NULL)) {
71 return sizeFree.QuadPart > 0 && sizeTotal.QuadPart == 0;
72 }
73 // FIXME: the call will fail on a blank cd, and inf there is no cd, but if we got a disc type we could guess that it is a blank cd
74 return m_discType != Solid::OpticalDisc::UnknownDiscType;
75}
76
77bool WinOpticalDisc::isRewritable() const
78{
79 return m_isRewritable;
80}
81
82qulonglong WinOpticalDisc::capacity() const
83{
84 return size();
85}
86
87#include "moc_winopticaldisc.cpp"
This device interface is available on optical discs.
DiscType
This enum type defines the type of optical disc it can be.
The single responsibility of this class is to create arguments valid for logind Inhibit call.
Definition fakebattery.h:16
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.