Update nymea dbus interface

This commit is contained in:
Simon Stürz 2018-03-13 11:32:07 +01:00
parent f4b6003664
commit a81497e760
3 changed files with 19 additions and 2 deletions

2
debian/control vendored
View File

@ -7,6 +7,8 @@ Build-Depends: debhelper (>= 9.0.0),
dh-systemd,
qt5-default,
qtbase5-dev,
qtbase5-dev-tools,
libqt5bluetooth5,
qtconnectivity5-dev
Standards-Version: 3.9.7

View File

@ -31,14 +31,14 @@ bool NymeadService::available() const
void NymeadService::enableBluetooth(const bool &enable)
{
if (!m_nymeadHardwareInterface) {
if (!m_nymeadHardwareBluetoothInterface) {
qCWarning(dcNymeaService()) << "Could not enable/disable bluetooth hardware resource. D-Bus interface not available.";
return;
}
qCDebug(dcNymeaService()) << "Request nymea to" << (enable ? "enable" : "disable") << "bluetooth resources";
QDBusMessage query = m_nymeadHardwareInterface->call("EnableBluetooth", enable);
QDBusMessage query = m_nymeadHardwareBluetoothInterface->call("EnableBluetooth", enable);
if(query.type() != QDBusMessage::ReplyMessage) {
qCWarning(dcNymeaService()) << "Could not enable/disable bluetooth on dbus:" << query.errorName() << query.errorMessage();
return;
@ -91,6 +91,14 @@ bool NymeadService::init()
return false;
}
m_nymeadHardwareBluetoothInterface = new QDBusInterface("io.guh.nymead", "/io/guh/nymead/HardwareManager/BluetoothLEManager", "io.guh.nymead", QDBusConnection::systemBus(), this);
if (!m_nymeadHardwareBluetoothInterface->isValid()) {
qCWarning(dcNymeaService()) << "Invalid D-Bus HardwareManager BluetoothLE interface.";
m_nymeadHardwareBluetoothInterface->deleteLater();
m_nymeadHardwareBluetoothInterface = nullptr;
return false;
}
setAvailable(true);
return true;
}
@ -117,5 +125,10 @@ void NymeadService::serviceUnregistered(const QString &serviceName)
m_nymeadHardwareInterface = nullptr;
}
if (m_nymeadHardwareBluetoothInterface) {
m_nymeadHardwareBluetoothInterface->deleteLater();
m_nymeadHardwareBluetoothInterface = nullptr;
}
setAvailable(false);
}

View File

@ -22,7 +22,9 @@ public:
private:
QDBusServiceWatcher *m_serviceWatcher = nullptr;
PushButtonAgent *m_pushButtonAgent = nullptr;
QDBusInterface *m_nymeadHardwareInterface = nullptr;
QDBusInterface *m_nymeadHardwareBluetoothInterface = nullptr;
bool m_pushbuttonEnabled = false;
bool m_available = false;