/* gcc -Wall -o kill-gabble kill-gabble.c `pkg-config --libs --cflags gio-2.0 glib-2.0 gio-unix-2.0` */ #include #include #include #include #include #include #include #include #include #include #include #include gint main (gint argc, gchar *argv[]) { GDBusConnection *c; GError *error = NULL; GVariant *parameters = NULL; GVariantBuilder builder; GUnixFDList *fd_list; GVariant *v_str; GVariant *dict; int fd = 1; /* some random existing fd. I chose stdout err. */ c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); /* Send message according to the Telepathy spec: * http://telepathy.freedesktop.org/spec/Connection_Manager.html#Method:RequestConnection * Except we don't use a correct "Connection_Parameter_Name"... */ g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); /* Prepare fds */ fd_list = g_unix_fd_list_new_from_array (&fd, 1); /* parameter1: string: Protocol */ v_str = g_variant_new_string ("foo"); g_assert (v_str); g_variant_builder_add_value (&builder, v_str); /* parameter2: a{sv} with v=fd */ dict = g_variant_new_dict_entry (g_variant_new_string ("bar"), g_variant_new_variant (g_variant_new_handle (0))); g_variant_builder_add_value(&builder, g_variant_new_array(NULL, &dict, 1)); parameters = g_variant_builder_end (&builder); g_dbus_connection_call_with_unix_fd_list (c, "org.freedesktop.Telepathy.ConnectionManager.gabble", "/org/freedesktop/Telepathy/ConnectionManager/gabble", "org.freedesktop.Telepathy.ConnectionManager", "RequestConnection", parameters, NULL, G_DBUS_CALL_FLAGS_NONE, -1, fd_list, NULL, NULL, NULL); /* The message is lost without the sleep. GDBus is in another thread... */ sleep (1); return 0; }