cleanup libnymea api to enforce less linking on plugins
This commit is contained in:
parent
5b59c8f96e
commit
bec536af7d
@ -149,11 +149,13 @@ bool BluetoothLowEnergyManagerImplementation::enabled() const
|
|||||||
|
|
||||||
void BluetoothLowEnergyManagerImplementation::setEnabled(bool enabled)
|
void BluetoothLowEnergyManagerImplementation::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (m_enabled == enabled)
|
if (enabled && !m_enabled) {
|
||||||
return;
|
m_enabled = enable();
|
||||||
|
emit enabledChanged(m_enabled);
|
||||||
m_enabled = enabled;
|
} else if (!enabled && m_enabled) {
|
||||||
emit enabledChanged(m_enabled);
|
m_enabled = disable();
|
||||||
|
emit enabledChanged(m_enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothLowEnergyManagerImplementation::onReconnectTimeout()
|
void BluetoothLowEnergyManagerImplementation::onReconnectTimeout()
|
||||||
@ -214,25 +216,23 @@ void BluetoothLowEnergyManagerImplementation::onDiscoveryError(const QBluetoothD
|
|||||||
|
|
||||||
bool BluetoothLowEnergyManagerImplementation::enable()
|
bool BluetoothLowEnergyManagerImplementation::enable()
|
||||||
{
|
{
|
||||||
qCDebug(dcBluetooth()) << "Hardware resource enabled.";
|
if (!available()) {
|
||||||
setEnabled(true);
|
qCWarning(dcBluetooth()) << "Bluetooth hardware not available. Cannot enable Hardware resource";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
foreach (QPointer<BluetoothLowEnergyDeviceImplementation> bluetoothDevice, m_devices) {
|
foreach (QPointer<BluetoothLowEnergyDeviceImplementation> bluetoothDevice, m_devices) {
|
||||||
bluetoothDevice->setEnabled(true);
|
bluetoothDevice->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
qCDebug(dcBluetooth()) << "Hardware resource enabled.";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BluetoothLowEnergyManagerImplementation::disable()
|
bool BluetoothLowEnergyManagerImplementation::disable()
|
||||||
{
|
{
|
||||||
qCDebug(dcBluetooth()) << "Hardware resource disabled.";
|
|
||||||
setEnabled(false);
|
|
||||||
|
|
||||||
foreach (QPointer<BluetoothLowEnergyDeviceImplementation> bluetoothDevice, m_devices) {
|
foreach (QPointer<BluetoothLowEnergyDeviceImplementation> bluetoothDevice, m_devices) {
|
||||||
bluetoothDevice->setEnabled(false);
|
bluetoothDevice->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
qCDebug(dcBluetooth()) << "Hardware resource disabled.";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "pushbuttondbusservice.h"
|
#include "pushbuttondbusservice.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
#include "nymeadbusservice.h"
|
||||||
|
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -28,10 +29,12 @@
|
|||||||
|
|
||||||
namespace nymeaserver {
|
namespace nymeaserver {
|
||||||
|
|
||||||
PushButtonDBusService::PushButtonDBusService(const QString &objectPath, UserManager *parent) : NymeaDBusService(objectPath, parent),
|
PushButtonDBusService::PushButtonDBusService(const QString &objectPath, UserManager *parent) :
|
||||||
|
QObject(parent),
|
||||||
m_userManager(parent)
|
m_userManager(parent)
|
||||||
{
|
{
|
||||||
if (!isValid()) {
|
NymeaDBusService* dbusService = new NymeaDBusService(objectPath, this);
|
||||||
|
if (!dbusService->isValid()) {
|
||||||
qCWarning(dcUserManager()) << "Failed to register PushButton D-Bus service.";
|
qCWarning(dcUserManager()) << "Failed to register PushButton D-Bus service.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,13 +23,13 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDBusObjectPath>
|
#include <QDBusObjectPath>
|
||||||
|
#include <QDBusContext>
|
||||||
|
|
||||||
#include "usermanager.h"
|
#include "usermanager.h"
|
||||||
#include "nymeadbusservice.h"
|
|
||||||
|
|
||||||
namespace nymeaserver {
|
namespace nymeaserver {
|
||||||
|
|
||||||
class PushButtonDBusService : public NymeaDBusService
|
class PushButtonDBusService : public QObject, public QDBusContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -58,6 +58,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hardwaremanager.h"
|
#include "hardwaremanager.h"
|
||||||
|
#include "hardwareresource.h"
|
||||||
|
|
||||||
/*! Constructs a new HardwareManager with the given \a parent.*/
|
/*! Constructs a new HardwareManager with the given \a parent.*/
|
||||||
HardwareManager::HardwareManager(QObject *parent) :
|
HardwareManager::HardwareManager(QObject *parent) :
|
||||||
|
|||||||
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "hardwareresource.h"
|
|
||||||
|
|
||||||
class Radio433;
|
class Radio433;
|
||||||
class UpnpDiscovery;
|
class UpnpDiscovery;
|
||||||
class PluginTimerManager;
|
class PluginTimerManager;
|
||||||
@ -34,6 +32,7 @@ class NetworkAccessManager;
|
|||||||
class UpnpDeviceDescriptor;
|
class UpnpDeviceDescriptor;
|
||||||
class QtAvahiServiceBrowser;
|
class QtAvahiServiceBrowser;
|
||||||
class BluetoothLowEnergyManager;
|
class BluetoothLowEnergyManager;
|
||||||
|
class HardwareResource;
|
||||||
|
|
||||||
class HardwareManager : public QObject
|
class HardwareManager : public QObject
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,13 +64,14 @@
|
|||||||
#include "hardwareresource.h"
|
#include "hardwareresource.h"
|
||||||
#include "hardwaremanager.h"
|
#include "hardwaremanager.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
#include "nymeadbusservice.h"
|
||||||
|
|
||||||
/*! Constructs a new HardwareResource with the given \a name and \a parent. */
|
/*! Constructs a new HardwareResource with the given \a name and \a parent. */
|
||||||
HardwareResource::HardwareResource(const QString &name, QObject *parent) :
|
HardwareResource::HardwareResource(const QString &name, QObject *parent) :
|
||||||
NymeaDBusService("/io/guh/nymead/HardwareManager/" + name, parent),
|
QObject(parent),
|
||||||
m_name(name)
|
m_name(name)
|
||||||
{
|
{
|
||||||
|
new NymeaDBusService("/io/guh/nymead/HardwareManager/" + name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Returns the name of this resource. */
|
/*! Returns the name of this resource. */
|
||||||
|
|||||||
@ -24,9 +24,8 @@
|
|||||||
#define HARDWARERESOURCE_H
|
#define HARDWARERESOURCE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "nymeadbusservice.h"
|
|
||||||
|
|
||||||
class HardwareResource : public NymeaDBusService
|
class HardwareResource : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ NymeaDBusService::NymeaDBusService(const QString &objectPath, QObject *parent) :
|
|||||||
finalObjectPath.append(part.at(0).toUpper());
|
finalObjectPath.append(part.at(0).toUpper());
|
||||||
finalObjectPath.append(part.right(part.length() - 1));
|
finalObjectPath.append(part.right(part.length() - 1));
|
||||||
}
|
}
|
||||||
status = s_connection.registerObject(finalObjectPath, this, QDBusConnection::ExportScriptableSlots);
|
status = s_connection.registerObject(finalObjectPath, parent, QDBusConnection::ExportScriptableSlots);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
qCWarning(dcApplication()) << "Failed to register D-Bus object:" << finalObjectPath;
|
qCWarning(dcApplication()) << "Failed to register D-Bus object:" << finalObjectPath;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusContext>
|
#include <QDBusContext>
|
||||||
|
|
||||||
class NymeaDBusService : public QObject, public QDBusContext
|
class NymeaDBusService : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "io.guh.nymead")
|
Q_CLASSINFO("D-Bus Interface", "io.guh.nymead")
|
||||||
|
|||||||
@ -41,7 +41,6 @@
|
|||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QBluetoothDeviceInfo>
|
|
||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
class DeviceManager;
|
class DeviceManager;
|
||||||
|
|||||||
@ -35,6 +35,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
|
parser.process(a);
|
||||||
|
|
||||||
PushButtonAgent agent;
|
PushButtonAgent agent;
|
||||||
if (!agent.init(parser.isSet(dbusOption) ? QDBusConnection::SessionBus : QDBusConnection::SystemBus)) {
|
if (!agent.init(parser.isSet(dbusOption) ? QDBusConnection::SessionBus : QDBusConnection::SystemBus)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user