Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/upower/upowermanager.cpp
Show All 31 Lines | |||||
32 | 32 | | |||
33 | using namespace Solid::Backends::UPower; | 33 | using namespace Solid::Backends::UPower; | ||
34 | using namespace Solid::Backends::Shared; | 34 | using namespace Solid::Backends::Shared; | ||
35 | 35 | | |||
36 | UPowerManager::UPowerManager(QObject *parent) | 36 | UPowerManager::UPowerManager(QObject *parent) | ||
37 | : Solid::Ifaces::DeviceManager(parent), | 37 | : Solid::Ifaces::DeviceManager(parent), | ||
38 | m_manager(UP_DBUS_SERVICE, | 38 | m_manager(UP_DBUS_SERVICE, | ||
39 | UP_DBUS_PATH, | 39 | UP_DBUS_PATH, | ||
40 | UP_DBUS_INTERFACE, | | |||
41 | QDBusConnection::systemBus()) | 40 | QDBusConnection::systemBus()) | ||
42 | { | 41 | { | ||
43 | m_supportedInterfaces | 42 | m_supportedInterfaces | ||
44 | << Solid::DeviceInterface::GenericInterface | 43 | << Solid::DeviceInterface::GenericInterface | ||
45 | << Solid::DeviceInterface::Battery; | 44 | << Solid::DeviceInterface::Battery; | ||
46 | 45 | | |||
47 | qDBusRegisterMetaType<QList<QDBusObjectPath> >(); | 46 | qDBusRegisterMetaType<QList<QDBusObjectPath> >(); | ||
48 | qDBusRegisterMetaType<QVariantMap>(); | 47 | qDBusRegisterMetaType<QVariantMap>(); | ||
Show All 9 Lines | 50 | if (!serviceFound) { | |||
58 | QDBusReply<QStringList> reply = QDBusConnection::systemBus().call(message); | 57 | QDBusReply<QStringList> reply = QDBusConnection::systemBus().call(message); | ||
59 | if (reply.isValid() && reply.value().contains(UP_DBUS_SERVICE)) { | 58 | if (reply.isValid() && reply.value().contains(UP_DBUS_SERVICE)) { | ||
60 | QDBusConnection::systemBus().interface()->startService(UP_DBUS_SERVICE); | 59 | QDBusConnection::systemBus().interface()->startService(UP_DBUS_SERVICE); | ||
61 | serviceFound = true; | 60 | serviceFound = true; | ||
62 | } | 61 | } | ||
63 | } | 62 | } | ||
64 | 63 | | |||
65 | if (serviceFound) { | 64 | if (serviceFound) { | ||
66 | if (m_manager.metaObject()->indexOfSignal("DeviceAdded(QDBusObjectPath)") != -1) { | 65 | connect(&m_manager, &OrgFreedesktopUPowerInterface::DeviceAdded, | ||
67 | // for UPower >= 0.99.0, changed signature :o/ | 66 | this, &UPowerManager::onDeviceAdded); | ||
68 | connect(&m_manager, SIGNAL(DeviceAdded(QDBusObjectPath)), | 67 | connect(&m_manager, &OrgFreedesktopUPowerInterface::DeviceRemoved, | ||
69 | this, SLOT(onDeviceAdded(QDBusObjectPath))); | 68 | this, &UPowerManager::onDeviceRemoved); | ||
70 | connect(&m_manager, SIGNAL(DeviceRemoved(QDBusObjectPath)), | | |||
71 | this, SLOT(onDeviceRemoved(QDBusObjectPath))); | | |||
72 | } else { | | |||
73 | connect(&m_manager, SIGNAL(DeviceAdded(QString)), | | |||
74 | this, SIGNAL(deviceAdded(QString))); | | |||
75 | connect(&m_manager, SIGNAL(DeviceRemoved(QString)), | | |||
76 | this, SIGNAL(deviceRemoved(QString))); | | |||
77 | } | | |||
78 | } | 69 | } | ||
79 | } | 70 | } | ||
80 | 71 | | |||
81 | UPowerManager::~UPowerManager() | 72 | UPowerManager::~UPowerManager() | ||
82 | { | 73 | { | ||
83 | } | 74 | } | ||
84 | 75 | | |||
85 | QObject *UPowerManager::createDevice(const QString &udi) | 76 | QObject *UPowerManager::createDevice(const QString &udi) | ||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |