diff options
| author | Elvis Angelaccio <[email protected]> | 2020-08-18 23:47:53 +0200 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2020-11-05 18:31:28 +0000 |
| commit | 465e06138e8baaefb967d32a2eaccf67daef8285 (patch) | |
| tree | 1b6ec2114228a7429b01b670f43d75d1ff0ee0ed /src/userfeedback/placesdatasource.cpp | |
| parent | 61bf84c13d203840d4ffeb55ce92dc8b660871a1 (diff) | |
Add support for KUserFeedback
This commit introduces KUserFeedback in dolphin with some basic data
sources and with a settings page to configure the telemetry values.
There are also a couple custom data sources as proof of concept: a bunch
of settings and the count of available network shares as listed by Solid.
The settings page is shown only if the user feedback framework is
enabled, but currently in Plasma we don't have a global kill switch to
disable it.
At the moment we never show an encouragement message. We need to connect
to the `Provider::showEncouragementMessage()` signal, but first we
should agree to a common way to show a non-annoying message to the users.
Diffstat (limited to 'src/userfeedback/placesdatasource.cpp')
| -rw-r--r-- | src/userfeedback/placesdatasource.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/userfeedback/placesdatasource.cpp b/src/userfeedback/placesdatasource.cpp new file mode 100644 index 000000000..6db89636d --- /dev/null +++ b/src/userfeedback/placesdatasource.cpp @@ -0,0 +1,76 @@ +/* + * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <[email protected] + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "placesdatasource.h" + +#include <KLocalizedString> +#include <KMountPoint> +#include <KUserFeedback/Provider> +#include <Solid/Device> +#include <Solid/NetworkShare> +#include <Solid/StorageAccess> + +#include <QVariant> + +PlacesDataSource::PlacesDataSource() + : KUserFeedback::AbstractDataSource(QStringLiteral("places"), KUserFeedback::Provider::DetailedSystemInformation) +{} + +QString PlacesDataSource::name() const +{ + return i18nc("name of kuserfeedback data source provided by dolphin", "Places"); +} + +QString PlacesDataSource::description() const +{ + // TODO: add count of remote places grouped by protocol type. + return i18nc("description of kuserfeedback data source provided by dolphin", "Count of available Network Shares"); +} + +QVariant PlacesDataSource::data() +{ + QVariantMap map; + + bool hasSSHFS = false; + bool hasSambaShare = false; + bool hasNfsShare = false; + + const auto devices = Solid::Device::listFromType(Solid::DeviceInterface::NetworkShare); + for (const auto &device : devices) { + if (!hasSSHFS && device.vendor() == QLatin1String("fuse.sshfs")) { + // Ignore kdeconnect SSHFS mounts, we already know that people have those. + auto storageAccess = device.as<Solid::StorageAccess>(); + if (storageAccess) { + auto mountPoint = KMountPoint::currentMountPoints().findByPath(storageAccess->filePath()); + if (!mountPoint->mountedFrom().startsWith(QLatin1String("kdeconnect@"))) { + hasSSHFS = true; + continue; + } + } + } + + if (!device.is<Solid::NetworkShare>()) { + continue; + } + + switch (device.as<Solid::NetworkShare>()->type()) { + case Solid::NetworkShare::Cifs: + hasSambaShare = true; + continue; + case Solid::NetworkShare::Nfs: + hasNfsShare = true; + continue; + default: + continue; + } + } + + map.insert(QStringLiteral("hasSSHFSMount"), hasSSHFS); + map.insert(QStringLiteral("hasSambaShare"), hasSambaShare); + map.insert(QStringLiteral("hasNfsShare"), hasNfsShare); + + return map; +} |
