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 <KUserFeedbackQt6/Provider>
12 #include <Solid/Device>
13 #include <Solid/NetworkShare>
14 #include <Solid/StorageAccess>
18 PlacesDataSource::PlacesDataSource()
19 : KUserFeedback::AbstractDataSource(QStringLiteral("places"), KUserFeedback::Provider::DetailedSystemInformation
)
23 QString
PlacesDataSource::name() const
25 return i18nc("name of kuserfeedback data source provided by dolphin", "Places");
28 QString
PlacesDataSource::description() const
30 // TODO: add count of remote places grouped by protocol type.
31 return i18nc("description of kuserfeedback data source provided by dolphin", "Count of available Network Shares");
34 QVariant
PlacesDataSource::data()
38 bool hasSSHFS
= false;
39 bool hasSambaShare
= false;
40 bool hasNfsShare
= false;
42 const auto devices
= Solid::Device::listFromType(Solid::DeviceInterface::NetworkShare
);
43 for (const auto &device
: devices
) {
44 if (!hasSSHFS
&& device
.vendor() == QLatin1String("fuse.sshfs")) {
45 // Ignore kdeconnect SSHFS mounts, we already know that people have those.
46 auto storageAccess
= device
.as
<Solid::StorageAccess
>();
48 auto mountPoint
= KMountPoint::currentMountPoints().findByPath(storageAccess
->filePath());
49 if (mountPoint
&& !mountPoint
->mountedFrom().startsWith(QLatin1String("kdeconnect@"))) {
56 if (!device
.is
<Solid::NetworkShare
>()) {
60 switch (device
.as
<Solid::NetworkShare
>()->type()) {
61 case Solid::NetworkShare::Cifs
:
64 case Solid::NetworkShare::Nfs
:
72 map
.insert(QStringLiteral("hasSSHFSMount"), hasSSHFS
);
73 map
.insert(QStringLiteral("hasSambaShare"), hasSambaShare
);
74 map
.insert(QStringLiteral("hasNfsShare"), hasNfsShare
);