/* * SPDX-FileCopyrightText: 2020 Elvis Angelaccio #include #include #include #include #include #include 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(); if (storageAccess) { auto mountPoint = KMountPoint::currentMountPoints().findByPath(storageAccess->filePath()); if (mountPoint && !mountPoint->mountedFrom().startsWith(QLatin1String("kdeconnect@"))) { hasSSHFS = true; continue; } } } if (!device.is()) { continue; } switch (device.as()->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; }