mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
solid: parent the QSocketNotifier to UdevQt::Client
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8d3250d896
commit
e6aef8e5d5
2 changed files with 10 additions and 7 deletions
|
@ -70,20 +70,20 @@ class Client : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Client(const QList<QByteArray> &subsystems, QObject *parent = 0);
|
Client(const QList<QByteArray> &subsystems, QObject *parent = nullptr);
|
||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
DeviceList allDevices();
|
DeviceList allDevices();
|
||||||
Device deviceBySysfsPath(const QString &sysfsPath);
|
Device deviceBySysfsPath(const QString &sysfsPath);
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void deviceAdded(const UdevQt::Device &dev);
|
void deviceAdded(const UdevQt::Device &dev);
|
||||||
void deviceRemoved(const UdevQt::Device &dev);
|
void deviceRemoved(const UdevQt::Device &dev);
|
||||||
void deviceChanged(const UdevQt::Device &dev);
|
void deviceChanged(const UdevQt::Device &dev);
|
||||||
void deviceOnlined(const UdevQt::Device &dev);
|
void deviceOnlined(const UdevQt::Device &dev);
|
||||||
void deviceOfflined(const UdevQt::Device &dev);
|
void deviceOfflined(const UdevQt::Device &dev);
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void monitorReadyRead(int fd);
|
void monitorReadyRead(int fd);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -22,8 +22,11 @@
|
||||||
|
|
||||||
namespace UdevQt {
|
namespace UdevQt {
|
||||||
|
|
||||||
Client::Client(const QList<QByteArray>& subsystems, QObject *parent)
|
Client::Client(const QList<QByteArray> &subsystems, QObject *parent)
|
||||||
: QObject(parent), m_udev(udev_new()), m_monitor(0), m_monitorNotifier(0)
|
: QObject(parent),
|
||||||
|
m_udev(udev_new()),
|
||||||
|
m_monitor(nullptr),
|
||||||
|
m_monitorNotifier(nullptr)
|
||||||
{
|
{
|
||||||
// create a listener
|
// create a listener
|
||||||
m_monitor = udev_monitor_new_from_netlink(m_udev, "udev");
|
m_monitor = udev_monitor_new_from_netlink(m_udev, "udev");
|
||||||
|
@ -39,8 +42,8 @@ Client::Client(const QList<QByteArray>& subsystems, QObject *parent)
|
||||||
|
|
||||||
// start the monitor receiving
|
// start the monitor receiving
|
||||||
udev_monitor_enable_receiving(m_monitor);
|
udev_monitor_enable_receiving(m_monitor);
|
||||||
m_monitorNotifier = new QSocketNotifier(udev_monitor_get_fd(m_monitor), QSocketNotifier::Read);
|
m_monitorNotifier = new QSocketNotifier(udev_monitor_get_fd(m_monitor), QSocketNotifier::Read, this);
|
||||||
QObject::connect(m_monitorNotifier, SIGNAL(activated(int)), this, SLOT(monitorReadyRead(int)));
|
connect(m_monitorNotifier, SIGNAL(activated(int)), this, SLOT(monitorReadyRead(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::~Client()
|
Client::~Client()
|
||||||
|
|
Loading…
Add table
Reference in a new issue