static void audtool_connect (void) { GError * error = NULL; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, & error); if (! connection) { fprintf (stderr, "D-Bus error: %s\n", error->message); g_error_free (error); exit (EXIT_FAILURE); } dbus_proxy = obj_audacious_proxy_new_sync (connection, 0, "org.atheme.audacious", "/org/atheme/audacious", NULL, & error); if (! dbus_proxy) { fprintf (stderr, "D-Bus error: %s\n", error->message); g_error_free (error); g_dbus_connection_close_sync (connection, NULL, NULL); exit (EXIT_FAILURE); } atexit (audtool_disconnect); }
static void audtool_disconnect (void) { g_object_unref (dbus_proxy); dbus_proxy = NULL; g_dbus_connection_close_sync (connection, NULL, NULL); connection = NULL; }
static void __bt_telephony_gdbus_init(void) { GDBusConnection *g_conn; GError *g_err = NULL; BT_DBG("+"); ret_if(bluetooth_telephony_obj != NULL); g_conn = _bt_init_system_gdbus_conn(); ret_if(g_conn == NULL); bluetooth_telephony_obj = org_tizen_csd_call_instance_skeleton_new(); g_signal_connect(bluetooth_telephony_obj, "handle-answer", G_CALLBACK(bluetooth_telephony_method_answer), NULL); g_signal_connect(bluetooth_telephony_obj, "handle-release", G_CALLBACK(bluetooth_telephony_method_release), NULL); g_signal_connect(bluetooth_telephony_obj, "handle-reject", G_CALLBACK(bluetooth_telephony_method_reject), NULL); g_signal_connect(bluetooth_telephony_obj, "handle-threeway", G_CALLBACK(bluetooth_telephony_method_threeway), NULL); g_signal_connect(bluetooth_telephony_obj, "handle-send-dtmf", G_CALLBACK(bluetooth_telephony_method_send_dtmf), NULL); if (g_dbus_interface_skeleton_export( G_DBUS_INTERFACE_SKELETON(bluetooth_telephony_obj), g_conn, "/", &g_err) == FALSE) { if (g_err) { BT_ERR("Export error: %s", g_err->message); g_clear_error(&g_err); } g_object_unref(bluetooth_telephony_obj); bluetooth_telephony_obj = NULL; g_dbus_connection_close_sync(gdbus_conn, NULL, NULL); gdbus_conn = NULL; return; } gdbus_conn = g_conn; BT_DBG("-"); }
void mpris2_cleanup (void) { hook_dissociate ("playback begin", (HookFunction) update_playback_status); hook_dissociate ("playback pause", (HookFunction) update_playback_status); hook_dissociate ("playback stop", (HookFunction) update_playback_status); hook_dissociate ("playback unpause", (HookFunction) update_playback_status); hook_dissociate ("playlist set playing", (HookFunction) update_metadata); hook_dissociate ("playlist position", (HookFunction) update_metadata); hook_dissociate ("playlist update", (HookFunction) update_metadata); hook_dissociate ("playback ready", (HookFunction) emit_seek); hook_dissociate ("playback seek", (HookFunction) emit_seek); if (update_timer) { g_source_remove (update_timer); update_timer = 0; } g_dbus_connection_close_sync (bus, NULL, NULL); g_object_unref (object_core); g_object_unref (object_player); if (image_file) { aud_art_unref (last_file); image_file = NULL; } str_unref (last_title); str_unref (last_artist); str_unref (last_album); str_unref (last_file); last_title = last_artist = last_album = last_file = NULL; last_length = 0; if (metadata_type) { g_variant_type_free (metadata_type); metadata_type = NULL; } }
static void test_once (Fixture *f, gconstpointer context) { GDBusMessage *message; gboolean pipe_res; pipe_res = g_unix_open_pipe (f->server_to_client, FD_CLOEXEC, &f->error); g_assert (pipe_res); pipe_res = g_unix_open_pipe (f->client_to_server, FD_CLOEXEC, &f->error); g_assert (pipe_res); f->server_iostream = my_io_stream_new_for_fds (f->client_to_server[0], f->server_to_client[1]); f->iostream = my_io_stream_new_for_fds (f->server_to_client[0], f->client_to_server[1]); g_dbus_connection_new (f->server_iostream, f->guid, (G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER | G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS), NULL /* auth observer */, NULL /* cancellable */, on_new_conn, &f->server_conn); g_dbus_connection_new (f->iostream, NULL, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, NULL /* auth observer */, NULL /* cancellable */, on_new_conn, &f->connection); while (f->server_conn == NULL || f->connection == NULL) g_main_context_iteration (NULL, TRUE); /* * queue a message - it'll sometimes be sent while the close is pending, * triggering the bug */ message = g_dbus_message_new_signal ("/", "com.example.Foo", "Bar"); g_dbus_connection_send_message (f->connection, message, 0, NULL, &f->error); g_assert_no_error (f->error); g_object_unref (message); /* close the connection (deliberately or via last-unref) */ if (g_strcmp0 (context, "unref") == 0) { g_clear_object (&f->connection); } else { g_dbus_connection_close_sync (f->connection, NULL, &f->error); g_assert_no_error (f->error); } /* either way, wait for the connection to close */ while (!g_dbus_connection_is_closed (f->server_conn)) g_main_context_iteration (NULL, TRUE); /* clean up before the next run */ g_clear_object (&f->iostream); g_clear_object (&f->server_iostream); g_clear_object (&f->connection); g_clear_object (&f->server_conn); g_clear_error (&f->error); }
int main (int argc, char **argv) { ServiceData svc = {0,}; GError *error = NULL; const char *address = NULL; char *guid; #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_type_init (); gst_init (NULL, NULL); g_set_prgname ("rhythmbox-metadata"); if (argv[1] != NULL && strcmp(argv[1], "--debug") == 0) { argv++; rb_debug_init (TRUE); } else if (argv[1] != NULL && strcmp (argv[1], "--debug-match") == 0) { rb_debug_init_match (argv[2]); argv += 2; } else { rb_debug_init (FALSE); } /* bug report modes */ if (argv[1] != NULL && strcmp(argv[1], "--load") == 0) { return test_load (argv[2]); } if (argv[1] != NULL && strcmp(argv[1], "--saveable-types") == 0) { return test_saveable_types (); } if (argv[1] != NULL && strcmp (argv[1], "--external") == 0) { argv++; svc.external = TRUE; } if (argv[1] == NULL) { address = "unix:tmpdir=/tmp"; } else { address = argv[1]; } rb_debug ("initializing metadata service; pid = %d; address = %s", getpid (), address); svc.metadata = rb_metadata_new (); svc.loop = g_main_loop_new (NULL, TRUE); /* create the server */ guid = g_dbus_generate_guid (); svc.server = g_dbus_server_new_sync (address, G_DBUS_SERVER_FLAGS_NONE, guid, NULL, NULL, &error); g_free (guid); if (error != NULL) { g_warning ("D-Bus server init failed: %s", error->message); return -1; } /* set up interface info */ svc.node_info = g_dbus_node_info_new_for_xml (rb_metadata_iface_xml, &error); if (error != NULL) { g_warning ("D-Bus server init failed: %s", error->message); return -1; } g_signal_connect (svc.server, "new-connection", G_CALLBACK (new_connection_cb), &svc); g_dbus_server_start (svc.server); /* write the server address back to the parent process */ { const char *addr; addr = g_dbus_server_get_client_address (svc.server); rb_debug ("D-BUS server listening on address %s", addr); printf ("%s\n", addr); fflush (stdout); } /* run main loop until we get bored */ if (!svc.external) g_timeout_add_seconds (ATTENTION_SPAN / 2, (GSourceFunc) electromagnetic_shotgun, &svc); g_main_loop_run (svc.loop); if (svc.connection) { g_dbus_connection_close_sync (svc.connection, NULL, NULL); g_object_unref (svc.connection); } g_object_unref (svc.metadata); g_main_loop_unref (svc.loop); g_dbus_server_stop (svc.server); g_object_unref (svc.server); gst_deinit (); return 0; }