int main (int argc, char **argv) { int ret; SRunner *sr; Suite *s; /* init stuff */ rb_profile_start ("rhythmdb-query-model test suite"); rb_threads_init (); setlocale (LC_ALL, NULL); rb_debug_init (TRUE); rb_refstring_system_init (); rb_file_helpers_init (TRUE); /* setup tests */ s = rhythmdb_query_model_suite (); sr = srunner_create (s); init_setup (sr, argc, argv); init_once (FALSE); srunner_run_all (sr, CK_NORMAL); ret = srunner_ntests_failed (sr); srunner_free (sr); rb_file_helpers_shutdown (); rb_refstring_system_shutdown (); rb_profile_end ("rhythmdb-query-model test suite"); return ret; }
int main (int argc, char **argv) { int ret; SRunner *sr; Suite *s; g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); rb_threads_init (); rb_debug_init (TRUE); rb_refstring_system_init (); rb_file_helpers_init (TRUE); /* setup tests */ s = rb_query_creator_suite (); sr = srunner_create (s); init_setup (sr, argc, argv); init_once (FALSE); srunner_run_all (sr, CK_NORMAL); ret = srunner_ntests_failed (sr); srunner_free (sr); rb_file_helpers_shutdown (); rb_refstring_system_shutdown (); return ret; }
int main (int argc, char **argv) { GtkWidget *main_window; GtkTreeModel *main_model; GtkTreeIter iter; RBEntryView *view; RhythmDB *db; RhythmDBEntry *entry; gtk_init (&argc, &argv); gdk_threads_init (); rb_thread_helpers_init (); rb_file_helpers_init (TRUE); rb_stock_icons_init (); rb_debug_init (TRUE); GDK_THREADS_ENTER (); db = rhythmdb_tree_new ("test"); rhythmdb_write_lock (db); entry = create_entry (db, "file:///sin.mp3", "Sin", "Pretty Hate Machine", "Nine Inch Nails", "Rock"); rhythmdb_write_unlock (db); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, RHYTHMDB_ENTRY_TYPE_IGNORE, RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); view = rb_entry_view_new (db, rb_file ("rb-entry-view-library.xml")); rb_entry_view_set_query_model (view, RHYTHMDB_QUERY_MODEL (main_model)); gtk_container_add (GTK_CONTAINER (main_window), GTK_WIDGET (view)); g_signal_connect (G_OBJECT (main_window), "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show_all (GTK_WIDGET (main_window)); gtk_main (); rhythmdb_shutdown (db); g_object_unref (G_OBJECT (db)); GDK_THREADS_LEAVE (); exit (0); }
int main (int argc, char **argv) { int ret; SRunner *sr; Suite *s; rb_profile_start ("rb-file-helpers test suite"); g_thread_init (NULL); rb_threads_init (); setlocale (LC_ALL, NULL); rb_debug_init (TRUE); rb_file_helpers_init (TRUE); /* setup tests */ s = rb_file_helpers_suite (); sr = srunner_create (s); init_setup (sr, argc, argv); init_once (FALSE); srunner_run_all (sr, CK_NORMAL); ret = srunner_ntests_failed (sr); srunner_free (sr); rb_file_helpers_shutdown (); rb_profile_end ("rb-file-helpers test suite"); return ret; }
int main (int argc, char **argv) { RhythmDB *db; char *name; int i; if (argc < 2) { name = g_build_filename (rb_user_data_dir(), "rhythmdb.xml", NULL); g_print ("using %s\n", name); } else { name = g_strdup (argv[1]); } rb_profile_start ("load test"); g_thread_init (NULL); rb_threads_init (); gtk_set_locale (); gtk_init (&argc, &argv); rb_debug_init (FALSE); rb_refstring_system_init (); rb_file_helpers_init (TRUE); GDK_THREADS_ENTER (); db = rhythmdb_tree_new ("test"); g_object_set (G_OBJECT (db), "name", name, NULL); g_free (name); for (i = 1; i <= 10; i++) { int j; rb_profile_start ("10 rhythmdb loads"); for (j = 1; j <= 10; j++) { set_waiting_signal (G_OBJECT (db), "load-complete"); rhythmdb_load (db); wait_for_signal (); rhythmdb_entry_delete_by_type (db, RHYTHMDB_ENTRY_TYPE_SONG); rhythmdb_entry_delete_by_type (db, rhythmdb_entry_type_get_by_name (db, "iradio")); rhythmdb_entry_delete_by_type (db, RHYTHMDB_ENTRY_TYPE_PODCAST_FEED); rhythmdb_entry_delete_by_type (db, RHYTHMDB_ENTRY_TYPE_PODCAST_POST); } rb_profile_end ("10 rhythmdb loads"); g_print ("completed %d loads\n", i * 10); } rhythmdb_shutdown (db); g_object_unref (G_OBJECT (db)); db = NULL; rb_file_helpers_shutdown (); rb_refstring_system_shutdown (); rb_profile_end ("load test"); return 0; }
int main (int argc, char **argv) { int ret; SRunner *sr; Suite *s; rb_profile_start ("rb-audioscrobbler test suite"); rb_threads_init (); rb_debug_init (TRUE); /* setup tests */ s = rb_audioscrobbler_suite (); sr = srunner_create (s); srunner_run_all (sr, CK_NORMAL); ret = srunner_ntests_failed (sr); srunner_free (sr); rb_profile_end ("rb-audioscrobbler test suite"); return ret; }
int main (int argc, char **argv) { DBusGConnection *session_bus; GError *error = NULL; RBShell *rb_shell; gboolean activated; gboolean autostarted; char *accel_map_file = NULL; char *desktop_file_path; GOptionContext *context; static const GOptionEntry options [] = { { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug output"), NULL }, { "debug-match", 'D', 0, G_OPTION_ARG_STRING, &debug_match, N_("Enable debug output matching a specified string"), NULL }, { "no-update", 0, 0, G_OPTION_ARG_NONE, &no_update, N_("Do not update the library with file changes"), NULL }, { "no-registration", 'n', 0, G_OPTION_ARG_NONE, &no_registration, N_("Do not register the shell"), NULL }, { "dry-run", 0, 0, G_OPTION_ARG_NONE, &dry_run, N_("Don't save any data permanently (implies --no-registration)"), NULL }, { "disable-plugins", 0, 0, G_OPTION_ARG_NONE, &disable_plugins, N_("Disable loading of plugins"), NULL }, { "rhythmdb-file", 0, 0, G_OPTION_ARG_STRING, &rhythmdb_file, N_("Path for database file to use"), NULL }, { "playlists-file", 0, 0, G_OPTION_ARG_STRING, &playlists_file, N_("Path for playlists file to use"), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &quit, N_("Quit Rhythmbox"), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, N_("[URI...]") }, { NULL } }; g_thread_init (NULL); rb_profile_start ("starting rhythmbox"); autostarted = (g_getenv ("DESKTOP_AUTOSTART_ID") != NULL); #ifdef USE_UNINSTALLED_DIRS desktop_file_path = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "rhythmbox.desktop", NULL); g_setenv ("GSETTINGS_SCHEMA_DIR", SHARE_UNINSTALLED_BUILDDIR, TRUE); #else desktop_file_path = g_build_filename (DATADIR, "applications", "rhythmbox.desktop", NULL); #endif egg_set_desktop_file (desktop_file_path); g_free (desktop_file_path); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); rb_profile_start ("initializing gstreamer"); g_option_context_add_group (context, gst_init_get_option_group ()); rb_profile_end ("initializing gstreamer"); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); setlocale (LC_ALL, NULL); rb_profile_start ("parsing command line options"); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); g_option_context_free (context); exit (1); } g_option_context_free (context); rb_profile_end ("parsing command line options"); g_random_set_seed (time (0)); #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); /* ask for utf-8 message text from GStreamer too, * since it doesn't do that itself. */ bind_textdomain_codeset ("gstreamer-0.10", "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!debug && debug_match) rb_debug_init_match (debug_match); else rb_debug_init (debug); rb_debug ("initializing Rhythmbox %s", VERSION); #if defined(USE_UNINSTALLED_DIRS) g_irepository_prepend_search_path (SHARE_UNINSTALLED_BUILDDIR "/../bindings/gi"); #endif /* TODO: kill this function */ rb_threads_init (); gdk_threads_enter (); activated = FALSE; rb_debug ("going to create DBus object"); dbus_g_thread_init (); session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (session_bus == NULL) { g_warning ("couldn't connect to session bus: %s", (error) ? error->message : "(null)"); g_clear_error (&error); } else if (!no_registration) { guint request_name_reply; int flags; #ifndef DBUS_NAME_FLAG_DO_NOT_QUEUE flags = DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT; #else flags = DBUS_NAME_FLAG_DO_NOT_QUEUE; #endif DBusGProxy *bus_proxy; bus_proxy = dbus_g_proxy_new_for_name (session_bus, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus"); if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error, G_TYPE_STRING, "org.gnome.Rhythmbox", G_TYPE_UINT, flags, G_TYPE_INVALID, G_TYPE_UINT, &request_name_reply, G_TYPE_INVALID)) { g_warning ("Failed to invoke RequestName: %s", error->message); } g_object_unref (bus_proxy); if (request_name_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER || request_name_reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) activated = FALSE; else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_EXISTS || request_name_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) activated = TRUE; else { g_warning ("Got unhandled reply %u from RequestName", request_name_reply); activated = FALSE; } } if (!activated) { if (quit) { rb_debug ("was asked to quit, but no instance was running"); gdk_notify_startup_complete (); exit (0); } #ifdef WITH_RHYTHMDB_GDA gda_init (PACKAGE, VERSION, argc, argv); #endif rb_refstring_system_init (); #ifdef USE_UNINSTALLED_DIRS rb_file_helpers_init (TRUE); #else rb_file_helpers_init (FALSE); #endif /* XXX not sure what to do with this. should we move it to * the config dir, or leave it where it is? */ accel_map_file = g_build_filename (g_get_home_dir (), ".gnome2", "accels", "rhythmbox", NULL); gtk_accel_map_load (accel_map_file); rb_debug ("Going to create a new shell"); rb_stock_icons_init (); g_setenv ("PULSE_PROP_media.role", "music", TRUE); rb_shell = rb_shell_new (no_registration, no_update, dry_run, autostarted, disable_plugins, rhythmdb_file, playlists_file); g_object_weak_ref (G_OBJECT (rb_shell), main_shell_weak_ref_cb, NULL); if (!no_registration && session_bus != NULL) { dbus_g_object_type_install_info (RB_TYPE_SHELL, &dbus_glib_rb_shell_object_info); dbus_g_connection_register_g_object (session_bus, "/org/gnome/Rhythmbox/Shell", G_OBJECT (rb_shell)); g_signal_connect (G_OBJECT (rb_shell), "database-load-complete", G_CALLBACK (database_load_complete), NULL); } } else if (!no_registration && session_bus != NULL) { DBusGProxy *shell_proxy; guint32 current_time; current_time = gdk_x11_display_get_user_time (gdk_display_get_default ()); shell_proxy = dbus_g_proxy_new_for_name_owner (session_bus, "org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell", "org.gnome.Rhythmbox.Shell", &error); if (!shell_proxy) { g_warning ("Couldn't create proxy for Rhythmbox shell: %s", error->message); } else { if (quit) { dbus_g_proxy_call_no_reply (shell_proxy, "quit", G_TYPE_INVALID); } else { load_uri_args ((const char **) remaining_args, (GFunc) dbus_load_uri, shell_proxy); dbus_g_proxy_call_no_reply (shell_proxy, "present", G_TYPE_UINT, current_time, G_TYPE_INVALID); } g_object_unref (G_OBJECT (shell_proxy)); } } if (activated) { gdk_notify_startup_complete (); } else { rb_profile_start ("mainloop"); #ifdef ENABLE_PYTHON if (rb_python_init_successful ()) { pyg_begin_allow_threads; gtk_main (); pyg_end_allow_threads; } else { gtk_main (); } #else gtk_main (); #endif rb_profile_end ("mainloop"); rb_debug ("out of toplevel loop"); rb_file_helpers_shutdown (); rb_stock_icons_shutdown (); rb_refstring_system_shutdown (); } gst_deinit (); rb_debug ("THE END"); rb_profile_end ("starting rhythmbox"); if (accel_map_file != NULL) { gtk_accel_map_save (accel_map_file); } gdk_threads_leave (); exit (0); }
int main (int argc, char **argv) { GOptionContext *context; gboolean ok; GError *error = NULL; DBusGConnection *bus; DBusGProxy *shell_proxy = NULL; DBusGProxy *player_proxy = NULL; gboolean is_playing; #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif /* setup */ setlocale (LC_ALL, ""); g_type_init (); g_set_prgname ("rhythmbox-client"); /* parse arguments */ context = g_option_context_new (NULL); g_option_context_add_main_entries (context, args, NULL); ok = g_option_context_parse (context, &argc, &argv, &error); if (annoy (&error)) exit (1); rb_debug_init (debug); /* get dbus connection and proxy for rhythmbox shell */ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (annoy (&error)) exit (1); if (!create_rb_shell_proxies (bus, &shell_proxy, &player_proxy, &error)) { annoy (&error); exit (1); } g_clear_error (&error); /* 1. activate or quit */ if (quit) { if (shell_proxy) { rb_debug ("quitting existing instance"); dbus_g_proxy_call_no_reply (shell_proxy, "quit", G_TYPE_INVALID); } else { rb_debug ("no existing instance to quit"); } exit (0); } if (shell_proxy == NULL) { DBusGProxy *bus_proxy; guint start_service_reply; if (no_start) { rb_debug ("no existing instance, and can't start one"); exit (0); } rb_debug ("starting new instance"); bus_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus"); if (!dbus_g_proxy_call (bus_proxy, "StartServiceByName", &error, G_TYPE_STRING, "org.gnome.Rhythmbox", G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &start_service_reply, G_TYPE_INVALID)) { g_warning ("%s", error->message); exit (1); } /* hopefully we can get a proxy for the rb shell now.. */ if (!create_rb_shell_proxies (bus, &shell_proxy, &player_proxy, &error)) { annoy (&error); exit (1); } g_clear_error (&error); } /* don't present if we're doing something else */ if (next || previous || clear_queue || play_uri || other_stuff || play || pause || play_pause || stop || print_playing || print_playing_format || notify || (set_volume > -0.01) || volume_up || volume_down || print_volume || mute || unmute) no_present = TRUE; /* 2. present or hide */ if (hide || !no_present) { DBusGProxy *properties_proxy; GValue value = {0,}; rb_debug ("setting visibility property"); g_value_init (&value, G_TYPE_BOOLEAN); g_value_set_boolean (&value, !hide); properties_proxy = dbus_g_proxy_new_from_proxy (shell_proxy, "org.freedesktop.DBus.Properties", "/org/gnome/Rhythmbox/Shell"); dbus_g_proxy_call_no_reply (properties_proxy, "Set", G_TYPE_STRING, "org.gnome.Rhythmbox.Shell", G_TYPE_STRING, "visibility", G_TYPE_VALUE, &value, G_TYPE_INVALID); g_object_unref (G_OBJECT (properties_proxy)); } /* 3. skip to next or previous track */ if (next) { rb_debug ("next track"); org_gnome_Rhythmbox_Player_next (player_proxy, &error); annoy (&error); } else if (previous) { rb_debug ("previous track"); org_gnome_Rhythmbox_Player_previous (player_proxy, &error); annoy (&error); } /* 4. add/enqueue */ if (clear_queue) { org_gnome_Rhythmbox_Shell_clear_queue (shell_proxy, &error); annoy (&error); } if (other_stuff) { int i; for (i = 0; other_stuff[i] != NULL; i++) { GFile *file; char *fileuri; file = g_file_new_for_commandline_arg (other_stuff[i]); fileuri = g_file_get_uri (file); if (fileuri == NULL) { g_warning ("couldn't convert \"%s\" to a URI", other_stuff[i]); continue; } if (enqueue) { rb_debug ("enqueueing %s", fileuri); org_gnome_Rhythmbox_Shell_add_to_queue (shell_proxy, fileuri, &error); } else { rb_debug ("importing %s", fileuri); org_gnome_Rhythmbox_Shell_load_ur_i (shell_proxy, fileuri, FALSE, &error); } annoy (&error); g_free (fileuri); g_object_unref (file); } } /* play uri */ if (play_uri) { GFile *file; char *fileuri; file = g_file_new_for_commandline_arg (play_uri); fileuri = g_file_get_uri (file); if (fileuri == NULL) { g_warning ("couldn't convert \"%s\" to a URI", play_uri); } else { rb_debug ("loading and playing %s", fileuri); org_gnome_Rhythmbox_Shell_load_ur_i (shell_proxy, fileuri, TRUE, &error); annoy (&error); } g_free (fileuri); g_object_unref (file); } /* 5. play/pause/stop */ org_gnome_Rhythmbox_Player_get_playing (player_proxy, &is_playing, &error); if (!annoy (&error)) { rb_debug ("playback state: %d", is_playing); if (play || pause || play_pause) { if (is_playing != play || play_pause) { rb_debug ("calling playPause to change playback state"); org_gnome_Rhythmbox_Player_play_pause (player_proxy, FALSE, &error); annoy (&error); } else { rb_debug ("no need to change playback state"); } } else if (stop) { g_warning ("not implemented yet"); } } /* 6. get/set volume, mute/unmute */ if (set_volume > -0.01) { org_gnome_Rhythmbox_Player_set_volume (player_proxy, set_volume, &error); annoy (&error); } else if (volume_up || volume_down) { org_gnome_Rhythmbox_Player_set_volume_relative (player_proxy, volume_up ? 0.1 : -0.1, &error); annoy (&error); } else if (unmute || mute) { org_gnome_Rhythmbox_Player_set_mute (player_proxy, unmute ? FALSE : TRUE, &error); annoy (&error); } if (print_volume) { gboolean mute = FALSE; gdouble volume = 1.0; org_gnome_Rhythmbox_Player_get_mute (player_proxy, &mute, &error); annoy (&error); org_gnome_Rhythmbox_Player_get_volume (player_proxy, &volume, &error); annoy (&error); if (mute) g_print (_("Playback is muted.\n")); g_print (_("Playback volume is %f.\n"), volume); } /* 7. print playing song */ if (print_playing_format) { print_playing_song (shell_proxy, player_proxy, print_playing_format); } else if (print_playing) { print_playing_song_default (shell_proxy, player_proxy); } /* 8. display notification about playing song */ if (notify) { rb_debug ("show notification"); org_gnome_Rhythmbox_Shell_notify (shell_proxy, TRUE, &error); annoy (&error); } g_object_unref (shell_proxy); g_object_unref (player_proxy); g_option_context_free (context); return 0; }
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; }
int main (int argc, char **argv) { GOptionContext *context; GError *error = NULL; GDBusConnection *bus; GDBusProxy *mpris; GDBusProxy *queue; GApplication *app; gboolean loaded; gboolean scanned; GVariant *state; #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif /* setup */ setlocale (LC_ALL, ""); g_type_init (); g_set_prgname ("rhythmbox-client"); /* parse arguments */ context = g_option_context_new (NULL); g_option_context_add_main_entries (context, args, NULL); g_option_context_parse (context, &argc, &argv, &error); if (annoy (&error)) exit (1); rb_debug_init (debug); app = g_application_new ("org.gnome.Rhythmbox3", G_APPLICATION_IS_LAUNCHER); if (g_application_register (app, NULL, &error) == FALSE) { if (check_running) { rb_debug ("no running instance found"); exit (2); } else if (quit) { rb_debug ("no existing instance to quit"); exit (0); } rb_debug ("uh.. what?"); exit (0); } /* are we just checking if it's running? */ if (check_running) { rb_debug ("running instance found"); exit (0); } /* wait until it's ready to accept control */ state = g_action_group_get_action_state (G_ACTION_GROUP (app), "LoadURI"); if (state == NULL) { rb_debug ("couldn't get app startup state"); exit (0); } bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); g_variant_get (state, "(bb)", &loaded, &scanned); if ((loaded && scanned) == FALSE) { GMainLoop *loop; GDBusProxy *app_proxy; rb_debug ("waiting for app startup"); loop = g_main_loop_new (NULL, FALSE); g_signal_connect (app, "action-state-changed", G_CALLBACK (state_changed_cb), loop); /* dbus implementation of GApplication doesn't do action state updates yet */ app_proxy = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, "org.gnome.Rhythmbox3", "/org/gnome/Rhythmbox3", "org.gtk.Actions", NULL, &error); if (app_proxy == NULL || proxy_has_name_owner (app_proxy) == FALSE) { g_warning ("unable to wait for app startup: %s", error->message); g_clear_error (&error); } else { g_object_set_data (G_OBJECT (app_proxy), "actual-app", app); g_signal_connect (app_proxy, "g-signal", G_CALLBACK (state_changed_signal_cb), loop); g_main_loop_run (loop); rb_debug ("app is now started enough"); } } /* create proxies */ mpris = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, "org.mpris.MediaPlayer2.rhythmbox", "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", NULL, &error); if (mpris == NULL || proxy_has_name_owner (mpris) == FALSE) { g_warning ("MPRIS D-Bus interface not available, some things won't work"); if (next || previous || (seek != 0) || play || do_pause || play_pause || stop || volume_up || volume_down || (set_volume > -0.01)) { exit (1); } } queue = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, "org.gnome.Rhythmbox3", "/org/gnome/Rhythmbox3/PlayQueue", "org.gnome.Rhythmbox3.PlayQueue", NULL, &error); if (queue == NULL || proxy_has_name_owner (queue) == FALSE) { g_warning ("Play queue interface not available, some things won't work"); if (enqueue || clear_queue) { exit (1); } } /* activate or quit */ if (quit) { rb_debug ("quitting existing instance"); g_action_group_activate_action (G_ACTION_GROUP (app), "Quit", NULL); exit (0); } /* don't present if we're doing something else */ if (next || previous || (seek != 0) || clear_queue || play_uri || other_stuff || play || do_pause || play_pause || stop || toggle_shuffle || print_playing || print_playing_format || (set_volume > -0.01) || volume_up || volume_down || print_volume /*|| mute || unmute*/ || (set_rating > -0.01)) no_present = TRUE; /* present */ if (!no_present) { g_application_activate (app); } /* set song rating */ if (set_rating >= 0.0 && set_rating <= 5.0) { rb_debug ("rate song"); rate_song (mpris, set_rating); } if (toggle_shuffle) { rb_debug("toggle shuffle"); g_action_group_activate_action (G_ACTION_GROUP (app), "ToggleShuffle", NULL); annoy(&error); } /* skip to next or previous track */ if (next) { rb_debug ("next track"); g_dbus_proxy_call_sync (mpris, "Next", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); } else if (previous) { rb_debug ("previous track"); g_dbus_proxy_call_sync (mpris, "Previous", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); } /* seek in track */ if (seek != 0) { GHashTable *properties; rb_debug ("seek"); properties = get_playing_song_info (mpris); if (properties != NULL) { GVariant *v = g_hash_table_lookup (properties, "mpris:trackid"); if (v != NULL) { g_dbus_proxy_call_sync (mpris, "SetPosition", g_variant_new ("(ox)", g_variant_get_string (v, NULL), seek), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); } } } /* add/enqueue */ if (clear_queue) { g_dbus_proxy_call_sync (queue, "ClearQueue", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); } if (other_stuff) { int i; for (i = 0; other_stuff[i] != NULL; i++) { GFile *file; char *fileuri; file = g_file_new_for_commandline_arg (other_stuff[i]); fileuri = g_file_get_uri (file); if (fileuri == NULL) { g_warning ("couldn't convert \"%s\" to a URI", other_stuff[i]); continue; } if (enqueue) { rb_debug ("enqueueing %s", fileuri); g_dbus_proxy_call_sync (queue, "AddToQueue", g_variant_new ("(s)", fileuri), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); } else { rb_debug ("importing %s", fileuri); g_action_group_activate_action (G_ACTION_GROUP (app), "LoadURI", g_variant_new ("(sb)", fileuri, FALSE)); } g_free (fileuri); g_object_unref (file); } } /* select/activate/play source */ if (select_source) { rb_debug ("selecting source %s", select_source); g_action_group_activate_action (G_ACTION_GROUP (app), "ActivateSource", g_variant_new ("(su)", select_source, 0)); } else if (activate_source) { rb_debug ("activating source %s", activate_source); g_action_group_activate_action (G_ACTION_GROUP (app), "ActivateSource", g_variant_new ("(su)", activate_source, 1)); } else if (play_source) { rb_debug ("playing source %s", play_source); g_action_group_activate_action (G_ACTION_GROUP (app), "ActivateSource", g_variant_new ("(su)", play_source, 2)); } /* play uri */ if (play_uri) { GFile *file; char *fileuri; file = g_file_new_for_commandline_arg (play_uri); fileuri = g_file_get_uri (file); if (fileuri == NULL) { g_warning ("couldn't convert \"%s\" to a URI", play_uri); } else { rb_debug ("loading and playing %s", fileuri); g_action_group_activate_action (G_ACTION_GROUP (app), "LoadURI", g_variant_new ("(sb)", fileuri, TRUE)); annoy (&error); } g_free (fileuri); g_object_unref (file); } /* play/pause/stop */ if (mpris) { GVariant *v; gboolean is_playing = FALSE; v = g_dbus_proxy_get_cached_property (mpris, "PlaybackStatus"); if (v != NULL) { is_playing = (g_strcmp0 (g_variant_get_string (v, NULL), "Playing") == 0); g_variant_unref (v); } if (play || do_pause || play_pause) { if (is_playing != play || play_pause) { rb_debug ("calling PlayPause to change playback state"); g_dbus_proxy_call_sync (mpris, "PlayPause", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); } else { rb_debug ("no need to change playback state"); } } else if (stop) { g_warning ("not implemented yet"); } } /* get/set volume, mute/unmute */ if (set_volume > -0.01) { g_dbus_proxy_call_sync (mpris, "org.freedesktop.DBus.Properties.Set", g_variant_new ("(ssv)", "org.mpris.MediaPlayer2.Player", "Volume", g_variant_new_double (set_volume)), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); } else if (volume_up || volume_down) { GVariant *v; v = g_dbus_proxy_get_cached_property (mpris, "Volume"); if (v != NULL) { set_volume = g_variant_get_double (v) + (volume_up ? 0.1 : -0.1); g_dbus_proxy_call_sync (mpris, "org.freedesktop.DBus.Properties.Set", g_variant_new ("(ssv)", "org.mpris.MediaPlayer2.Player", "Volume", g_variant_new_double (set_volume)), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); annoy (&error); g_variant_unref (v); } } /* no mute for now? */ /* } else if (unmute || mute) { org_gnome_Rhythmbox_Player_set_mute (player_proxy, unmute ? FALSE : TRUE, &error); annoy (&error); } */ if (print_volume) { gdouble volume = 1.0; GVariant *v = g_dbus_proxy_get_cached_property (mpris, "Volume"); if (v != NULL) { volume = g_variant_get_double (v); g_variant_unref (v); } g_print (_("Playback volume is %f.\n"), volume); } /* print playing song */ if (print_playing_format) { print_playing_song (mpris, print_playing_format); } else if (print_playing) { print_playing_song_default (mpris); } if (mpris) { g_object_unref (mpris); } g_dbus_connection_flush_sync (bus, NULL, NULL); g_option_context_free (context); return 0; }
int main (int argc, char **argv) { RhythmDB *db; RhythmDBEntry *entry, *entry2, *entry3, *entry4; GtkTreeModel *main_model; GtkTreeIter iter; guint testnum = 1; query_func qfunc; gtk_init (&argc, &argv); gdk_threads_init (); rb_thread_helpers_init (); rb_debug_init (TRUE); GDK_THREADS_ENTER (); qfunc = rhythmdb_do_full_query; begin: db = rhythmdb_tree_new ("test"); /* * TEST 1: Entry creation with album */ g_print ("Test %d\n", testnum); rhythmdb_write_lock (db); entry = create_entry (db, "file:///sin.mp3", "Sin", "Pretty Hate Machine", "Nine Inch Nails", "Rock"); rhythmdb_write_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 2: Do a query for all songs, verify our single song is in it */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); qfunc (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, RHYTHMDB_ENTRY_TYPE_IGNORE, RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); /* We should only have one entry. */ g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 3: Do a query for songs named "Sin" */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Sin", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); /* We should only have one entry. */ g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 4: Do a query for songs named "Cow", should be empty */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Cow", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (!gtk_tree_model_get_iter_first (main_model, &iter)); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 5 * Do a query for songs named "Cow" and "Sin", should be empty. */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Cow", RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Sin", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (!gtk_tree_model_get_iter_first (main_model, &iter)); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 6 * Do a query for songs named "Cow" or "Sin", should have our song. */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Cow", RHYTHMDB_QUERY_DISJUNCTION, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Sin", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); /* We should only have one entry. */ g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 7 * Do a query for songs with Genre "Rock", should have our song. */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_GENRE, "Rock", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); /* We should only have one entry. */ g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 8 * Do a query for songs with Genre "Nine Inch Nails", * should be empty. */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_GENRE, "Nine Inch Nails", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (!gtk_tree_model_get_iter_first (main_model, &iter)); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 9 * Do a query for songs with album "Pretty Hate Machine", * should have our song. */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_ALBUM, "Pretty Hate Machine", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); /* We should only have one entry. */ g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; /* * TEST 10 * Do a query for songs with artist "Nine Inch Nails", * should have our song. */ g_print ("Test %d\n", testnum); rhythmdb_read_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_ARTIST, "Nine Inch Nails", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); /* We should only have one entry. */ g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); DESTROY_MODELS (); rhythmdb_read_unlock (db); g_print ("Test %d\n", testnum); testnum++; g_print ("Test %d\n", testnum); rhythmdb_write_lock (db); entry2 = create_entry (db, "file:///head like a hole.mp3", "Head Like A Hole", "Pretty Hate Machine", "Nine Inch Nails", "Rock"); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_ARTIST, "Nine Inch Nails", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); g_assert (gtk_tree_model_iter_next (main_model, &iter)); g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); VERIFY_MAIN_MODEL (entry2); DESTROY_MODELS (); rhythmdb_write_unlock (db); g_print ("Test %d\n", testnum); testnum++; g_print ("Test %d\n", testnum); rhythmdb_write_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_ALBUM, "Pretty Hate Machine", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); g_assert (gtk_tree_model_iter_next (main_model, &iter)); g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); VERIFY_MAIN_MODEL (entry2); DESTROY_MODELS (); rhythmdb_write_unlock (db); g_print ("Test %d\n", testnum); testnum++; g_print ("Test %d\n", testnum); rhythmdb_write_lock (db); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_GENRE, "Rock", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); g_assert (gtk_tree_model_iter_next (main_model, &iter)); g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); VERIFY_MAIN_MODEL (entry2); DESTROY_MODELS (); rhythmdb_write_unlock (db); g_print ("Test %d\n", testnum); g_print ("Test %d\n", testnum); rhythmdb_write_lock (db); entry3 = create_entry (db, "file:///angel.ogg", "Angel", "Mezzanine", "Massive Attack", "Electronica"); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_GENRE, "Electronica", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Mezzanine", "Massive Attack", "Electronica"); VERIFY_MAIN_MODEL (entry3); DESTROY_MODELS (); rhythmdb_write_unlock (db); g_print ("Test %d\n", testnum); testnum++; g_print ("Test %d\n", testnum); rhythmdb_write_lock (db); entry4 = create_entry (db, "file:///killa bees.ogg", "Killa Bees", "Armageddon", "Usual Suspects", "Drum N' Bass"); main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db)); rhythmdb_do_full_query (db, main_model, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Angel", RHYTHMDB_QUERY_DISJUNCTION, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Sin", RHYTHMDB_QUERY_DISJUNCTION, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Head Like A Hole", RHYTHMDB_QUERY_DISJUNCTION, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TITLE, "Killa Bees", RHYTHMDB_QUERY_END); wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model)); g_assert (gtk_tree_model_get_iter_first (main_model, &iter)); g_assert (gtk_tree_model_iter_next (main_model, &iter)); g_assert (gtk_tree_model_iter_next (main_model, &iter)); g_assert (gtk_tree_model_iter_next (main_model, &iter)); g_assert (!gtk_tree_model_iter_next (main_model, &iter)); VERIFY_META_MODELS ("Mezzanine", "Massive Attack", "Electronica"); VERIFY_META_MODELS ("Armageddon", "Usual Suspects", "Drum N' Bass"); VERIFY_META_MODELS ("Pretty Hate Machine", "Nine Inch Nails", "Rock"); VERIFY_MAIN_MODEL (entry); VERIFY_MAIN_MODEL (entry2); VERIFY_MAIN_MODEL (entry3); VERIFY_MAIN_MODEL (entry4); DESTROY_MODELS (); rhythmdb_write_unlock (db); g_print ("Test %d\n", testnum); testnum++; if (qfunc == rhythmdb_do_full_query) { rhythmdb_shutdown (db); g_object_unref (G_OBJECT (db)); qfunc = rhythmdb_do_full_query_async; goto begin; } /* * THE END */ rhythmdb_shutdown (db); g_object_unref (G_OBJECT (db)); GDK_THREADS_LEAVE (); exit (0); }
int main (int argc, char **argv) { ServiceData svc = {0,}; DBusError dbus_error = {0,}; const char *address = NULL; #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 (); /* set up D-BUS server */ svc.server = dbus_server_listen (address, &dbus_error); if (!svc.server) { rb_debug ("D-BUS server init failed: %s", dbus_error.message); return -1; } dbus_server_set_new_connection_function (svc.server, _new_connection, (gpointer) &svc, NULL); /* write the server address back to the parent process */ { char *addr; addr = dbus_server_get_address (svc.server); rb_debug ("D-BUS server listening on address %s", addr); printf ("%s\n", addr); fflush (stdout); free (addr); } /* run main loop until we get bored */ svc.loop = g_main_loop_new (NULL, TRUE); dbus_server_setup_with_g_main (svc.server, g_main_loop_get_context (svc.loop)); if (!svc.external) g_timeout_add_seconds (ATTENTION_SPAN / 2, (GSourceFunc) electromagnetic_shotgun, &svc); g_main_loop_run (svc.loop); if (svc.connection) { dbus_connection_close (svc.connection); dbus_connection_unref (svc.connection); } g_object_unref (svc.metadata); g_main_loop_unref (svc.loop); dbus_server_disconnect (svc.server); dbus_server_unref (svc.server); gst_deinit (); return 0; }