added macros borrowed from Philippe

important: macros to be used with dbus-1-tqt/pulls/42

Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
feat/new_hwcontrol
Emanoil Kotsev 3 months ago
parent 351c99b1fb
commit 3da61733fc
No known key found for this signature in database
GPG Key ID: F1EEB8CD9FB16A50

@ -30,6 +30,7 @@
class BrightnessService: public org::trinitydesktop::hardwarecontrol::BrightnessInterface, class BrightnessService: public org::trinitydesktop::hardwarecontrol::BrightnessInterface,
public DeviceServiceBase public DeviceServiceBase
{ {
public: public:
BrightnessService(TQT_DBusConnection&); BrightnessService(TQT_DBusConnection&);
virtual ~BrightnessService(); virtual ~BrightnessService();

@ -28,6 +28,7 @@
class CPUGovernorService: public org::trinitydesktop::hardwarecontrol::CPUGovernorInterface, class CPUGovernorService: public org::trinitydesktop::hardwarecontrol::CPUGovernorInterface,
public DeviceServiceBase public DeviceServiceBase
{ {
public: public:
CPUGovernorService(TQT_DBusConnection&); CPUGovernorService(TQT_DBusConnection&);
virtual ~CPUGovernorService(); virtual ~CPUGovernorService();

@ -24,6 +24,7 @@
#include <tqfile.h> #include <tqfile.h>
#include <tqtextstream.h> #include <tqtextstream.h>
#include "common.h"
#include <tqdbuserror.h> #include <tqdbuserror.h>
#include "DeviceServiceBase.h" #include "DeviceServiceBase.h"
@ -37,8 +38,7 @@ DeviceServiceBase::DeviceServiceBase(TQT_DBusConnection &conn)
DeviceServiceBase::~DeviceServiceBase() DeviceServiceBase::~DeviceServiceBase()
{ {
if (m_connection) DEL(m_connection)
delete m_connection;
} }
bool DeviceServiceBase::canSetDeviceValue(const TQString& device, TQT_DBusError& error) { bool DeviceServiceBase::canSetDeviceValue(const TQString& device, TQT_DBusError& error) {

@ -23,6 +23,7 @@
#include <tqtimer.h> #include <tqtimer.h>
#include <tqdbusmessage.h> #include <tqdbusmessage.h>
#include "common.h"
#include "HardwareControl.h" #include "HardwareControl.h"
#define DBUS_HWCTRL_SERVICE_NAME "org.trinitydesktop.hardwarecontrol" #define DBUS_HWCTRL_SERVICE_NAME "org.trinitydesktop.hardwarecontrol"
@ -83,26 +84,10 @@ void HardwareControl::slotDbusSignal(const TQT_DBusMessage& message) {
void HardwareControl::dbusConnectionClose() { void HardwareControl::dbusConnectionClose() {
if(rootService) DEL(rootService)
{ DEL(orgService)
delete rootService; DEL(trinitydesktopService)
rootService=0; DEL(hardwarecontrolService)
}
if(orgService)
{
delete orgService;
orgService=0;
}
if(trinitydesktopService)
{
delete trinitydesktopService;
trinitydesktopService=0;
}
if(hardwarecontrolService)
{
delete hardwarecontrolService;
hardwarecontrolService=0;
}
if(m_connection.isConnected()) { if(m_connection.isConnected()) {
m_connection.disconnect(this, TQ_SLOT(slotDbusSignal(const TQT_DBusMessage&))); m_connection.disconnect(this, TQ_SLOT(slotDbusSignal(const TQT_DBusMessage&)));

@ -29,6 +29,7 @@
#include <tqvaluelist.h> #include <tqvaluelist.h>
#include "common.h"
#include "InputEventsService.h" #include "InputEventsService.h"
#define BITS_PER_LONG (sizeof(long) * 8) #define BITS_PER_LONG (sizeof(long) * 8)
@ -43,8 +44,7 @@ InputEventsService::InputEventsService(TQT_DBusConnection &conn)
InputEventsService::~InputEventsService() InputEventsService::~InputEventsService()
{ {
if (m_connection) DEL(m_connection)
delete m_connection;
} }
/*! /*!

@ -28,6 +28,7 @@
class InputEventsService: public org::trinitydesktop::hardwarecontrol::InputEventsInterface class InputEventsService: public org::trinitydesktop::hardwarecontrol::InputEventsInterface
{ {
public: public:
InputEventsService(TQT_DBusConnection&); InputEventsService(TQT_DBusConnection&);
virtual ~InputEventsService(); virtual ~InputEventsService();

@ -28,6 +28,7 @@
class PowerService: public org::trinitydesktop::hardwarecontrol::PowerInterface, class PowerService: public org::trinitydesktop::hardwarecontrol::PowerInterface,
public DeviceServiceBase public DeviceServiceBase
{ {
public: public:
PowerService(TQT_DBusConnection&); PowerService(TQT_DBusConnection&);
virtual ~PowerService(); virtual ~PowerService();

@ -31,6 +31,7 @@
class PropertiesService: public org::freedesktop::DBus::PropertiesInterface class PropertiesService: public org::freedesktop::DBus::PropertiesInterface
{ {
public: public:
PropertiesService(TQT_DBusConnection&); PropertiesService(TQT_DBusConnection&);
virtual ~PropertiesService(); virtual ~PropertiesService();

@ -0,0 +1,25 @@
/*
* common.h
*
* Created on: Apr 12, 2025
* Author: emanoil
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TDE_HWLIBDAEMONS_COMMON_H_
#define TDE_HWLIBDAEMONS_COMMON_H_
#define DEL(x) if (x) { delete x; x = nullptr; }
#endif /* TDE_HWLIBDAEMONS_COMMON_H_ */

@ -42,14 +42,27 @@
*/ */
#define DBUS_HWCTRL_SERVICE_PATH "/org/trinitydesktop/hardwarecontrol" #define DBUS_HWCTRL_SERVICE_PATH "/org/trinitydesktop/hardwarecontrol"
#define REGISTER_PORTAL(klass) \
m_interfaces.insert(klass::interface(), new klass(m_connection));
#define DESTROY_PORTAL(klass) \
delete m_interfaces[klass::interface()];
#define ADDCHILD(x) addChildNode(TQString(x));
#define REGISTER_OBJECT(x) registerObject(m_connection,TQString(x));
#define ADDNODE(x,y) \
ADDCHILD(x) \
REGISTER_OBJECT(y)
/* /*
* Root Node * Root Node
*/ */
RootNodeService::RootNodeService(TQT_DBusConnection &connection ) RootNodeService::RootNodeService(TQT_DBusConnection &connection )
: DBusBaseNode(), m_connection(connection) : DBusBaseNode(), m_connection(connection)
{ {
addChildNode(TQString("org")); ADDNODE("org","/")
registerObject(m_connection,TQString("/"));
} }
RootNodeService::~RootNodeService(){ RootNodeService::~RootNodeService(){
@ -66,8 +79,7 @@ TQT_DBusObjectBase* RootNodeService::createInterface(const TQString& interfaceNa
OrgNodeService::OrgNodeService(TQT_DBusConnection &connection ) OrgNodeService::OrgNodeService(TQT_DBusConnection &connection )
: DBusBaseNode(), m_connection(connection) : DBusBaseNode(), m_connection(connection)
{ {
addChildNode(TQString("trinitydesktop")); ADDNODE("trinitydesktop","/org")
registerObject(m_connection,TQString("/org"));
} }
OrgNodeService::~OrgNodeService(){ OrgNodeService::~OrgNodeService(){
@ -84,11 +96,15 @@ TQT_DBusObjectBase* OrgNodeService::createInterface(const TQString& interfaceNam
TrinityDesktopNodeService::TrinityDesktopNodeService(TQT_DBusConnection &connection ) TrinityDesktopNodeService::TrinityDesktopNodeService(TQT_DBusConnection &connection )
: DBusBaseNode(), m_connection(connection) : DBusBaseNode(), m_connection(connection)
{ {
addChildNode(TQString("hardwarecontrol")); ADDNODE("hardwarecontrol","/org/trinitydesktop")
registerObject(m_connection,TQString("/org/trinitydesktop"));
} }
TrinityDesktopNodeService::~TrinityDesktopNodeService(){ TrinityDesktopNodeService::~TrinityDesktopNodeService(){
DESTROY_PORTAL(PropertiesService);
DESTROY_PORTAL(BrightnessService);
DESTROY_PORTAL(CPUGovernorService);
DESTROY_PORTAL(InputEventsService);
DESTROY_PORTAL(PowerService);
} }
TQT_DBusObjectBase* TrinityDesktopNodeService::createInterface(const TQString& interfaceName) TQT_DBusObjectBase* TrinityDesktopNodeService::createInterface(const TQString& interfaceName)
@ -104,12 +120,12 @@ HardwareControlNodeService::HardwareControlNodeService(TQT_DBusConnection &conn)
m_connection(conn) m_connection(conn)
{ {
m_interfaces.insert("org.freedesktop.DBus.Introspectable", this); m_interfaces.insert("org.freedesktop.DBus.Introspectable", this);
m_interfaces.insert("org.freedesktop.DBus.Properties", new PropertiesService(m_connection)); REGISTER_PORTAL(PropertiesService);
m_interfaces.insert("org.trinitydesktop.hardwarecontrol.Brightness", new BrightnessService(m_connection)); REGISTER_PORTAL(BrightnessService);
m_interfaces.insert("org.trinitydesktop.hardwarecontrol.CPUGovernor", new CPUGovernorService(m_connection)); REGISTER_PORTAL(CPUGovernorService);
m_interfaces.insert("org.trinitydesktop.hardwarecontrol.InputEvents", new InputEventsService(m_connection)); REGISTER_PORTAL(InputEventsService);
m_interfaces.insert("org.trinitydesktop.hardwarecontrol.Power", new PowerService(m_connection)); REGISTER_PORTAL(PowerService);
registerObject(m_connection,TQString(DBUS_HWCTRL_SERVICE_PATH)); REGISTER_OBJECT(DBUS_HWCTRL_SERVICE_PATH)
} }
HardwareControlNodeService::~HardwareControlNodeService(){ HardwareControlNodeService::~HardwareControlNodeService(){

Loading…
Cancel
Save