You will need to include the libdbus libraries in your project or make files. They are not in the default path.
The first header files you will need:
#include <stdio.h>
#include <dbus/dbus.h>
#endif
You need a connection to the DBus server running, and an error object for the error message. In C, you the function return is the state usually 0 for null then you check the error object for the message.
int main()
{
DBusError error;
dbus_error_init(&error);
Use the dbus native functions to connect to the System bus. You can also connect to teh session bus which is usually meant for application to application communication. System is meant for events, but you can use either one. There is also a starter bus, but not meant to be used by us.
conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
if(conn == NULL)
}
else printf("Connected to System Bus\n");
If you succeed at that point, you will have to create you signal. This involves creating a DBusMessage (represents the signal) and DBusMessageIter (which used to store arguments). dbus_uint32_t serial = 0;// You need a unique number to associate replies with requests. Will be used to manage communication later. Signal value is a string. dbus_uint32_t serial = 0; DBusMessage* msg; DBusMessageIter args; const char* sigvalue = "Hello World";
printf("Attempting to create a new Signal.\n");