Plasma5Support

soliddevicejob.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Viranch Mehta <viranch.mehta@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-only
5*/
6
7#include "soliddevicejob.h"
8
9#include <solid/device.h>
10#include <solid/opticaldisc.h>
11#include <solid/opticaldrive.h>
12#include <solid/storageaccess.h>
13
14#include <QDebug>
15
16void SolidDeviceJob::start()
17{
18 Solid::Device device(m_dest);
19 QString operation = operationName();
20
21 if (operation == QLatin1String("mount")) {
22 if (device.is<Solid::StorageAccess>()) {
23 Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
24 if (access && !access->isAccessible()) {
25 access->setup();
26 }
27 }
28 } else if (operation == QLatin1String("unmount")) {
29 if (device.is<Solid::OpticalDisc>()) {
30 Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
31 if (!drive) {
32 drive = device.parent().as<Solid::OpticalDrive>();
33 }
34 if (drive) {
35 drive->eject();
36 }
37 } else if (device.is<Solid::StorageAccess>()) {
38 Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
39 if (access && access->isAccessible()) {
40 access->teardown();
41 }
42 }
43 }
44
45 emitResult();
46}
void emitResult()
bool isAccessible() const
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.