Sending Signals (and possibly a BUG????)

mahir at softhome.net mahir at softhome.net
Fri Apr 16 20:28:56 EST 2004


Hi, 

Please help me understand the procedure for sending and receiving DBUS
signals to peer applications(connected to dbus) or broadcast to all the 
connected applications. 

I've written the following CODE FRAGMENT to send the signal to the bus,
I would like to know how to write the message matching rules and to write
the corresponding signal handlers in the peer application code. 

Currently the peer application receives the messages in same way as while
sending "method_call", but I'm not able to catch the "signal". 

Possible ~~BUG~~
When I try to set the sender using the "dbus_message_set_sender()" function
call and send the message to dbus, the dbus daemon crashes... everytime
Please look at the commented code in the CODE FRAGMENT given below tagged
with ~~~BUG~~~ 

Thanks,
mahir 


CODE FRAGMENT: 

       const char* my_path = "org.organization.interface";
       const char* myinf = "/org/organization/interface"; 

       msg = dbus_message_new_signal(my_path, my_inf, SAMPLE_SIGNAL);
       if(msg == NULL)
       {
               fprintf(stderr, "Creation of New Signal failed, LINE: %d\n",
                                       __LINE__);
               exit(1);
       } 

#if 0
//~~~BUG~~~~
       //Passing a string with dot[s] makes the daemon crash
       //Usage is same as in dbus-message.c:6894
       if(!dbus_message_set_sender(msg, "com.nokia.sputnik"))
               printf(stderr, "send_signal: No mem at LINE: %d\n", 
__LINE__);
//~~~BUG~~~~
#endif 

       if(!dbus_message_append_args(msg, DBUS_TYPE_STRING, "Hello.string",
                                       DBUS_TYPE_INVALID))
               printf(stderr, "send_signal: No mem at LINE: %d\n", 
__LINE__); 




More information about the dbus mailing list