summary refs log blame commit diff stats
path: root/src/common/dbus/Makefile.am
blob: 11b5d77d247882a5973f24257219c1818f7cfb1a (plain) (tree)
generated by cgit-pink 1.4.1 (git 2.36.1) at 2025-02-15 00:34:42 +0000
"o">&error); } /* Now if you write "/test blah" again in the HexChat window * you'll get a "Unknown command" error message */ g_print ("test command received: %s\n", word_eol[1]); if (!dbus_g_proxy_call (proxy, "Print", &error, G_TYPE_STRING, "test command succeed", G_TYPE_INVALID, G_TYPE_INVALID)) { write_error ("Failed to complete Print", &error); } } } static void unload_cb (void) { g_print ("Good bye !\n"); exit (EXIT_SUCCESS); } int main (int argc, char **argv) { DBusGConnection *connection; DBusGProxy *remote_object; GMainLoop *mainloop; gchar *path; GError *error = NULL; #if ! GLIB_CHECK_VERSION (2, 36, 0) g_type_init (); #endif connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) { write_error ("Couldn't connect to session bus", &error); return EXIT_FAILURE; } remote_object = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE, DBUS_REMOTE, DBUS_REMOTE_CONNECTION_INTERFACE); if (!dbus_g_proxy_call (remote_object, "Connect", &error, G_TYPE_STRING, argv[0], G_TYPE_STRING, "example", G_TYPE_STRING, "Example of a D-Bus client", G_TYPE_STRING, "1.0", G_TYPE_INVALID, G_TYPE_STRING, &path, G_TYPE_INVALID)) { write_error ("Failed to complete Connect", &error); return EXIT_FAILURE; } g_object_unref (remote_object); remote_object = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE, path, DBUS_REMOTE_PLUGIN_INTERFACE); g_free (path); if (!dbus_g_proxy_call (remote_object, "HookCommand", &error, G_TYPE_STRING, "test", G_TYPE_INT, 0, G_TYPE_STRING, "Simple D-BUS example", G_TYPE_INT, 1, G_TYPE_INVALID, G_TYPE_UINT, &command_id, G_TYPE_INVALID)) { write_error ("Failed to complete HookCommand", &error); return EXIT_FAILURE; } g_print ("Command hook id=%d\n", command_id); if (!dbus_g_proxy_call (remote_object, "HookServer", &error, G_TYPE_STRING, "RAW LINE", G_TYPE_INT, 0, G_TYPE_INT, 0, G_TYPE_INVALID, G_TYPE_UINT, &server_id, G_TYPE_INVALID)) { write_error ("Failed to complete HookServer", &error); return EXIT_FAILURE; } g_print ("Server hook id=%d\n", server_id); dbus_g_object_register_marshaller ( _hexchat_marshal_VOID__POINTER_POINTER_UINT_UINT, G_TYPE_NONE, G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_object_register_marshaller ( g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, G_TYPE_INVALID); dbus_g_proxy_add_signal (remote_object, "CommandSignal", G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (remote_object, "CommandSignal", G_CALLBACK (test_command_cb), NULL, NULL); dbus_g_proxy_add_signal (remote_object, "ServerSignal", G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (remote_object, "ServerSignal", G_CALLBACK (test_server_cb), NULL, NULL); dbus_g_proxy_add_signal (remote_object, "UnloadSignal", G_TYPE_INVALID); dbus_g_proxy_connect_signal (remote_object, "UnloadSignal", G_CALLBACK (unload_cb), NULL, NULL); /* Now you can write on the HexChat windows: "/test arg1 arg2 ..." */ mainloop = g_main_loop_new (NULL, FALSE); g_main_loop_run (mainloop); return EXIT_SUCCESS; }