Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/mounts/mountsdevice.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 by David Hallas <david@davidhallas.dk> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This program is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
12 | * GNU General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU General Public License * | ||||
15 | * along with this program; if not, write to the * | ||||
16 | * Free Software Foundation, Inc., * | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||||
18 | ***************************************************************************/ | ||||
19 | | ||||
20 | #include "mountsdevice.h" | ||||
21 | #include "mounts.h" | ||||
22 | #include "mountsstorageaccess.h" | ||||
23 | #include <QDebug> | ||||
24 | | ||||
25 | using namespace Solid::Backends::Mounts; | ||||
26 | | ||||
27 | MountsDevice::MountsDevice(QString udi) : | ||||
28 | m_udi(udi) | ||||
29 | { | ||||
30 | } | ||||
31 | | ||||
32 | MountsDevice::~MountsDevice() | ||||
33 | { | ||||
34 | } | ||||
35 | | ||||
36 | QString MountsDevice::udi() const | ||||
37 | { | ||||
38 | return m_udi; | ||||
39 | } | ||||
40 | | ||||
41 | QString MountsDevice::parentUdi() const | ||||
42 | { | ||||
43 | return QLatin1String(MOUNTS_UDI_PREFIX); | ||||
44 | } | ||||
45 | | ||||
46 | QString MountsDevice::vendor() const | ||||
47 | { | ||||
48 | return QString(); | ||||
49 | } | ||||
50 | | ||||
51 | QString MountsDevice::product() const | ||||
52 | { | ||||
53 | return QString(); | ||||
54 | } | ||||
55 | | ||||
56 | QString MountsDevice::icon() const | ||||
57 | { | ||||
58 | return QStringLiteral("drive-harddisk"); | ||||
59 | } | ||||
60 | | ||||
61 | QStringList MountsDevice::emblems() const | ||||
62 | { | ||||
63 | QStringList ret; | ||||
64 | ret << "emblem-mounted"; | ||||
65 | return ret; | ||||
66 | } | ||||
67 | | ||||
68 | QString MountsDevice::description() const | ||||
69 | { | ||||
70 | const FuseMount *fuseMount = Mounts::fuseMountFromUdi(m_udi); | ||||
71 | if (!fuseMount) { | ||||
72 | return QString(); | ||||
73 | } | ||||
74 | return QString("%1 device").arg(fuseMount->device); | ||||
75 | } | ||||
76 | | ||||
77 | bool MountsDevice::queryDeviceInterface(const Solid::DeviceInterface::Type& type) const | ||||
78 | { | ||||
79 | return (type == Solid::DeviceInterface::StorageAccess); | ||||
80 | } | ||||
81 | | ||||
82 | QObject *MountsDevice::createDeviceInterface(const Solid::DeviceInterface::Type& type) | ||||
83 | { | ||||
84 | if (type == Solid::DeviceInterface::StorageAccess) { | ||||
85 | return new MountsStorageAccess(this, m_udi); | ||||
86 | } | ||||
87 | return nullptr; | ||||
88 | } |