How to properly connect Slots and Signals over QDBus
Unsolved
General and Desktop
-
So I have a service that will have multiple clients connecting to it. I want to connect a signal to a slot in such a way that when one client emits a signal, all of the other connected clients will also receive this signal. The client objects are subclassed from the auto-generated proxy that shares the same methods and signals as the server class. I'm assuming inside the client class I will have to connect the signals and slots through a QDBusConnection, but I am unsure of how to do this. If anyone could offer some advice I would greatly appreciate it!
The Server Object:
namespace SmartAppMgr { class SmartAppManager : public QObject { Q_OBJECT public: SmartAppManager ( QObject* a_parent = NULL ); virtual ~SmartAppManager(); Q_SIGNAL void PhoneCallStatusChanged( ); Q_SLOT void onPhoneCallStatusChanged(); bool getPhoneCallStatus(); void setPhoneCallStatus( bool status ); private: bool m_phoneCallStatus; QDBusConnection mDBusConnection; }; }
The Client Object:
namespace SmartAppMgr { class SmartAppManagerClient: public ComSmartAppManagerInterface { Q_OBJECT public: //! Constructor SmartAppManagerClient ( QDBusConnection const& a_connection, QObject* a_parent = 0 ); //! Destructor virtual ~SmartAppManagerClient(); }; }
The service that actually runs everything:
int main ( int argc, char* argv[] ) { // Creating the app QCoreApplication app( argc, argv ); QDBusConnection connection = QDBusConnection::systemBus(); SmartAppMgr::SmartAppManager smartAppManager; SmartAppManagerAdaptor smartAppManagerAdaptor( &smartAppManager ); if( connection.registerService( SmartAppMgr::sSmartAppManagerBusName ) ) { qDebug() << "\n\nSuccessfully registered the SmartAppManager DBus Service!\n\n"; } else { qDebug() << "\n\nFailed to register the SmartAppManager DBus serivce!\n\n"; return -1; } if ( connection.registerObject( SmartAppMgr::sSmartAppManagerObjectPath, &smartAppManager ) ) { qDebug() << "\n\nSuccessfully registered SmartAppManager DBus object!\n\n"; } else { qDebug() << "\n\nFailed to register the SmartAppManager DBus object!\n\n"; return -1; } return app.exec(); }
-
Hi,
Aren't you implementing something like QtRemoteObjects ?