Example for using properties in Proxy and Interface fashion

Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
master
Emanoil Kotsev 10 months ago
parent 3de1a6bbc8
commit b1f7f4eabb
Signed by: deloptes
GPG Key ID: F1EEB8CD9FB16A50

@ -0,0 +1,163 @@
// File autogenerated
// declaration include
#include "dbusbaseNode.h"
// TQt includes
#include <tqdom.h>
#include <tqmap.h>
#include <tqstringlist.h>
// TQt D-Bus includes
#include <tqdbusconnection.h>
#include <tqdbusmessage.h>
// interface classes includes
#include "dbusbaseNode.h"
#include "introspectableInterface.h"
class DBusBaseNode::Private : public org::freedesktop::DBus::IntrospectableInterface
{
public:
virtual ~Private();
public:
TQMap<TQString, TQT_DBusObjectBase*> interfaces;
TQString introspectionData;
TQT_DBusConnection connection;
TQString objectPath;
TQStringList childrenNodes;
protected:
virtual bool Introspect(TQString& data, TQT_DBusError& error);
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
void cacheIntrospectionData();
};
DBusBaseNode::DBusBaseNode() : TQT_DBusObjectBase(),
m_private(new Private())
{
}
DBusBaseNode::~DBusBaseNode()
{
unregisterObject();
delete m_private;
}
bool DBusBaseNode::registerObject(const TQT_DBusConnection& connection, const TQString& path)
{
if (path.isEmpty()) return false;
if (!m_private->objectPath.isEmpty()) unregisterObject();
m_private->connection = connection;
m_private->objectPath = path;
if (!m_private->connection.registerObject(path, this))
{
m_private->connection = TQT_DBusConnection();
m_private->objectPath = TQString();
return false;
}
if (m_private->interfaces.isEmpty())
{
TQString name = "org.freedesktop.DBus.Introspectable";
TQT_DBusObjectBase* interface = m_private;
m_private->interfaces.insert(name, interface);
}
return true;
}
void DBusBaseNode::addChildNode(const TQString& child)
{
m_private->childrenNodes.append(child);
}
void DBusBaseNode::unregisterObject()
{
if (m_private->objectPath.isEmpty()) return;
m_private->connection.unregisterObject(m_private->objectPath);
m_private->connection = TQT_DBusConnection();
m_private->objectPath = TQString();
}
bool DBusBaseNode::handleMethodCall(const TQT_DBusMessage& message)
{
TQMap<TQString, TQT_DBusObjectBase*>::iterator findIt = m_private->interfaces.find(message.interface());
if (findIt == m_private->interfaces.end()) return false;
return delegateMethodCall(message, findIt.data());
}
DBusBaseNode::Private::~Private()
{
TQMap<TQString, TQT_DBusObjectBase*>::const_iterator it = interfaces.begin();
TQMap<TQString, TQT_DBusObjectBase*>::const_iterator endIt = interfaces.end();
for (; it != endIt; ++it)
{
TQT_DBusObjectBase* interface = it.data();
if (interface != this)
delete interface;
}
interfaces.clear();
}
bool DBusBaseNode::Private::Introspect(TQString& data, TQT_DBusError& error)
{
Q_UNUSED(error);
if (introspectionData.isEmpty()) cacheIntrospectionData();
data = introspectionData;
return true;
}
void DBusBaseNode::Private::handleMethodReply(const TQT_DBusMessage& reply)
{
connection.send(reply);
}
void DBusBaseNode::Private::cacheIntrospectionData()
{
TQDomDocument doc;
TQDomElement interfaceElement;
TQDomElement nodeElement = doc.createElement("node");
if (!objectPath.isEmpty() && objectPath.compare("/") != 0)
{
nodeElement.setAttribute ( "name", objectPath );
}
// Introspectable is added by default. Show it only if there is interface
if (interfaces.count()>1) {
interfaceElement = doc.createElement("interface");
org::freedesktop::DBus::IntrospectableInterface::buildIntrospectionData(interfaceElement);
nodeElement.appendChild(interfaceElement);
}
if (!childrenNodes.isEmpty()) {
for (TQStringList::Iterator it = childrenNodes.begin(); it != childrenNodes.end(); ++it ) {
TQDomElement nodeElement1 = doc.createElement("node");
nodeElement1.setAttribute ( "name", *it );
nodeElement.appendChild(nodeElement1);
}
}
doc.appendChild(nodeElement);
introspectionData = "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n";
introspectionData += doc.toString();
}
// End of File

@ -0,0 +1,45 @@
// File autogenerated
#if !defined(DBUSBASENODE_H_INCLUDED)
#define DBUSBASENODE_H_INCLUDED
// TQt D-Bus includes
#include <tqdbuserror.h>
#include <tqdbusobject.h>
// forward declarations
class TQString;
class TQT_DBusConnection;
class DBusBaseNode : public TQT_DBusObjectBase
{
public:
DBusBaseNode();
virtual ~DBusBaseNode();
bool registerObject(const TQT_DBusConnection& connection, const TQString& path);
void addChildNode(const TQString& child);
void unregisterObject();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString& interfaceName) = 0;
protected: // usually no need to reimplement
virtual bool handleMethodCall(const TQT_DBusMessage& message);
private:
class Private;
Private* m_private;
private: // Hiding copy constructor and assignment operator
DBusBaseNode(const DBusBaseNode&);
DBusBaseNode& operator=(const DBusBaseNode&);
}; // class DBusBaseNode
#endif //DBUSBASENODE_H_INCLUDED
// End of File

@ -0,0 +1,94 @@
/*
*
* Object Manager implementation of bluez5
*
* Copyright (C) 2018 Emanoil Kotsev <deloptes@gmail.com>
*
*
* This file is part of libtdebluez.
*
* libtdebluez is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* libtdebluez 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 kbluetooth; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <tdeapplication.h>
#include <tdeaboutdata.h>
#include <tdecmdlineargs.h>
#include <tdelocale.h>
//
//#include <tqstringlist.h>
//
#include <tqdbusobjectpath.h>
#include "exampleclient.h"
#include "serviceProxy.h"
/**
*
dbus-send --session --print-reply \
--dest=org.example.Service \
/org/example/service \
org.example.Service.GetValue
*
*/
#define DBUS_CONNECTION "org.example.Service"
ExampleClient::ExampleClient() : TQObject()
{
dBusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SessionBus, DBUS_CONNECTION);
if (!dBusConn.isConnected())
{
tqDebug(TQString("Failed to open connection to system message bus: %1").arg(dBusConn.lastError().message()));
exit(-1);
}
org::example::ServiceProxy *service = new org::example::ServiceProxy("org.example.Service", "/org/example/service");
service->setConnection(dBusConn);
TQT_DBusError dbuserror;
TQ_UINT64 outvalue;
if (!service->GetValue(outvalue, dbuserror))
{
if (dbuserror.isValid())
{
tqDebug(TQString("GetValue(error) failed: %1").arg(dbuserror.message()));
}
}
TQ_UINT64 result = service->getSize(dbuserror);
if (dbuserror.isValid())
{
tqDebug(TQString("GetValue(error) failed: %1").arg(dbuserror.message()));
}
tqDebug(TQString("GetValue returned: %1").arg(TQString::number(outvalue)));
delete service;
}
ExampleClient::~ExampleClient()
{
// close D-Bus connection
dBusConn.closeConnection(DBUS_CONNECTION);
}
int main(int argc, char **argv)
{
ExampleClient commandHandler;
}
#include "exampleclient.moc"
// End of File

@ -0,0 +1,37 @@
/*
*
* Object Manager implementation of bluez5
*
* Copyright (C) 2018 Emanoil Kotsev <deloptes@gmail.com>
*
*
* This file is part of libtdebluez.
*
* libtdebluez is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* libtdebluez 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 kbluetooth; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <tqobject.h>
#include <tqdbusconnection.h>
class ExampleClient : public TQObject
{
// TQ_OBJECT
public:
ExampleClient();
virtual ~ExampleClient();
private:
TQT_DBusConnection dBusConn;
};

@ -0,0 +1,88 @@
// File autogenerated
// declaration include
#include "introspectableInterface.h"
// TQt includes
#include <tqdom.h>
#include <tqstring.h>
// TQt D-Bus includes
#include <tqdbuserror.h>
#include <tqdbusmessage.h>
namespace org
{
namespace freedesktop
{
namespace DBus
{
void IntrospectableInterface::buildIntrospectionData(TQDomElement& interfaceElement)
{
interfaceElement.setAttribute("name", "org.freedesktop.DBus.Introspectable");
TQDomDocument document = interfaceElement.ownerDocument();
TQDomElement methodElement = document.createElement("method");
methodElement.setAttribute("name", "Introspect");
TQDomElement argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "data");
argumentElement.setAttribute("type", "s");
argumentElement.setAttribute("direction", "out");
methodElement.appendChild(argumentElement);
interfaceElement.appendChild(methodElement);
}
TQT_DBusMessage IntrospectableInterface::callIntrospect(const TQT_DBusMessage& message)
{
TQT_DBusError error;
TQT_DBusMessage reply;
TQString _data;
if (Introspect(_data, error))
{
reply = TQT_DBusMessage::methodReply(message);
reply << TQT_DBusData::fromString(_data);
}
else
{
if (!error.isValid())
{
tqWarning("Call to implementation of org::freedesktop::DBus::IntrospectableInterface::Introspect returned 'false' but error object is not valid!");
error = TQT_DBusError::stdFailed("org.freedesktop.DBus.Introspectable.Introspect execution failed");
}
reply = TQT_DBusMessage::methodError(message, error);
}
return reply;
}
bool IntrospectableInterface::handleMethodCall(const TQT_DBusMessage& message)
{
if (message.interface() != "org.freedesktop.DBus.Introspectable") return false;
if (message.member() == "Introspect")
{
TQT_DBusMessage reply = callIntrospect(message);
handleMethodReply(reply);
return true;
}
return false;
}
}; // namespace DBus
}; // namespace freedesktop
}; // namespace org
// End of File

@ -0,0 +1,51 @@
// File autogenerated
#if !defined(INTROSPECTABLEINTERFACE_H_INCLUDED)
#define INTROSPECTABLEINTERFACE_H_INCLUDED
// TQt D-Bus includes
#include <tqdbuserror.h>
#include <tqdbusobject.h>
// forward declarations
class TQDomElement;
class TQString;
class TQT_DBusError;
namespace org
{
namespace freedesktop
{
namespace DBus
{
class IntrospectableInterface : public TQT_DBusObjectBase
{
public:
virtual ~IntrospectableInterface() {}
static void buildIntrospectionData(TQDomElement& interfaceElement);
protected:
virtual bool Introspect(TQString& data, TQT_DBusError& error) = 0;
protected: // implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply) = 0;
protected: // usually no need to reimplement
virtual bool handleMethodCall(const TQT_DBusMessage& message);
TQT_DBusMessage callIntrospect(const TQT_DBusMessage& message);
}; // class IntrospectableInterface
}; // namespace DBus
}; // namespace freedesktop
}; // namespace org
#endif //INTROSPECTABLEINTERFACE_H_INCLUDED
// End of File

@ -0,0 +1,30 @@
#include "testservice.h"
#include <tqapplication.h>
#include <tqdbusconnection.h>
int main(int argc, char** argv)
{
TQApplication app(argc, argv, false);
TQT_DBusConnection connection = TQT_DBusConnection::sessionBus();
// TQT_DBusConnection connection = TQT_DBusConnection::systemBus();
if (!connection.isConnected())
tqFatal("Cannot connect to session bus");
// try to get a specific service name
if (!connection.requestName("org.example.Service"))
{
tqWarning("Requesting name 'org.example.Service' failed. "
"Will only be addressable through unique name '%s'",
connection.uniqueName().local8Bit().data());
}
else
{
tqDebug("Requesting name 'org.example.Service' successfull");
}
RootService rootService(connection);
OrgService orgService(connection);
ExampleService exampleService(connection);
MultiInterfaceService service(connection);
return app.exec();
}

@ -0,0 +1,258 @@
// File autogenerated
// declaration include
#include "propertiesInterface.h"
// TQt includes
#include <tqdom.h>
#include <tqmap.h>
#include <tqstring.h>
#include <tqstringlist.h>
// TQt D-Bus includes
#include <tqdbusdata.h>
#include <tqdbusdatalist.h>
#include <tqdbusdatamap.h>
#include <tqdbuserror.h>
#include <tqdbusmessage.h>
#include <tqdbusvariant.h>
namespace org
{
namespace freedesktop
{
namespace DBus
{
void PropertiesInterface::buildIntrospectionData(TQDomElement& interfaceElement)
{
interfaceElement.setAttribute("name", "org.freedesktop.DBus.Properties");
TQDomDocument document = interfaceElement.ownerDocument();
TQDomElement methodElement = document.createElement("method");
methodElement.setAttribute("name", "Get");
TQDomElement argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "interface");
argumentElement.setAttribute("type", "s");
argumentElement.setAttribute("direction", "in");
methodElement.appendChild(argumentElement);
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "name");
argumentElement.setAttribute("type", "s");
argumentElement.setAttribute("direction", "in");
methodElement.appendChild(argumentElement);
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "value");
argumentElement.setAttribute("type", "v");
argumentElement.setAttribute("direction", "out");
methodElement.appendChild(argumentElement);
interfaceElement.appendChild(methodElement);
methodElement = document.createElement("method");
methodElement.setAttribute("name", "Set");
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "interface");
argumentElement.setAttribute("type", "s");
argumentElement.setAttribute("direction", "in");
methodElement.appendChild(argumentElement);
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "name");
argumentElement.setAttribute("type", "s");
argumentElement.setAttribute("direction", "in");
methodElement.appendChild(argumentElement);
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "value");
argumentElement.setAttribute("type", "v");
argumentElement.setAttribute("direction", "in");
methodElement.appendChild(argumentElement);
interfaceElement.appendChild(methodElement);
methodElement = document.createElement("method");
methodElement.setAttribute("name", "GetAll");
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "interface");
argumentElement.setAttribute("type", "s");
argumentElement.setAttribute("direction", "in");
methodElement.appendChild(argumentElement);
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "properties");
argumentElement.setAttribute("type", "a{sv}");
argumentElement.setAttribute("direction", "out");
methodElement.appendChild(argumentElement);
interfaceElement.appendChild(methodElement);
methodElement = document.createElement("signal");
methodElement.setAttribute("name", "PropertiesChanged");
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "interface");
argumentElement.setAttribute("type", "s");
argumentElement.setAttribute("direction", "out");
methodElement.appendChild(argumentElement);
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "changed_properties");
argumentElement.setAttribute("type", "a{sv}");
argumentElement.setAttribute("direction", "out");
methodElement.appendChild(argumentElement);
argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "invalidated_properties");
argumentElement.setAttribute("type", "as");
argumentElement.setAttribute("direction", "out");
methodElement.appendChild(argumentElement);
interfaceElement.appendChild(methodElement);
}
bool PropertiesInterface::emitPropertiesChanged(const TQString& interface, const TQMap< TQString, TQT_DBusVariant >& changed_properties, const TQStringList& invalidated_properties)
{
TQString path = objectPath();
Q_ASSERT(!path.isEmpty());
TQT_DBusMessage message = TQT_DBusMessage::signal(path, "org.freedesktop.DBus.Properties", "PropertiesChanged");
message << TQT_DBusData::fromString(interface);
message << TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap< TQString >(changed_properties));
message << TQT_DBusData::fromList((invalidated_properties));
return handleSignalSend(message);
}
TQT_DBusMessage PropertiesInterface::callGet(const TQT_DBusMessage& message)
{
TQT_DBusError error;
TQT_DBusMessage reply;
TQString _interface = message[0].toString();
TQString _name = message[1].toString();
TQT_DBusVariant _value;
if (Get(_interface, _name, _value, error))
{
reply = TQT_DBusMessage::methodReply(message);
reply << TQT_DBusData::fromVariant(_value);
}
else
{
if (!error.isValid())
{
tqWarning("Call to implementation of org::freedesktop::DBus::PropertiesInterface::Get returned 'false' but error object is not valid!");
error = TQT_DBusError::stdFailed("org.freedesktop.DBus.Properties.Get execution failed");
}
reply = TQT_DBusMessage::methodError(message, error);
}
return reply;
}
TQT_DBusMessage PropertiesInterface::callSet(const TQT_DBusMessage& message)
{
TQT_DBusError error;
TQT_DBusMessage reply;
TQString _interface = message[0].toString();
TQString _name = message[1].toString();
TQT_DBusVariant _value = message[2].toVariant();
if (Set(_interface, _name, _value, error))
{
reply = TQT_DBusMessage::methodReply(message);
}
else
{
if (!error.isValid())
{
tqWarning("Call to implementation of org::freedesktop::DBus::PropertiesInterface::Set returned 'false' but error object is not valid!");
error = TQT_DBusError::stdFailed("org.freedesktop.DBus.Properties.Set execution failed");
}
reply = TQT_DBusMessage::methodError(message, error);
}
return reply;
}
TQT_DBusMessage PropertiesInterface::callGetAll(const TQT_DBusMessage& message)
{
TQT_DBusError error;
TQT_DBusMessage reply;
TQString _interface = message[0].toString();
TQMap< TQString, TQT_DBusVariant > _properties;
if (GetAll(_interface, _properties, error))
{
reply = TQT_DBusMessage::methodReply(message);
reply << TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap< TQString >(_properties));
}
else
{
if (!error.isValid())
{
tqWarning("Call to implementation of org::freedesktop::DBus::PropertiesInterface::GetAll returned 'false' but error object is not valid!");
error = TQT_DBusError::stdFailed("org.freedesktop.DBus.Properties.GetAll execution failed");
}
reply = TQT_DBusMessage::methodError(message, error);
}
return reply;
}
bool PropertiesInterface::handleMethodCall(const TQT_DBusMessage& message)
{
if (message.interface() != "org.freedesktop.DBus.Properties") return false;
if (message.member() == "Get")
{
TQT_DBusMessage reply = callGet(message);
handleMethodReply(reply);
return true;
}
if (message.member() == "Set")
{
TQT_DBusMessage reply = callSet(message);
handleMethodReply(reply);
return true;
}
if (message.member() == "GetAll")
{
TQT_DBusMessage reply = callGetAll(message);
handleMethodReply(reply);
return true;
}
return false;
}
}; // namespace DBus
}; // namespace freedesktop
}; // namespace org
// End of File

@ -0,0 +1,70 @@
// File autogenerated
#if !defined(PROPERTIESINTERFACE_H_INCLUDED)
#define PROPERTIESINTERFACE_H_INCLUDED
// TQt D-Bus includes
#include <tqdbuserror.h>
#include <tqdbusobject.h>
// forward declarations
class TQDomElement;
class TQString;
class TQStringList;
class TQT_DBusError;
class TQT_DBusVariant;
template <typename K, typename V> class TQMap;
namespace org
{
namespace freedesktop
{
namespace DBus
{
class PropertiesInterface : public TQT_DBusObjectBase
{
public:
virtual ~PropertiesInterface() {}
static void buildIntrospectionData(TQDomElement& interfaceElement);
protected: // implement sending signals
virtual bool handleSignalSend(const TQT_DBusMessage& reply) = 0;
virtual TQString objectPath() const = 0;
protected: // for sending D-Bus signals
virtual bool emitPropertiesChanged(const TQString& interface, const TQMap< TQString, TQT_DBusVariant >& changed_properties, const TQStringList& invalidated_properties);
protected:
virtual bool Get(const TQString& interface, const TQString& name, TQT_DBusVariant& value, TQT_DBusError& error) = 0;
virtual bool Set(const TQString& interface, const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error) = 0;
virtual bool GetAll(const TQString& interface, TQMap< TQString, TQT_DBusVariant >& properties, TQT_DBusError& error) = 0;
protected: // implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply) = 0;
protected: // usually no need to reimplement
virtual bool handleMethodCall(const TQT_DBusMessage& message);
TQT_DBusMessage callGet(const TQT_DBusMessage& message);
TQT_DBusMessage callSet(const TQT_DBusMessage& message);
TQT_DBusMessage callGetAll(const TQT_DBusMessage& message);
}; // class PropertiesInterface
}; // namespace DBus
}; // namespace freedesktop
}; // namespace org
#endif //PROPERTIESINTERFACE_H_INCLUDED
// End of File

@ -0,0 +1,129 @@
// File autogenerated
// declaration include
#include "propertiesProxy.h"
// TQt includes
#include <tqmap.h>
#include <tqstring.h>
#include <tqstringlist.h>
// TQt D-Bus includes
#include <tqdbusdata.h>
#include <tqdbusdatalist.h>
#include <tqdbusdatamap.h>
#include <tqdbuserror.h>
#include <tqdbusmessage.h>
#include <tqdbusproxy.h>
#include <tqdbusvariant.h>
namespace org
{
namespace freedesktop
{
namespace DBus
{
PropertiesProxy::PropertiesProxy(const TQString& service, const TQString& path, TQObject* parent, const char* name)
: TQObject(parent, name),
m_baseProxy(new TQT_DBusProxy())
{
m_baseProxy->setInterface("org.freedesktop.DBus.Properties");
m_baseProxy->setPath(path);
m_baseProxy->setService(service);
TQObject::connect(m_baseProxy, TQT_SIGNAL(dbusSignal(const TQT_DBusMessage&)),
this, TQT_SLOT(slotHandleDBusSignal(const TQT_DBusMessage&)));
}
PropertiesProxy::~PropertiesProxy()
{
delete m_baseProxy;
}
void PropertiesProxy::setConnection(const TQT_DBusConnection& connection)
{
m_baseProxy->setConnection(connection);
}
bool PropertiesProxy::Get(const TQString& interface, const TQString& name, TQT_DBusVariant& value, TQT_DBusError& error)
{
TQValueList<TQT_DBusData> parameters;
parameters << TQT_DBusData::fromString(interface);
parameters << TQT_DBusData::fromString(name);
TQT_DBusMessage reply = m_baseProxy->sendWithReply("Get", parameters, &error);
if (reply.type() != TQT_DBusMessage::ReplyMessage) return false;
if (reply.count() != 1) return false;
bool ok = false;
value = reply.front().toVariant(&ok);
if (!ok) return false;
return true;
}
bool PropertiesProxy::Set(const TQString& interface, const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error)
{
TQValueList<TQT_DBusData> parameters;
parameters << TQT_DBusData::fromString(interface);
parameters << TQT_DBusData::fromString(name);
parameters << TQT_DBusData::fromVariant(value);
TQT_DBusMessage reply = m_baseProxy->sendWithReply("Set", parameters, &error);
if (reply.type() != TQT_DBusMessage::ReplyMessage) return false;
return true;
}
bool PropertiesProxy::GetAll(const TQString& interface, TQMap< TQString, TQT_DBusVariant >& properties, TQT_DBusError& error)
{
TQValueList<TQT_DBusData> parameters;
parameters << TQT_DBusData::fromString(interface);
TQT_DBusMessage reply = m_baseProxy->sendWithReply("GetAll", parameters, &error);
if (reply.type() != TQT_DBusMessage::ReplyMessage) return false;
if (reply.count() != 1) return false;
bool ok = false;
bool subOK = false;
properties = reply.front().toStringKeyMap(&ok).toVariantMap(&subOK);
if (!subOK) return false;
if (!ok) return false;
return true;
}
void PropertiesProxy::slotHandleDBusSignal(const TQT_DBusMessage& message)
{
if (message.member() == "PropertiesChanged")
{
TQString _interface = message[0].toString();
TQMap< TQString, TQT_DBusVariant > _changed_properties = message[1].toStringKeyMap().toVariantMap();
TQStringList _invalidated_properties = message[2].toList().toTQStringList();
emit PropertiesChanged(_interface, _changed_properties, _invalidated_properties);
}
}
}; // namespace DBus
}; // namespace freedesktop
}; // namespace org
#include "propertiesProxy.moc"
// End of File

@ -0,0 +1,71 @@
// File autogenerated
#if !defined(PROPERTIESPROXY_H_INCLUDED)
#define PROPERTIESPROXY_H_INCLUDED
// TQt includes
#include <tqobject.h>
// TQt D-Bus includes
#include <tqdbuserror.h>
// forward declarations
class TQString;
class TQStringList;
class TQT_DBusConnection;
class TQT_DBusError;
class TQT_DBusMessage;
class TQT_DBusProxy;
class TQT_DBusVariant;
template <typename K, typename V> class TQMap;
namespace org
{
namespace freedesktop
{
namespace DBus
{
class PropertiesProxy : public TQObject
{
Q_OBJECT
public:
PropertiesProxy(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0);
virtual ~PropertiesProxy();
void setConnection(const TQT_DBusConnection& connection);
signals:
void PropertiesChanged(const TQString& interface, const TQMap< TQString, TQT_DBusVariant >& changed_properties, const TQStringList& invalidated_properties);
public:
virtual bool Get(const TQString& interface, const TQString& name, TQT_DBusVariant& value, TQT_DBusError& error);
virtual bool Set(const TQString& interface, const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error);
virtual bool GetAll(const TQString& interface, TQMap< TQString, TQT_DBusVariant >& properties, TQT_DBusError& error);
protected slots: // usually no need to reimplement
virtual void slotHandleDBusSignal(const TQT_DBusMessage& message);
protected:
TQT_DBusProxy* m_baseProxy;
private: // Hiding copy constructor and assignment operator
PropertiesProxy(const PropertiesProxy&);
PropertiesProxy& operator=(const PropertiesProxy&);
}; // class PropertiesProxy
}; // namespace DBus
}; // namespace freedesktop
}; // namespace org
#endif //PROPERTIESPROXY_H_INCLUDED
// End of File

@ -0,0 +1,83 @@
// File autogenerated
// declaration include
#include "serviceInterface.h"
// TQt includes
#include <tqdom.h>
// TQt D-Bus includes
#include <tqdbuserror.h>
#include <tqdbusmessage.h>
namespace org
{
namespace example
{
void ServiceInterface::buildIntrospectionData(TQDomElement& interfaceElement)
{
interfaceElement.setAttribute("name", "org.example.Service");
TQDomDocument document = interfaceElement.ownerDocument();
TQDomElement methodElement = document.createElement("method");
methodElement.setAttribute("name", "GetValue");
TQDomElement argumentElement = document.createElement("arg");
argumentElement.setAttribute("name", "output");
argumentElement.setAttribute("type", "t");
argumentElement.setAttribute("direction", "out");
methodElement.appendChild(argumentElement);
interfaceElement.appendChild(methodElement);
}
TQT_DBusMessage ServiceInterface::callGetValue(const TQT_DBusMessage& message)
{
TQT_DBusError error;
TQT_DBusMessage reply;
TQ_UINT64 _output;
if (GetValue(_output, error))
{
reply = TQT_DBusMessage::methodReply(message);
reply << TQT_DBusData::fromUInt64(_output);
}
else
{
if (!error.isValid())
{
tqWarning("Call to implementation of org::example::ServiceInterface::GetValue returned 'false' but error object is not valid!");
error = TQT_DBusError::stdFailed("org.example.Service.GetValue execution failed");
}
reply = TQT_DBusMessage::methodError(message, error);
}
return reply;
}
bool ServiceInterface::handleMethodCall(const TQT_DBusMessage& message)
{
if (message.interface() != "org.example.Service") return false;
if (message.member() == "GetValue")
{
TQT_DBusMessage reply = callGetValue(message);
handleMethodReply(reply);
return true;
}
return false;
}
}; // namespace example
}; // namespace org
// End of File

@ -0,0 +1,46 @@
// File autogenerated
#if !defined(SERVICEINTERFACE_H_INCLUDED)
#define SERVICEINTERFACE_H_INCLUDED
// TQt D-Bus includes
#include <tqdbuserror.h>
#include <tqdbusobject.h>
// forward declarations
class TQDomElement;
class TQT_DBusError;
namespace org
{
namespace example
{
class ServiceInterface : public TQT_DBusObjectBase
{
public:
virtual ~ServiceInterface() {}
static void buildIntrospectionData(TQDomElement& interfaceElement);
protected:
virtual bool GetValue(TQ_UINT64& output, TQT_DBusError& error) = 0;
protected: // implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply) = 0;
protected: // usually no need to reimplement
virtual bool handleMethodCall(const TQT_DBusMessage& message);
TQT_DBusMessage callGetValue(const TQT_DBusMessage& message);
}; // class ServiceInterface
}; // namespace example
}; // namespace org
#endif //SERVICEINTERFACE_H_INCLUDED
// End of File

@ -0,0 +1,190 @@
// File autogenerated
// declaration include
#include "serviceNode.h"
// TQt includes
#include <tqdom.h>
#include <tqmap.h>
#include <tqstringlist.h>
// TQt D-Bus includes
#include <tqdbusconnection.h>
#include <tqdbusmessage.h>
// interface classes includes
#include "serviceInterface.h"
#include "propertiesInterface.h"
#include "introspectableInterface.h"
namespace org
{
namespace example
{
class serviceNode::Private : public org::freedesktop::DBus::IntrospectableInterface
{
public:
virtual ~Private();
public:
TQMap<TQString, TQT_DBusObjectBase*> interfaces;
TQString introspectionData;
TQT_DBusConnection connection;
TQString objectPath;
TQStringList childrenNodes;
protected:
virtual bool Introspect(TQString& data, TQT_DBusError& error);
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
void cacheIntrospectionData();
};
serviceNode::serviceNode() : TQT_DBusObjectBase(),
m_private(new Private())
{
}
serviceNode::~serviceNode()
{
unregisterObject();
delete m_private;
}
bool serviceNode::registerObject(const TQT_DBusConnection& connection, const TQString& path)
{
if (path.isEmpty()) return false;
if (!m_private->objectPath.isEmpty()) unregisterObject();
m_private->connection = connection;
m_private->objectPath = path;
if (!m_private->connection.registerObject(path, this))
{
m_private->connection = TQT_DBusConnection();
m_private->objectPath = TQString();
return false;
}
if (m_private->interfaces.isEmpty())
{
TQString name = "org.freedesktop.DBus.Introspectable";
TQT_DBusObjectBase* interface = m_private;
m_private->interfaces.insert(name, interface);
name = "org.example.Service";
interface = createInterface(name);
Q_ASSERT(interface != 0);
m_private->interfaces.insert(name, interface);
name = "org.freedesktop.DBus.Properties";
interface = createInterface(name);
Q_ASSERT(interface != 0);
m_private->interfaces.insert(name, interface);
}
return true;
}
void serviceNode::addChildNode(const TQString& child)
{
m_private->childrenNodes.append(child);
}
void serviceNode::unregisterObject()
{
if (m_private->objectPath.isEmpty()) return;
m_private->connection.unregisterObject(m_private->objectPath);
m_private->connection = TQT_DBusConnection();
m_private->objectPath = TQString();
}
bool serviceNode::handleMethodCall(const TQT_DBusMessage& message)
{
TQMap<TQString, TQT_DBusObjectBase*>::iterator findIt = m_private->interfaces.find(message.interface());
if (findIt == m_private->interfaces.end()) return false;
return delegateMethodCall(message, findIt.data());
}
serviceNode::Private::~Private()
{
TQMap<TQString, TQT_DBusObjectBase*>::const_iterator it = interfaces.begin();
TQMap<TQString, TQT_DBusObjectBase*>::const_iterator endIt = interfaces.end();
for (; it != endIt; ++it)
{
TQT_DBusObjectBase* interface = it.data();
if (interface != this)
delete interface;
}
interfaces.clear();
}
bool serviceNode::Private::Introspect(TQString& data, TQT_DBusError& error)
{
Q_UNUSED(error);
if (introspectionData.isEmpty()) cacheIntrospectionData();
data = introspectionData;
return true;
}
void serviceNode::Private::handleMethodReply(const TQT_DBusMessage& reply)
{
connection.send(reply);
}
void serviceNode::Private::cacheIntrospectionData()
{
TQDomDocument doc;
TQDomElement interfaceElement;
TQDomElement nodeElement = doc.createElement("node");
if (!objectPath.isEmpty() && objectPath.compare("/") != 0)
{
nodeElement.setAttribute ( "name", objectPath );
}
// Introspectable is added by default. Show it only if there is interface
if (interfaces.count()>1) {
interfaceElement = doc.createElement("interface");
org::freedesktop::DBus::IntrospectableInterface::buildIntrospectionData(interfaceElement);
nodeElement.appendChild(interfaceElement);
}
interfaceElement = doc.createElement("interface");
org::example::ServiceInterface::buildIntrospectionData(interfaceElement);
nodeElement.appendChild(interfaceElement);
interfaceElement = doc.createElement("interface");
org::freedesktop::DBus::PropertiesInterface::buildIntrospectionData(interfaceElement);
nodeElement.appendChild(interfaceElement);
if (!childrenNodes.isEmpty()) {
for (TQStringList::Iterator it = childrenNodes.begin(); it != childrenNodes.end(); ++it ) {
TQDomElement nodeElement1 = doc.createElement("node");
nodeElement1.setAttribute ( "name", *it );
nodeElement.appendChild(nodeElement1);
}
}
doc.appendChild(nodeElement);
introspectionData = "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n";
introspectionData += doc.toString();
}
}; // namespace example
}; // namespace org
// End of File

@ -0,0 +1,53 @@
// File autogenerated
#if !defined(SERVICENODE_H_INCLUDED)
#define SERVICENODE_H_INCLUDED
// TQt D-Bus includes
#include <tqdbuserror.h>
#include <tqdbusobject.h>
// forward declarations
class TQString;
class TQT_DBusConnection;
namespace org
{
namespace example
{
class serviceNode : public TQT_DBusObjectBase
{
public:
serviceNode();
virtual ~serviceNode();
bool registerObject(const TQT_DBusConnection& connection, const TQString& path);
void addChildNode(const TQString& child);
void unregisterObject();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString& interfaceName) = 0;
protected: // usually no need to reimplement
virtual bool handleMethodCall(const TQT_DBusMessage& message);
private:
class Private;
Private* m_private;
private: // Hiding copy constructor and assignment operator
serviceNode(const serviceNode&);
serviceNode& operator=(const serviceNode&);
}; // class serviceNode
}; // namespace example
}; // namespace org
#endif //SERVICENODE_H_INCLUDED
// End of File

@ -0,0 +1,113 @@
// File autogenerated
// declaration include
#include "serviceProxy.h"
// TQt D-Bus includes
#include <tqdbusconnection.h>
#include <tqdbuserror.h>
#include <tqdbusmessage.h>
#include <tqdbusproxy.h>
#include <tqdbusvariant.h>
namespace org
{
namespace example
{
ServiceProxy::ServiceProxy(const TQString& service, const TQString& path, TQObject* parent, const char* name)
: TQObject(parent, name),
m_baseProxy(new TQT_DBusProxy())
{
m_baseProxy->setInterface("org.example.Service");
m_baseProxy->setPath(path);
m_baseProxy->setService(service);
}
ServiceProxy::~ServiceProxy()
{
delete m_baseProxy;
}
void ServiceProxy::setConnection(const TQT_DBusConnection& connection)
{
m_baseProxy->setConnection(connection);
}
bool ServiceProxy::GetValue(TQ_UINT64& output, TQT_DBusError& error)
{
TQValueList<TQT_DBusData> parameters;
TQT_DBusMessage reply = m_baseProxy->sendWithReply("GetValue", parameters, &error);
if (reply.type() != TQT_DBusMessage::ReplyMessage) return false;
if (reply.count() != 1) return false;
bool ok = false;
output = reply.front().toUInt64(&ok);
if (!ok) return false;
return true;
}
void ServiceProxy::setDBusProperty(const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error)
{
TQT_DBusConnection connection = m_baseProxy->connection();
TQT_DBusMessage message = TQT_DBusMessage::methodCall(m_baseProxy->service(), m_baseProxy->path(), "org.freedesktop.DBus.Properties", "Set");
message << TQT_DBusData::fromString(m_baseProxy->interface());
message << TQT_DBusData::fromString(name);
message << TQT_DBusData::fromVariant(value);
connection.sendWithReply(message, &error);
}
TQT_DBusVariant ServiceProxy::getDBusProperty(const TQString& name, TQT_DBusError& error) const
{
TQT_DBusConnection connection = m_baseProxy->connection();
TQT_DBusMessage message = TQT_DBusMessage::methodCall(m_baseProxy->service(), m_baseProxy->path(), "org.freedesktop.DBus.Properties", "Get");
message << TQT_DBusData::fromString(m_baseProxy->interface());
message << TQT_DBusData::fromString(name);
TQT_DBusMessage reply = connection.sendWithReply(message, &error);
if (reply.type() != TQT_DBusMessage::ReplyMessage) return TQT_DBusVariant();
if (reply.count() != 1) return TQT_DBusVariant();
bool ok = false;
TQT_DBusVariant value = reply.front().toVariant(&ok);
if (!ok) return TQT_DBusVariant();
return value;
}
TQ_UINT64 ServiceProxy::getSize(TQT_DBusError& error) const
{
TQT_DBusVariant variant = getDBusProperty("Size", error);
if (error.isValid()) return TQ_UINT64();
bool ok = false;
TQ_UINT64 result = variant.value.toUInt64(&ok);
if (!ok) {}
return result;
}
}; // namespace example
}; // namespace org
#include "serviceProxy.moc"
// End of File

@ -0,0 +1,60 @@
// File autogenerated
#if !defined(SERVICEPROXY_H_INCLUDED)
#define SERVICEPROXY_H_INCLUDED
// TQt includes
#include <tqobject.h>
// TQt D-Bus includes
#include <tqdbuserror.h>
// forward declarations
class TQString;
class TQT_DBusConnection;
class TQT_DBusError;
class TQT_DBusMessage;
class TQT_DBusProxy;
class TQT_DBusVariant;
namespace org
{
namespace example
{
class ServiceProxy : public TQObject
{
Q_OBJECT
public:
ServiceProxy(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0);
virtual ~ServiceProxy();
void setConnection(const TQT_DBusConnection& connection);
public:
virtual bool GetValue(TQ_UINT64& output, TQT_DBusError& error);
public:
virtual void setDBusProperty(const TQString& name, const TQT_DBusVariant& variant, TQT_DBusError& error);
virtual TQT_DBusVariant getDBusProperty(const TQString& name, TQT_DBusError& error) const;
virtual TQ_UINT64 getSize(TQT_DBusError& error) const;
protected:
TQT_DBusProxy* m_baseProxy;
private: // Hiding copy constructor and assignment operator
ServiceProxy(const ServiceProxy&);
ServiceProxy& operator=(const ServiceProxy&);
}; // class ServiceProxy
}; // namespace example
}; // namespace org
#endif //SERVICEPROXY_H_INCLUDED
// End of File

@ -0,0 +1,31 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/example/service">
<interface name="org.example.Service">
<method name="GetValue">
<arg name="output" type="t" direction="out" />
</method>
<property name="Size" type="t" access="read" />
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface" type="s" direction="in" />
<arg name="name" type="s" direction="in" />
<arg name="value" type="v" direction="out" />
</method>
<method name="Set">
<arg name="interface" type="s" direction="in" />
<arg name="name" type="s" direction="in" />
<arg name="value" type="v" direction="in" />
</method>
<method name="GetAll">
<arg name="interface" type="s" direction="in" />
<arg name="properties" type="a{sv}" direction="out" />
</method>
<signal name="PropertiesChanged">
<arg name="interface" type="s" />
<arg name="changed_properties" type="a{sv}" />
<arg name="invalidated_properties" type="as" />
</signal>
</interface>
</node>

@ -0,0 +1,145 @@
#include "testservice.h"
#include <kdebug.h>
// TQt includes
#include <tqdom.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqdbuserror.h>
#include <tqdbusmessage.h>
#include <tqdbusdatalist.h>
#include <tqdbusvariant.h>
Properties1::Properties1(TQT_DBusConnection &conn)
: m_connection(&conn)
{
}
Properties1::~Properties1(){
}
void Properties1::handleMethodReply(const TQT_DBusMessage& reply) {
m_connection->send(reply);
// do something
}
bool Properties1::Get(const TQString& interface, const TQString& name, TQT_DBusVariant& value, TQT_DBusError& error) {
// get interface
// get param name from interface
value.value = TQT_DBusData::fromUInt64(131719);
value.signature = value.value.buildDBusSignature();
return true;
}
bool Properties1::Set(const TQString& interface, const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error) {
// get interface
// get param name from interface
// do something
return true;
}
bool Properties1::GetAll(const TQString& interface, TQMap< TQString, TQT_DBusVariant >& properties, TQT_DBusError& error) {
// get interface
// get param name from interface
// do something
return true;
}
bool Properties1::handleSignalSend(const TQT_DBusMessage& reply) {
// do something
return true;
}
TQString Properties1::objectPath() const {
// do something
return TQString();
}
TQT_DBusObjectBase* Properties1::createInterface(const TQString& interface) {
if (interface == "org.example.Service")
return (TQT_DBusObjectBase*) new Interface1((*m_connection));
else
return (TQT_DBusObjectBase*) this;
}
Interface1::Interface1(TQT_DBusConnection &conn)
: m_connection(&conn)
{
testval = 123456;
}
Interface1::~Interface1(){
}
void Interface1::handleMethodReply(const TQT_DBusMessage& reply) {
// do something
m_connection->send(reply);
}
bool Interface1::GetValue(TQ_UINT64& output, TQT_DBusError& error) {
output = testval;
return true;
}
RootService::RootService(TQT_DBusConnection &connection )
: DBusBaseNode(), m_connection(connection)
{
registerObject(m_connection,"/");
addChildNode("org");
}
RootService::~RootService(){
}
TQT_DBusObjectBase* RootService::createInterface(const TQString& interfaceName)
{
return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
}
OrgService::OrgService(TQT_DBusConnection &connection )
: DBusBaseNode(), m_connection(connection)
{
registerObject(m_connection,"/org");
addChildNode("example");
}
OrgService::~OrgService(){
}
TQT_DBusObjectBase* OrgService::createInterface(const TQString& interfaceName)
{
return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
}
ExampleService::ExampleService(TQT_DBusConnection &connection )
: DBusBaseNode(), m_connection(connection)
{
registerObject(m_connection,"/org/example");
addChildNode("service");
}
ExampleService::~ExampleService(){
}
TQT_DBusObjectBase* ExampleService::createInterface(const TQString& interfaceName)
{
return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
}
MultiInterfaceService::MultiInterfaceService(TQT_DBusConnection &connection )
: org::example::serviceNode(), m_connection(connection)
{
m_interfaces.insert("org.freedesktop.DBus.Introspectable", this);
m_interfaces.insert("org.example.Service", new Interface1(m_connection));
m_interfaces.insert("org.freedesktop.DBus.Properties", new Properties1(m_connection));
registerObject(m_connection,"/org/example/service");
}
MultiInterfaceService::~MultiInterfaceService(){
}
TQT_DBusObjectBase* MultiInterfaceService::createInterface(const TQString& interfaceName)
{
return (TQT_DBusObjectBase*) m_interfaces[interfaceName];
}

@ -0,0 +1,91 @@
#include <tqdbusconnection.h>
#include <tqdbusobject.h>
#include <tqmap.h>
#include <tqstringlist.h>
#include "serviceInterface.h"
#include "serviceNode.h"
#include "dbusbaseNode.h"
#include "propertiesInterface.h"
class Properties1 : public org::freedesktop::DBus::PropertiesInterface
{
public:
Properties1(TQT_DBusConnection&);
~Properties1();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
bool Get(const TQString& interface, const TQString& name, TQT_DBusVariant& value, TQT_DBusError& error);
bool Set(const TQString& interface, const TQString& name, const TQT_DBusVariant& value, TQT_DBusError& error);
bool GetAll(const TQString& interface, TQMap< TQString, TQT_DBusVariant >& properties, TQT_DBusError& error);
void handleMethodReply(const TQT_DBusMessage& reply);
bool handleSignalSend(const TQT_DBusMessage& reply);
TQString objectPath() const;
private:
TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
TQT_DBusConnection *m_connection;
};
class Interface1 : public org::example::ServiceInterface
{
public:
Interface1(TQT_DBusConnection&);
virtual ~Interface1();
protected: // implement methods
virtual bool GetValue(TQ_UINT64& output, TQT_DBusError& error);
protected: // implement sending replies
virtual void handleMethodReply(const TQT_DBusMessage& reply);
private:
TQT_DBusConnection *m_connection;
std::uint64_t testval;
};
class RootService : public DBusBaseNode
{
public:
RootService(TQT_DBusConnection&);
~RootService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
TQT_DBusConnection m_connection;
};
class OrgService : public DBusBaseNode
{
public:
OrgService(TQT_DBusConnection&);
~OrgService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
TQT_DBusConnection m_connection;
};
class ExampleService : DBusBaseNode
{
public:
ExampleService(TQT_DBusConnection&);
~ExampleService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
TQT_DBusConnection m_connection;
};
class MultiInterfaceService : public org::example::serviceNode
{
public:
MultiInterfaceService(TQT_DBusConnection&);
~MultiInterfaceService();
protected:
virtual TQT_DBusObjectBase* createInterface(const TQString&);
private:
TQMap<TQString, TQT_DBusObjectBase*> m_interfaces;
TQT_DBusConnection m_connection;
};

@ -0,0 +1,30 @@
/usr/bin/g++ -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time \
-D_FORTIFY_SOURCE=2 -DQT_NO_ASCII_CAST -DQT_CLEAN_NAMESPACE -DQT_NO_STL -DQT_NO_COMPAT \
-DQT_NO_TRANSLATION -DQT_THREAD_SUPPORT -D_REENTRANT -include tqt.h -I/usr/include/tqt3 \
-I/opt/trinity/include/ -I/usr/include/dbus-1-tqt -I/usr/include/tqt -I -DQT_NO_ASCII_CAST \
-DQT_CLEAN_NAMESPACE -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION -DQT_THREAD_SUPPORT \
-D_REENTRANT -include tqt.h -g -Wl,-z,relro main.cpp testservice.cpp \
dbusbaseNode.cpp serviceNode.cpp introspectableInterface.cpp \
propertiesInterface.cpp propertiesProxy.cpp serviceInterface.cpp \
-o tqdbusexample -ldbus-1-tqt \
/opt/trinity/lib/libtdeparts.so /opt/trinity/lib/libtdeio.so \
/opt/trinity/lib/libtdecore.so -ltqt -ltqt-mt -lXrender -lX11 -lc \
/usr/lib/x86_64-linux-gnu/libz.so -lidn -lXcomposite -lICE -lSM -lutil -lr -lacl -lattr -ltqui
# build client example
tmoc serviceProxy.h -o serviceProxy.moc
tmoc exampleclient.h -o exampleclient.moc
tmoc propertiesProxy.h -o propertiesProxy.moc
/usr/bin/g++ -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time \
-D_FORTIFY_SOURCE=2 -DQT_NO_ASCII_CAST -DQT_CLEAN_NAMESPACE -DQT_NO_STL -DQT_NO_COMPAT \
-DQT_NO_TRANSLATION -DQT_THREAD_SUPPORT -D_REENTRANT -include tqt.h -I. -I/usr/include/tqt3 \
-I/opt/trinity/include/ -I/usr/include/dbus-1-tqt -I/usr/include/tqt -I -DQT_NO_ASCII_CAST \
-DQT_CLEAN_NAMESPACE -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION -DQT_THREAD_SUPPORT \
-D_REENTRANT -include tqt.h -g -Wl,-z,relro testservice.cpp dbusbaseNode.cpp serviceNode.cpp \
propertiesInterface.cpp propertiesProxy.cpp serviceProxy.cpp serviceInterface.cpp \
introspectableInterface.cpp exampleclient.cpp \
-o tqdbusexample_client -ldbus-1-tqt \
/opt/trinity/lib/libtdeparts.so /opt/trinity/lib/libtdeio.so \
/opt/trinity/lib/libtdecore.so -ltqt -ltqt-mt -lXrender -lX11 -lc \
/usr/lib/x86_64-linux-gnu/libz.so -lidn -lXcomposite -lICE -lSM -lutil -lr -lacl -lattr -ltqui
Loading…
Cancel
Save