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; }
gboolean rb_plugins_engine_init (RBShell *shell) { g_return_val_if_fail (rb_plugins == NULL, FALSE); if (!g_module_supported ()) { g_warning ("rb is not able to initialize the plugins engine."); return FALSE; } rb_profile_start ("plugins engine init"); rb_plugins = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)rb_plugin_info_free); rb_plugins_shell = shell; g_object_ref (G_OBJECT (rb_plugins_shell)); #ifdef ENABLE_PYTHON rb_python_module_init_python (); #endif rb_plugins_engine_load_all (); garbage_collect_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 20, garbage_collect_cb, NULL, NULL); rb_profile_end ("plugins engine init"); return TRUE; }
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; 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) { int ret; SRunner *sr; Suite *s; g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); /* init stuff */ rb_profile_start ("rhythmbox test suite"); rb_threads_init (); rb_debug_init (TRUE); rb_refstring_system_init (); rb_file_helpers_init (TRUE); /* setup tests */ s = rhythmdb_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 ("rhythmbox test suite"); return ret; }
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); }
static void impl_activate (PeasActivatable *bplugin) { RBMtpPlugin *plugin = RB_MTP_PLUGIN (bplugin); GtkUIManager *uimanager = NULL; RBRemovableMediaManager *rmm; char *file = NULL; RBShell *shell; #if defined(HAVE_GUDEV) gboolean rmm_scanned = FALSE; #else int num_mtp_devices; LIBMTP_raw_device_t *mtp_devices; #endif g_object_get (plugin, "object", &shell, NULL); g_object_get (shell, "ui-manager", &uimanager, "removable-media-manager", &rmm, NULL); /* ui */ rb_media_player_source_init_actions (shell); plugin->action_group = gtk_action_group_new ("MTPActions"); gtk_action_group_set_translation_domain (plugin->action_group, GETTEXT_PACKAGE); _rb_action_group_add_display_page_actions (plugin->action_group, G_OBJECT (shell), rb_mtp_plugin_actions, G_N_ELEMENTS (rb_mtp_plugin_actions)); gtk_ui_manager_insert_action_group (uimanager, plugin->action_group, 0); file = rb_find_plugin_data_file (G_OBJECT (bplugin), "mtp-ui.xml"); plugin->ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager, file, NULL); g_object_unref (uimanager); g_object_unref (shell); /* device detection */ #if defined(HAVE_GUDEV) plugin->create_device_source_id = g_signal_connect_object (rmm, "create-source-device", G_CALLBACK (create_source_device_cb), plugin, 0); /* only scan if we're being loaded after the initial scan has been done */ g_object_get (rmm, "scanned", &rmm_scanned, NULL); if (rmm_scanned) rb_removable_media_manager_scan (rmm); #else if (rb_mtp_plugin_setup_dbus_hal_connection (plugin) == FALSE) { rb_debug ("not scanning for MTP devices because we couldn't get a HAL context"); g_object_unref (rmm); return; } rb_profile_start ("scanning for MTP devices"); LIBMTP_Detect_Raw_Devices (&mtp_devices, &num_mtp_devices); if (num_mtp_devices > 0) { int num_hal_devices; char **hal_devices; int i; rb_debug ("%d MTP devices found", num_mtp_devices); hal_devices = libhal_get_all_devices (plugin->hal_context, &num_hal_devices, NULL); for (i = 0; i < num_hal_devices; i++) { /* should narrow this down a bit - usb only, for a start */ rb_mtp_plugin_maybe_add_source (plugin, hal_devices[i], mtp_devices, num_mtp_devices); } libhal_free_string_array (hal_devices); } if (mtp_devices != NULL) { free (mtp_devices); } rb_profile_end ("scanning for MTP devices"); #endif g_object_unref (rmm); }