1/*
2 SPDX-FileCopyrightText: 2006-2007 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 "storagedrive.h"
8#include "storagedrive_p.h"
9
10#include "device.h"
11#include "device_p.h"
12#include "predicate.h"
13#include "soliddefs_p.h"
14#include "storageaccess.h"
15#include <solid/devices/ifaces/storagedrive.h>
16
17Solid::StorageDrive::StorageDrive(QObject *backendObject)
18 : DeviceInterface(*new StorageDrivePrivate(), backendObject)
19{
20}
21
22Solid::StorageDrive::StorageDrive(StorageDrivePrivate &dd, QObject *backendObject)
23 : DeviceInterface(dd, backendObject)
24{
25}
26
27Solid::StorageDrive::~StorageDrive()
28{
29}
30
31Solid::StorageDrive::Bus Solid::StorageDrive::bus() const
32{
33 Q_D(const StorageDrive);
34 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), Platform, bus());
35}
36
37Solid::StorageDrive::DriveType Solid::StorageDrive::driveType() const
38{
39 Q_D(const StorageDrive);
40 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), HardDisk, driveType());
41}
42
43bool Solid::StorageDrive::isRemovable() const
44{
45 Q_D(const StorageDrive);
46 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isRemovable());
47}
48
49bool Solid::StorageDrive::isHotpluggable() const
50{
51 Q_D(const StorageDrive);
52 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isHotpluggable());
53}
54
55qulonglong Solid::StorageDrive::size() const
56{
57 Q_D(const StorageDrive);
58 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, size());
59}
60
61bool Solid::StorageDrive::isInUse() const
62{
63 Q_D(const StorageDrive);
64 Predicate p(DeviceInterface::StorageAccess);
65 const QList<Device> devices = Device::listFromQuery(predicate: p, parentUdi: d->devicePrivate()->udi());
66
67 bool inUse = false;
68 for (const Device &dev : devices) {
69 if (dev.is<Solid::StorageAccess>()) {
70 const Solid::StorageAccess *access = dev.as<Solid::StorageAccess>();
71 inUse |= (access->isAccessible());
72 }
73 }
74 return inUse;
75}
76
77QDateTime Solid::StorageDrive::timeDetected() const
78{
79 Q_D(const StorageDrive);
80 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), QDateTime(), timeDetected());
81}
82
83QDateTime Solid::StorageDrive::timeMediaDetected() const
84{
85 Q_D(const StorageDrive);
86 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), QDateTime(), timeMediaDetected());
87}
88
89#include "moc_storagedrive.cpp"
90

source code of solid/src/solid/devices/frontend/storagedrive.cpp