PDA

View Full Version : Connect Problem



nrabara
2nd May 2009, 12:04
The declaration of connect is as below for QDBusConnection,


bool QDBusConnection::connect ( const QString & service, const QString & path, const QString & interface, const QString & name, const QString & signature, QObject * receiver, const char * slot )

now scenario is as below,

service = com.test.serivce
path = /
interface = ?
name = buttonPressed
receiver=? [because i want to call SLOT of other application whose object is not declared in this application]
slot= ? [this slot is not defined or declared in this application its a port of current application it's in other application]

If I call this connect from the process which have registered it's object service and path, Is it Possible to connect to SLOT in process which has created interface of this service(not registered any object)?

Your suggestion would be highly appriciable.

wysota
4th May 2009, 08:26
You can't connect signals from your applications to receivers in other applications this way. You can only associate a signal in your application with a message that will be sent to the bus. It is the other application that has to connect to the bus and the interface exposed by your application.

nrabara
4th May 2009, 10:10
Thanks wysota,

I got your point, but my scenario is quit different, It's like below

I have created 2 process
1) Qt Process (for GUI)
2) ./MyApplication (for hardware stuff)

QT Process would do all GUI related stuff and content functions that can change/modify the display by adding or removing widgets, this function would be call by MyApplication.

Qt Process CODE


main(int argc, char *argv[])
{
QApplication a(argc, argv)
Widget w;

// get connected to DBus
// registered service & object

}


Myapplication will create interface to this sevice and call the methods of this Qt process(I am able to do this)
MyApplication Code


main()
{
// Create interface to dbus service.

// Call function of Qt process from this MyApplication process
interface.call("method_name",arg1,arg2,...)


}




I will(my device) get messages from another device [ master ] in my case, master will send commands and messages to MyApplication process.

Master's command & mesg. would be the information, what to show on display(what widget, color, font size, widget string etc.) .

MyApplication process will interpret this messages and call function of Qt Process to show widgets on the display according the argument passed from MyApplication process.

Now,I want signal / or message from Qt on click of any widget.
In MyApplication I have not registered any object and service, I have just created interface and calling function directly, Because my MyApplication code is just like below



main()
{
// system initialization

// create Interface of service registered by Qt Process

while()
{
//driver events to poll
// DSP message queue to poll(check for messg and command )
// other time critical tasks

// call function of Qt process if Display need to change the content
interface.call("method_name",arg1,arg2,...)

}


}



Now if I register object from MyApplication, I need to use Q_OBJECT and I must call exec() to get into the event loop. if I call exec(), process will go in wait state and my time critical data would be missed.

What should I do? how can it possible to manage communication with dbus without affection other time Critical tasks ?

Your suggestion would be great help for me.

wysota
4th May 2009, 12:19
You don't have to use Qt to use D-BUS. On the other hand if you want to be notified about something happening in another application (regardless if you use Qt or not and if you use D-BUS or not) you will have to do some polling or waiting. If you want, you can do that in a secondary thread but at some point you will have to check whether there is something waiting for you in the IPC channel.