Solid

fakestorageaccess.cpp
1/*
2 SPDX-FileCopyrightText: 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 "fakestorageaccess.h"
8
9using namespace Solid::Backends::Fake;
10
11FakeStorageAccess::FakeStorageAccess(FakeDevice *device)
12 : FakeDeviceInterface(device)
13{
14 connect(device, SIGNAL(propertyChanged(QMap<QString, int>)), this, SLOT(onPropertyChanged(QMap<QString, int>)));
15}
16
17FakeStorageAccess::~FakeStorageAccess()
18{
19}
20
21bool FakeStorageAccess::isAccessible() const
22{
23 return fakeDevice()->property(QStringLiteral("isMounted")).toBool();
24}
25
26QString FakeStorageAccess::filePath() const
27{
28 return fakeDevice()->property(QStringLiteral("mountPoint")).toString();
29}
30
31bool FakeStorageAccess::isIgnored() const
32{
33 return fakeDevice()->property(QStringLiteral("isIgnored")).toBool();
34}
35
36bool FakeStorageAccess::isEncrypted() const
37{
38 return fakeDevice()->property(QStringLiteral("isEncrypted")).toBool();
39}
40
41bool FakeStorageAccess::setup()
42{
43 if (fakeDevice()->isBroken() || isAccessible()) {
44 return false;
45 } else {
46 fakeDevice()->setProperty(QStringLiteral("isMounted"), true);
47 return true;
48 }
49}
50
51bool FakeStorageAccess::teardown()
52{
53 if (fakeDevice()->isBroken() || !isAccessible()) {
54 return false;
55 } else {
56 fakeDevice()->setProperty(QStringLiteral("isMounted"), false);
57 return true;
58 }
59}
60
61void Solid::Backends::Fake::FakeStorageAccess::onPropertyChanged(const QMap<QString, int> &changes)
62{
63 for (auto it = changes.cbegin(); it != changes.cend(); ++it) {
64 if (it.key() == QLatin1String(QLatin1String("isMounted"))) {
65 Q_EMIT accessibilityChanged(fakeDevice()->property(QStringLiteral("isMounted")).toBool(), fakeDevice()->udi());
66 }
67 }
68}
69
70#include "moc_fakestorageaccess.cpp"
const_iterator cbegin() const const
const_iterator cend() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
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 Mon Nov 18 2024 12:14:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.