Commit cb150953 authored by Volker Krause's avatar Volker Krause

Build without D-Bus on Android

Reviewers: dhaumann

Reviewed By: dhaumann

Subscribers: dhaumann, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D18389
parent 928f7f21
......@@ -18,7 +18,10 @@ include(KDECMakeSettings)
include(ECMQtDeclareLoggingCategory)
set(REQUIRED_QT_VERSION 5.10.0)
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml DBus Widgets)
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Xml Widgets)
if (NOT ANDROID)
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus)
endif()
if(WIN32)
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Network)
......
......@@ -17,11 +17,13 @@ add_library(KF5::Solid ALIAS KF5Solid)
target_include_directories(KF5Solid INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/Solid>")
target_link_libraries(KF5Solid PUBLIC Qt5::Core
PRIVATE Qt5::DBus
Qt5::Xml
PRIVATE Qt5::Xml
Qt5::Widgets
${solid_OPTIONAL_LIBS}
)
if (TARGET Qt5::DBus)
target_link_libraries(KF5Solid PRIVATE Qt5::DBus)
endif()
set_target_properties(KF5Solid PROPERTIES VERSION ${SOLID_VERSION_STRING}
SOVERSION ${SOLID_SOVERSION}
......@@ -90,7 +92,10 @@ add_library(KF5Solid_static STATIC ${solid_LIB_SRCS})
set_target_properties(KF5Solid_static PROPERTIES COMPILE_FLAGS -DSOLID_STATIC_DEFINE=1)
target_link_libraries(KF5Solid_static PUBLIC Qt5::Core)
target_link_libraries(KF5Solid_static PRIVATE Qt5::DBus Qt5::Xml Qt5::Widgets ${solid_OPTIONAL_LIBS})
target_link_libraries(KF5Solid_static PRIVATE Qt5::Xml Qt5::Widgets ${solid_OPTIONAL_LIBS})
if (TARGET Qt5::DBus)
target_link_libraries(KF5Solid_static PRIVATE Qt5::DBus)
endif()
target_include_directories(KF5Solid_static PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/..;${CMAKE_CURRENT_BINARY_DIR}/..>")
########### install files ###############
......
......@@ -35,7 +35,9 @@
#include "fakebattery.h"
#include <QStringList>
#ifdef QT_DBUS_LIB
#include <QDBusConnection>
#endif
#include <solid/genericinterface.h>
......@@ -51,7 +53,9 @@ FakeDevice::FakeDevice(const QString &udi, const QMap<QString, QVariant> &proper
d->locked = false;
d->broken = false;
#ifdef QT_DBUS_LIB
QDBusConnection::sessionBus().registerObject(udi, this, QDBusConnection::ExportNonScriptableSlots);
#endif
// Force instantiation of all the device interfaces
// this way they'll get exported on the bus
......@@ -79,7 +83,9 @@ FakeDevice::FakeDevice(const FakeDevice &dev)
FakeDevice::~FakeDevice()
{
#ifdef QT_DBUS_LIB
QDBusConnection::sessionBus().unregisterObject(d->udi, QDBusConnection::UnregisterTree);
#endif
}
QString FakeDevice::udi() const
......@@ -302,10 +308,12 @@ QObject *FakeDevice::createDeviceInterface(const Solid::DeviceInterface::Type &t
break;
}
#ifdef QT_DBUS_LIB
if (iface) {
QDBusConnection::sessionBus().registerObject(d->udi + '/' + Solid::DeviceInterface::typeToString(type), iface,
QDBusConnection::ExportNonScriptableSlots);
}
#endif
return iface;
}
......
......@@ -29,7 +29,9 @@
#include <QFile>
#include <QString>
#include <QTimer>
#ifdef QT_DBUS_LIB
#include <QDBusConnection>
#endif
using namespace Solid::Backends::Fake;
......@@ -48,7 +50,9 @@ FakeManager::FakeManager(QObject *parent, const QString &xmlFile)
QString machineXmlFile = xmlFile;
d->xmlFile = machineXmlFile;
#ifdef QT_DBUS_LIB
QDBusConnection::sessionBus().registerObject("/org/kde/solid/fakehw", this, QDBusConnection::ExportNonScriptableSlots);
#endif
parseMachineFile();
......@@ -68,7 +72,9 @@ FakeManager::FakeManager(QObject *parent, const QString &xmlFile)
FakeManager::~FakeManager()
{
#ifdef QT_DBUS_LIB
QDBusConnection::sessionBus().unregisterObject("/org/kde/solid/fakehw", QDBusConnection::UnregisterTree);
#endif
qDeleteAll(d->loadedDevices);
delete d;
}
......
......@@ -20,8 +20,6 @@
#include "fakevolume.h"
#include <QDBusConnection>
using namespace Solid::Backends::Fake;
FakeVolume::FakeVolume(FakeDevice *device)
......
......@@ -20,8 +20,10 @@
#include "ifaces/device.h"
#ifdef QT_DBUS_LIB
#include <QDBusConnection>
#include <QDBusMessage>
#endif
Solid::Ifaces::Device::Device(QObject *parent)
: QObject(parent)
......@@ -44,6 +46,7 @@ void Solid::Ifaces::Device::registerAction(const QString &actionName,
const char *requestSlot,
const char *doneSlot) const
{
#ifdef QT_DBUS_LIB
QDBusConnection::sessionBus().connect(QString(), deviceDBusPath(),
"org.kde.Solid.Device", actionName + "Requested",
dest, requestSlot);
......@@ -51,21 +54,26 @@ void Solid::Ifaces::Device::registerAction(const QString &actionName,
QDBusConnection::sessionBus().connect(QString(), deviceDBusPath(),
"org.kde.Solid.Device", actionName + "Done",
dest, doneSlot);
#endif
}
void Solid::Ifaces::Device::broadcastActionDone(const QString &actionName,
int error, const QString &errorString) const
{
#ifdef QT_DBUS_LIB
QDBusMessage signal = QDBusMessage::createSignal(deviceDBusPath(), "org.kde.Solid.Device", actionName + "Done");
signal << error << errorString;
QDBusConnection::sessionBus().send(signal);
#endif
}
void Solid::Ifaces::Device::broadcastActionRequested(const QString &actionName) const
{
#ifdef QT_DBUS_LIB
QDBusMessage signal = QDBusMessage::createSignal(deviceDBusPath(), "org.kde.Solid.Device", actionName + "Requested");
QDBusConnection::sessionBus().send(signal);
#endif
}
QString Solid::Ifaces::Device::deviceDBusPath() const
......
......@@ -29,7 +29,7 @@
#if defined (Q_OS_MAC)
#include "backends/iokit/iokitmanager.h"
#elif defined (Q_OS_UNIX)
#elif defined (Q_OS_UNIX) && !defined(Q_OS_ANDROID)
#include "backends/hal/halmanager.h"
#include "backends/udisks2/udisksmanager.h"
#include "backends/upower/upowermanager.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment