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