Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #include "dbus.h"
10 :
11 : #ifdef HAVE_KDBCONFIG_H
12 : #include "kdbconfig.h"
13 : #endif
14 :
15 : #include <kdbhelper.h>
16 :
17 : #include <stdio.h>
18 :
19 : void print_message (DBusMessage * message, dbus_bool_t literal);
20 :
21 0 : DBusHandlerResult callback (DBusConnection * connection ELEKTRA_UNUSED, DBusMessage * message, void * user_data ELEKTRA_UNUSED)
22 : {
23 0 : if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameAcquired")) return DBUS_HANDLER_RESULT_HANDLED;
24 :
25 0 : if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) return DBUS_HANDLER_RESULT_HANDLED;
26 :
27 0 : printf ("Notify received\n");
28 0 : return DBUS_HANDLER_RESULT_HANDLED;
29 : }
30 :
31 0 : int main (int argc, char ** argv)
32 : {
33 0 : if (argc == 2)
34 : {
35 0 : ElektraDbusPluginData * data = elektraCalloc (sizeof *data);
36 0 : if (!strcmp (argv[1], "send_session")) elektraDbusSendMessage (data, DBUS_BUS_SESSION, "test1", "KeyChanged");
37 0 : if (!strcmp (argv[1], "send_system")) elektraDbusSendMessage (data, DBUS_BUS_SYSTEM, "test2", "KeyChanged");
38 0 : if (!strcmp (argv[1], "receive_session")) elektraDbusReceiveMessage (DBUS_BUS_SESSION, callback);
39 0 : if (!strcmp (argv[1], "receive_system")) elektraDbusReceiveMessage (DBUS_BUS_SYSTEM, callback);
40 : }
41 : }
|