File indexing completed on 2025-01-26 05:09:00

0001 /*
0002     SPDX-FileCopyrightText: 2010 Jacopo De Simoi <wilderkde@gmail.com>
0003     SPDX-FileCopyrightText: 2014 Lukáš Tinkl <ltinkl@redhat.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QHash>
0011 #include <QObject>
0012 #include <QString>
0013 
0014 #include <Solid/Device>
0015 #include <solid/solidnamespace.h>
0016 
0017 /**
0018  * @brief Class which triggers solid notifications
0019  *
0020  * This is an internal class which listens to solid errors and route them via dbus to an
0021  * appropriate visualization (e.g. the plasma device notifier applet); if such visualization is not available
0022  * errors are shown via regular notifications
0023  *
0024  * @author Jacopo De Simoi <wilderkde at gmail.com>
0025  */
0026 
0027 class KSolidNotify : public QObject
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit KSolidNotify(QObject *parent);
0033 
0034 Q_SIGNALS:
0035     void notify(Solid::ErrorType solidError, const QString &error, const QString &errorDetails, const QString &udi);
0036     void blockingAppsReady(const QStringList &apps);
0037     void clearNotification(const QString &udi);
0038 
0039 protected Q_SLOTS:
0040     void onDeviceAdded(const QString &udi);
0041     void onDeviceRemoved(const QString &udi);
0042 
0043 private:
0044     enum class SolidReplyType {
0045         Setup,
0046         Teardown,
0047         Eject,
0048     };
0049 
0050     void onSolidReply(SolidReplyType type, Solid::ErrorType error, const QVariant &errorData, const QString &udi);
0051 
0052     void connectSignals(Solid::Device *device);
0053     bool isSafelyRemovable(const QString &udi) const;
0054     void queryBlockingApps(const QString &devicePath);
0055 
0056     QHash<QString, Solid::Device> m_devices;
0057 };