2 * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <elvis.angelaccio@kde.org
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #include "placesdatasource.h"
9 #include <KLocalizedString>
10 #include <KMountPoint>
11 #include <KUserFeedback/Provider>
12 #include <Solid/Device>
13 #include <Solid/NetworkShare>
14 #include <Solid/StorageAccess>
18 PlacesDataSource::PlacesDataSource()
19 : KUserFeedback::AbstractDataSource(QStringLiteral("places"), KUserFeedback::Provider::DetailedSystemInformation
)
22 QString
PlacesDataSource::name() const
24 return i18nc("name of kuserfeedback data source provided by dolphin", "Places");
27 QString
PlacesDataSource::description() const
29 // TODO: add count of remote places grouped by protocol type.
30 return i18nc("description of kuserfeedback data source provided by dolphin", "Count of available Network Shares");
33 QVariant
PlacesDataSource::data()
37 bool hasSSHFS
= false;
38 bool hasSambaShare
= false;
39 bool hasNfsShare
= false;
41 const auto devices
= Solid::Device::listFromType(Solid::DeviceInterface::NetworkShare
);
42 for (const auto &device
: devices
) {
43 if (!hasSSHFS
&& device
.vendor() == QLatin1String("fuse.sshfs")) {
44 // Ignore kdeconnect SSHFS mounts, we already know that people have those.
45 auto storageAccess
= device
.as
<Solid::StorageAccess
>();
47 auto mountPoint
= KMountPoint::currentMountPoints().findByPath(storageAccess
->filePath());
48 if (mountPoint
&& !mountPoint
->mountedFrom().startsWith(QLatin1String("kdeconnect@"))) {
55 if (!device
.is
<Solid::NetworkShare
>()) {
59 switch (device
.as
<Solid::NetworkShare
>()->type()) {
60 case Solid::NetworkShare::Cifs
:
63 case Solid::NetworkShare::Nfs
:
71 map
.insert(QStringLiteral("hasSSHFSMount"), hasSSHFS
);
72 map
.insert(QStringLiteral("hasSambaShare"), hasSambaShare
);
73 map
.insert(QStringLiteral("hasNfsShare"), hasNfsShare
);