Commit 85bd163d authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Export a generated DBus interface class for the systemstats interface

We use the generated interface in several places where we currently
duplicate the interface generation and also have two copies of the
interface file, let's unify them all by including it in the systemstats
lib.
parent 419f5a55
......@@ -7,6 +7,7 @@ set(systemstats_SRCS
SensorPlugin.cpp
SensorProperty.cpp
SysFsSensor.cpp
DBusInterface.cpp
)
set(systemstats_HDRS
......@@ -18,12 +19,29 @@ set(systemstats_HDRS
SysFsSensor.h
SysctlSensor.h
SensorInfo.h
DBusInterface.h
)
set_source_files_properties(org.kde.ksystemstats.xml PROPERTIES INCLUDE SensorInfo.h)
qt5_add_dbus_interface(dbusinterface_SRCS org.kde.ksystemstats.xml org.kde.ksystemstats)
# Symbol visibility trickery: We cannot generate the DBus interface class with
# the right export macro, so instead create it as a static library with the right
# visibility preset set, then link to that in the shared library.
add_library(dbusinterface STATIC ${dbusinterface_SRCS})
set_target_properties(dbusinterface PROPERTIES CXX_VISIBILITY_PRESET default)
target_link_libraries(dbusinterface Qt::Core Qt::DBus KSysGuard::Formatter)
add_library(SystemStats ${systemstats_SRCS})
add_library(KSysGuard::SystemStats ALIAS SystemStats)
target_link_libraries(SystemStats PUBLIC Qt::Core Qt::DBus KSysGuard::Formatter)
target_include_directories(SystemStats
PUBLIC
"$<BUILD_INTERFACE:${libksysguard_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR}/ksysguard/>"
)
target_link_libraries(SystemStats PUBLIC Qt::Core Qt::DBus KSysGuard::Formatter PRIVATE dbusinterface)
generate_export_header(SystemStats)
......@@ -38,5 +56,6 @@ install(TARGETS SystemStats EXPORT libksysguardLibraryTargets ${KDE_INSTALL_TARG
install(FILES
${systemstats_HDRS}
${CMAKE_CURRENT_BINARY_DIR}/systemstats_export.h
${CMAKE_CURRENT_BINARY_DIR}/org.kde.ksystemstats.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/ksysguard/systemstats
)
/*
Copyright (C) 2021 Arjen Hiemstra <ahiemstra@heimr.nl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "DBusInterface.h"
namespace KSysGuard
{
namespace SystemStats
{
DBusInterface::DBusInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
: org::kde::ksystemstats(service, path, connection, parent)
{
}
}
}
/*
Copyright (C) 2021 Arjen Hiemstra <ahiemstra@heimr.nl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#pragma once
#include "org.kde.ksystemstats.h"
#include "systemstats_export.h"
namespace KSysGuard
{
namespace SystemStats
{
const QString ServiceName = QStringLiteral("org.kde.ksystemstats");
const QString ObjectPath = QStringLiteral("/");
/**
* This exposes the generated DBus interface for org.kde.ksystemstats
*/
class SYSTEMSTATS_EXPORT DBusInterface : public org::kde::ksystemstats
{
Q_OBJECT
public:
DBusInterface(const QString &service = ServiceName, const QString &path = ObjectPath, const QDBusConnection &connection = QDBusConnection::sessionBus(), QObject *parent = nullptr);
};
} // namespace SystemStats
} // namespace KSysGuard
......@@ -27,13 +27,15 @@
#include "formatter/Unit.h"
#include "systemstats_export.h"
namespace KSysGuard
{
constexpr uint BackendUpdateInterval = 500;
// Data that is static for the lifespan of the sensor
class Q_DECL_EXPORT SensorInfo
class SYSTEMSTATS_EXPORT SensorInfo
{
public:
SensorInfo() = default;
......@@ -47,7 +49,7 @@ public:
qreal max = 0;
};
class Q_DECL_EXPORT SensorData
class SYSTEMSTATS_EXPORT SensorData
{
public:
SensorData() = default;
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.ksystemstats">
<signal name="sensorAdded">
<arg name="sensorId" type="s" direction="out"/>
</signal>
<signal name="sensorRemoved">
<arg name="sensorId" type="s" direction="out"/>
</signal>
<signal name="newSensorData">
<arg name="sensorData" type="a(sv)" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="KSysGuard::SensorDataList"/>
</signal>
<signal name="sensorMetaDataChanged">
<arg name="metaData" type="a{s(sssuuddi)}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QHash&lt;QString,KSysGuard::SensorInfo&gt;"/>
</signal>
<method name="allSensors">
<arg name="sensorInfo" type="a{s(sssuuddi)}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QHash&lt;QString,KSysGuard::SensorInfo&gt;"/>
</method>
<method name="sensors">
<arg name="sensorsIds" type="as" direction="in"/>
<arg name ="sensorInfo" type="a{s(sssuuddi)}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QHash&lt;QString,KSysGuard::SensorInfo&gt;"/>
</method>
<method name="subscribe">
<arg name="sensorIds" type="as" direction="in"/>
</method>
<method name="unsubscribe">
<arg name="sensorIds" type="as" direction="in"/>
</method>
<method name="sensorData">
<arg name="sensorIds" type="as" direction="in"/>
<arg name="sensorData" type="a(sv)" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="KSysGuard::SensorDataList"/>
</method>
</interface>
</node>
Supports Markdown
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