static void
impl_dispose (GObject *object)
{
	RBAndroidSourcePrivate *priv = GET_PRIVATE (object);

	if (priv->db != NULL) {
		if (priv->ignore_type != NULL) {
			rhythmdb_entry_delete_by_type (priv->db, priv->ignore_type);
			g_clear_object (&priv->ignore_type);
		}
		if (priv->error_type != NULL) {
			rhythmdb_entry_delete_by_type (priv->db, priv->error_type);
			g_clear_object (&priv->error_type);
		}

		g_clear_object (&priv->db);
	}

	if (priv->import_job != NULL) {
		rhythmdb_import_job_cancel (priv->import_job);
		g_clear_object (&priv->import_job);
	}

	g_clear_object (&priv->device_info);
	g_clear_object (&priv->mount);
	g_clear_object (&priv->gudev_device);

	G_OBJECT_CLASS (rb_android_source_parent_class)->dispose (object);
}
static void
impl_dispose (GObject *object)
{
	RBGenericPlayerSourcePrivate *priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (object);

	if (priv->load_playlists_id != 0) {
		g_source_remove (priv->load_playlists_id);
		priv->load_playlists_id = 0;
	}

	if (priv->db != NULL) {
		if (priv->ignore_type != RHYTHMDB_ENTRY_TYPE_INVALID) {
			rhythmdb_entry_delete_by_type (priv->db, priv->ignore_type);
			g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, priv->ignore_type);
			priv->ignore_type = RHYTHMDB_ENTRY_TYPE_INVALID;
		}
		if (priv->error_type != RHYTHMDB_ENTRY_TYPE_INVALID) {
			rhythmdb_entry_delete_by_type (priv->db, priv->error_type);
			g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, priv->error_type);
			priv->error_type = RHYTHMDB_ENTRY_TYPE_INVALID;
		}

		g_object_unref (priv->db);
		priv->db = NULL;
	}

	if (priv->import_job != NULL) {
		rhythmdb_import_job_cancel (priv->import_job);
		g_object_unref (priv->import_job);
		priv->import_job = NULL;
	}

	G_OBJECT_CLASS (rb_generic_player_source_parent_class)->dispose (object);
}
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;
}
static void
impl_dispose (GObject *object)
{
	RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (object);

	if (priv->load_playlists_id != 0) {
		g_source_remove (priv->load_playlists_id);
		priv->load_playlists_id = 0;
	}

	if (priv->db != NULL) {
		if (priv->ignore_type != NULL) {
			rhythmdb_entry_delete_by_type (priv->db, priv->ignore_type);
			g_object_unref (priv->ignore_type);
			priv->ignore_type = NULL;
		}
		if (priv->error_type != NULL) {
			rhythmdb_entry_delete_by_type (priv->db, priv->error_type);
			g_object_unref (priv->error_type);
			priv->error_type = NULL;
		}

		g_object_unref (priv->db);
		priv->db = NULL;
	}

	if (priv->import_job != NULL) {
		rhythmdb_import_job_cancel (priv->import_job);
		g_object_unref (priv->import_job);
		priv->import_job = NULL;
	}

	if (priv->device_info != NULL) {
		g_object_unref (priv->device_info);
		priv->device_info = NULL;
	}

	if (priv->mount != NULL) {
		g_object_unref (priv->mount);
		priv->mount = NULL;
	}

	rb_application_remove_plugin_menu_item (RB_APPLICATION (g_application_get_default ()),
						"display-page-add-playlist",
						priv->new_playlist_action_name);

	G_OBJECT_CLASS (rb_generic_player_source_parent_class)->dispose (object);
}
Exemple #5
0
static void
feed_selection_changed_cb (GtkTreeSelection *selection, RBPodcastAddDialog *dialog)
{
	GtkTreeModel *model;

	if (dialog->priv->clearing)
		return;

	dialog->priv->have_selection =
		gtk_tree_selection_get_selected (selection, &model, &dialog->priv->selected_feed);
	gtk_widget_set_sensitive (dialog->priv->subscribe_button, dialog->priv->have_selection);

	rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH);
	rhythmdb_commit (dialog->priv->db);

	if (dialog->priv->have_selection) {
		RBPodcastChannel *channel = NULL;

		gtk_tree_model_get (model,
				    &dialog->priv->selected_feed,
				    FEED_COLUMN_PARSED_FEED, &channel,
				    -1);

		if (channel->posts == NULL) {
			rb_debug ("parsing feed %s to get posts", channel->url);
			parse_in_thread (dialog, channel->url, TRUE, FALSE);
		} else {
			add_posts_for_feed (dialog, channel);
		}
	}
}
static void
impl_dispose (GObject *object)
{
	RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (object);

	if (priv->load_playlists_id != 0) {
		g_source_remove (priv->load_playlists_id);
		priv->load_playlists_id = 0;
	}

	if (priv->db != NULL) {
		if (priv->ignore_type != NULL) {
			rhythmdb_entry_delete_by_type (priv->db, priv->ignore_type);
			g_object_unref (priv->ignore_type);
			priv->ignore_type = NULL;
		}
		if (priv->error_type != NULL) {
			rhythmdb_entry_delete_by_type (priv->db, priv->error_type);
			g_object_unref (priv->error_type);
			priv->error_type = NULL;
		}

		g_object_unref (priv->db);
		priv->db = NULL;
	}

	if (priv->import_job != NULL) {
		rhythmdb_import_job_cancel (priv->import_job);
		g_object_unref (priv->import_job);
		priv->import_job = NULL;
	}

	if (priv->device_info != NULL) {
		g_object_unref (priv->device_info);
		priv->device_info = NULL;
	}

	if (priv->mount != NULL) {
		g_object_unref (priv->mount);
		priv->mount = NULL;
	}

	G_OBJECT_CLASS (rb_generic_player_source_parent_class)->dispose (object);
}
static void
start_scanning (RBImportDialog *dialog)
{
	RBTaskList *tasklist;

	rhythmdb_entry_delete_by_type (dialog->priv->db, dialog->priv->entry_type);
	rhythmdb_entry_delete_by_type (dialog->priv->db, dialog->priv->ignore_type);
	rhythmdb_commit (dialog->priv->db);

	rb_debug ("starting %s", dialog->priv->current_uri);
	dialog->priv->import_job = rhythmdb_import_job_new (dialog->priv->db,
							    dialog->priv->entry_type,
							    dialog->priv->ignore_type,
							    dialog->priv->ignore_type);
	g_object_set (dialog->priv->import_job, "task-label", _("Importing tracks"), NULL);
	g_signal_connect (dialog->priv->import_job, "complete", G_CALLBACK (import_complete_cb), dialog);
	rhythmdb_import_job_add_uri (dialog->priv->import_job, dialog->priv->current_uri);
	rhythmdb_import_job_start (dialog->priv->import_job);

	g_object_get (dialog->priv->shell, "task-list", &tasklist, NULL);
	rb_task_list_add_task (tasklist, RB_TASK_PROGRESS (dialog->priv->import_job));
	g_object_unref (tasklist);
}
Exemple #8
0
void
rb_podcast_add_dialog_reset (RBPodcastAddDialog *dialog, const char *text, gboolean load)
{
	dialog->priv->reset_count++;
	remove_all_feeds (dialog);
	rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH);
	rhythmdb_commit (dialog->priv->db);

	rb_search_entry_set_text (dialog->priv->search_entry, text);

	if (load) {
		search_cb (dialog->priv->search_entry, text, dialog);
	} else {
		rb_search_entry_grab_focus (dialog->priv->search_entry);
	}
}
Exemple #9
0
static void
search_cb (RBSearchEntry *entry, const char *text, RBPodcastAddDialog *dialog)
{
	GList *searches;
	GList *s;
	int i;

	/* remove previous feeds */
	remove_all_feeds (dialog);
	rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH);
	rhythmdb_commit (dialog->priv->db);

	gtk_widget_hide (dialog->priv->info_bar);

	if (text == NULL || text[0] == '\0') {
		return;
	}

	/* if the entered text looks like a feed URL, parse it directly */
	for (i = 0; i < G_N_ELEMENTS (podcast_uri_prefixes); i++) {
		if (g_str_has_prefix (text, podcast_uri_prefixes[i])) {
			parse_in_thread (dialog, text, FALSE, TRUE);
			return;
		}
	}

	/* not really sure about this one */
	if (g_path_is_absolute (text)) {
		parse_in_thread (dialog, text, FALSE, TRUE);
		return;
	}

	/* otherwise, try podcast searches */
	dialog->priv->search_successful = FALSE;
	searches = rb_podcast_manager_get_searches (dialog->priv->podcast_mgr);
	for (s = searches; s != NULL; s = s->next) {
		RBPodcastSearch *search = s->data;

		g_signal_connect_object (search, "result", G_CALLBACK (podcast_search_result_cb), dialog, 0);
		g_signal_connect_object (search, "finished", G_CALLBACK (podcast_search_finished_cb), dialog, 0);
		rb_podcast_search_start (search, text, PODCAST_SEARCH_LIMIT);
		dialog->priv->running_searches++;
	}
}
static void
impl_delete_thyself (RBDisplayPage *page)
{
	RhythmDB *db;
	RBShell *shell;
	RhythmDBEntryType *entry_type;

	g_object_get (page, "shell", &shell, NULL);
	g_object_get (shell, "db", &db, NULL);
	g_object_unref (shell);

	g_object_get (page, "entry-type", &entry_type, NULL);
	rb_debug ("deleting all entries of type '%s'", rhythmdb_entry_type_get_name (entry_type));
	rhythmdb_entry_delete_by_type (db, entry_type);
	g_object_unref (entry_type);

	rhythmdb_commit (db);
	g_object_unref (db);
}
Exemple #11
0
static void
rb_mtp_source_dispose (GObject *object)
{
	RBMtpSource *source = RB_MTP_SOURCE (object);
	RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
	RhythmDBEntryType *entry_type;
	RhythmDB *db;

	if (priv->device_thread != NULL) {
		g_object_unref (priv->device_thread);
		priv->device_thread = NULL;
	}

#if defined(HAVE_GUDEV)
	if (priv->remount_volume != NULL) {
		rb_debug ("remounting gvfs volume for mtp device");
		/* the callback will unref remount_volume */
		g_volume_mount (priv->remount_volume,
				G_MOUNT_MOUNT_NONE,
				NULL,
				NULL,
				remount_done_cb,
				NULL);
		priv->remount_volume = NULL;
	}
#endif
	if (priv->art_store != NULL) {
		g_object_unref (priv->art_store);
		priv->art_store = NULL;
	}

	db = get_db_for_source (source);

	g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
	rhythmdb_entry_delete_by_type (db, entry_type);
	g_object_unref (entry_type);

	rhythmdb_commit (db);
	g_object_unref (db);

	G_OBJECT_CLASS (rb_mtp_source_parent_class)->dispose (object);
}
static void
impl_delete_thyself (RBSource *source)
{
	RhythmDB *db;
	RhythmDBEntryType entry_type;

	rb_debug ("audio cd ejected");

	/* cancel the loading of metadata */
	rb_audiocd_load_metadata_cancel (RB_AUDIOCD_SOURCE (source));

	db = get_db_for_source (RB_AUDIOCD_SOURCE (source));

	g_object_get (source, "entry-type", &entry_type, NULL);
	rhythmdb_entry_delete_by_type (db, entry_type);
	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);

	rhythmdb_commit (db);
	g_object_unref (db);
}
Exemple #13
0
static void
subscribe_selected_feed (RBPodcastAddDialog *dialog)
{
	RBPodcastChannel *channel;

	g_assert (dialog->priv->have_selection);

	rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH);
	rhythmdb_commit (dialog->priv->db);

	/* subscribe selected feed */
	gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->feed_model),
			    &dialog->priv->selected_feed,
			    FEED_COLUMN_PARSED_FEED, &channel,
			    -1);
	if (channel->posts != NULL) {
		rb_podcast_manager_add_parsed_feed (dialog->priv->podcast_mgr, channel);
	} else {
		rb_podcast_manager_subscribe_feed (dialog->priv->podcast_mgr, channel->url, TRUE);
	}
}
static void
impl_delete_thyself (RBDisplayPage *page)
{
	RBGriloSource *source = RB_GRILO_SOURCE (page);
	RhythmDBEntryType *entry_type;

	if (source->priv->browse_op != 0) {
		grl_operation_cancel (source->priv->browse_op);
		source->priv->browse_op = 0;
	}

	if (source->priv->media_browse_op != 0) {
		grl_operation_cancel (source->priv->media_browse_op);
		source->priv->media_browse_op = 0;
	}

	g_object_get (source, "entry-type", &entry_type, NULL);
	rhythmdb_entry_delete_by_type (source->priv->db, entry_type);
	g_object_unref (entry_type);

	rhythmdb_commit (source->priv->db);
}
static void
rb_mtp_source_dispose (GObject *object)
{
	RBMtpSource *source = RB_MTP_SOURCE (object);
	RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source);
	RhythmDBEntryType entry_type;
	RhythmDB *db;

	db = get_db_for_source (source);

	g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
	rhythmdb_entry_delete_by_type (db, entry_type);
	g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);

	rhythmdb_commit (db);
	g_object_unref (db);

	if (priv->load_songs_idle_id != 0) {
		g_source_remove (priv->load_songs_idle_id);
		priv->load_songs_idle_id = 0;
	}

	G_OBJECT_CLASS (rb_mtp_source_parent_class)->dispose (object);
}
static void
current_folder_changed_cb (GtkFileChooser *chooser, RBImportDialog *dialog)
{
	GSettings *settings;
	RBSource *source;
	GtkWidget *label;
	const char *uri;
	char **locations;
	int i;
	
	uri = gtk_file_chooser_get_uri (chooser);
	if (g_strcmp0 (uri, dialog->priv->current_uri) == 0)
		return;
	g_free (dialog->priv->current_uri);
	dialog->priv->current_uri = g_strdup (uri);

	if (dialog->priv->import_job != NULL) {
		rhythmdb_import_job_cancel (dialog->priv->import_job);
	}

	clear_info_bar (dialog);

	source = rb_shell_guess_source_for_uri (dialog->priv->shell, uri);
	if (source != NULL) {
		if (RB_IS_DEVICE_SOURCE (source)) {
			char *msg;
			char *name;
			GtkWidget *content;

			rhythmdb_entry_delete_by_type (dialog->priv->db, dialog->priv->entry_type);
			rhythmdb_entry_delete_by_type (dialog->priv->db, dialog->priv->ignore_type);
			rhythmdb_commit (dialog->priv->db);

			dialog->priv->info_bar = gtk_info_bar_new ();
			g_object_set (dialog->priv->info_bar, "hexpand", TRUE, NULL);

			g_object_get (source, "name", &name, NULL);

			/* this isn't a terribly helpful message. */
			msg = g_strdup_printf (_("The location you have selected is on the device %s."), name);
			label = gtk_label_new (msg);
			g_free (msg);
			content = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->priv->info_bar));
			gtk_container_add (GTK_CONTAINER (content), label);

			msg = g_strdup_printf (_("Show %s"), name);
			gtk_info_bar_add_button (GTK_INFO_BAR (dialog->priv->info_bar), msg, GTK_RESPONSE_ACCEPT);
			g_free (msg);

			g_signal_connect (dialog->priv->info_bar, "response", G_CALLBACK (device_info_bar_response_cb), dialog);

			gtk_widget_show_all (dialog->priv->info_bar);
			gtk_container_add (GTK_CONTAINER (dialog->priv->info_bar_container), dialog->priv->info_bar);
			return;
		}
	}

	/* disable copy if the selected location is already inside the library */
	settings = g_settings_new ("org.gnome.rhythmbox.rhythmdb");
	locations = g_settings_get_strv (settings, "locations");
	gtk_widget_set_sensitive (dialog->priv->copy_check, TRUE);
	for (i = 0; locations[i] != NULL; i++) {
		if (g_str_has_prefix (uri, locations[i])) {
			gtk_widget_set_sensitive (dialog->priv->copy_check, FALSE);
			break;
		}
	}
	g_strfreev (locations);
	g_object_unref (settings);

	if (dialog->priv->import_job != NULL) {
		/* wait for the previous job to finish up */
		rb_debug ("need to wait for previous import job to finish");
		g_signal_connect (dialog->priv->import_job, "complete", G_CALLBACK (start_deferred_scan), dialog);
	} else {
		start_scanning (dialog);
	}
}