コード例 #1
0
static void
hide_import_job (RBImportDialog *dialog)
{
	if (dialog->priv->import_job) {
		RBTaskList *tasklist;
		g_object_get (dialog->priv->shell, "task-list", &tasklist, NULL);
		rb_task_list_remove_task (tasklist, RB_TASK_PROGRESS (dialog->priv->import_job));
		g_object_unref (tasklist);
	}
}
コード例 #2
0
static void
load_songs (RBGenericPlayerSource *source)
{
	RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source);
	RhythmDBEntryType *entry_type;
	char **audio_folders;
	char *mount_path;
	RBShell *shell;
	RBTaskList *tasklist;
	char *name;
	char *label;

	mount_path = rb_generic_player_source_get_mount_path (source);
	g_object_get (source, "entry-type", &entry_type, NULL);

	/* if we have a set of folders on the device containing audio files,
	 * load only those folders, otherwise add the whole volume.
	 */
	priv->import_job = rhythmdb_import_job_new (priv->db, entry_type, priv->ignore_type, priv->error_type);
	g_object_get (source, "name", &name, NULL);
	label = g_strdup_printf (_("Scanning %s"), name);
	g_object_set (priv->import_job, "task-label", label, NULL);
	g_free (label);
	g_free (name);

	g_signal_connect_object (priv->import_job, "complete", G_CALLBACK (import_complete_cb), source, 0);

	g_object_get (priv->device_info, "audio-folders", &audio_folders, NULL);
	if (audio_folders != NULL && g_strv_length (audio_folders) > 0) {
		int af;
		for (af=0; audio_folders[af] != NULL; af++) {
			char *path;
			path = rb_uri_append_path (mount_path, audio_folders[af]);
			rb_debug ("loading songs from device audio folder %s", path);
			rhythmdb_import_job_add_uri (priv->import_job, path);
			g_free (path);
		}
	} else {
		rb_debug ("loading songs from device mount path %s", mount_path);
		rhythmdb_import_job_add_uri (priv->import_job, mount_path);
	}
	g_strfreev (audio_folders);

	rhythmdb_import_job_start (priv->import_job);

	g_object_get (source, "shell", &shell, NULL);
	g_object_get (shell, "task-list", &tasklist, NULL);
	rb_task_list_add_task (tasklist, RB_TASK_PROGRESS (priv->import_job));
	g_object_unref (tasklist);
	g_object_unref (shell);

	g_object_unref (entry_type);
	g_free (mount_path);
}
コード例 #3
0
static gboolean
ensure_loaded (RBAndroidSource *source)
{
	RBAndroidSourcePrivate *priv = GET_PRIVATE (source);
	RBSourceLoadStatus status;
	RhythmDBEntryType *entry_type;
	GMount *mount;
	GFile *root;
	RBTaskList *tasklist;
	RBShell *shell;
	char *name;
	char *label;

	if (priv->loaded) {
		g_object_get (source, "load-status", &status, NULL);
		return (status == RB_SOURCE_LOAD_STATUS_LOADED);
	}

	priv->loaded = TRUE;
	rb_media_player_source_load (RB_MEDIA_PLAYER_SOURCE (source));

	/* identify storage containers and find music dirs within them */
	g_object_get (source, "mount", &mount, "entry-type", &entry_type, NULL);
	root = g_mount_get_root (mount);
	g_object_unref (mount);

	priv->cancel = g_cancellable_new ();
	priv->import_job = rhythmdb_import_job_new (priv->db, entry_type, priv->ignore_type, priv->error_type);
	g_signal_connect_object (priv->import_job, "complete", G_CALLBACK (import_complete_cb), source, 0);

	priv->scanned = 0;
	g_queue_init (&priv->to_scan);
	g_queue_push_tail (&priv->to_scan, root);
	g_object_unref (entry_type);

	find_music_dirs (RB_ANDROID_SOURCE (source));

	g_object_get (source, "name", &name, "shell", &shell, NULL);
	label = g_strdup_printf (_("Scanning %s"), name);
	g_object_set (priv->import_job, "task-label", label, NULL);

	g_object_get (shell, "task-list", &tasklist, NULL);
	rb_task_list_add_task (tasklist, RB_TASK_PROGRESS (priv->import_job));
	g_object_unref (tasklist);
	g_object_unref (shell);

	g_free (label);
	g_free (name);
	return FALSE;
}
コード例 #4
0
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);
}
コード例 #5
0
/**
 * rb_transfer_target_transfer:
 * @target: an #RBTransferTarget
 * @entries: (element-type RB.RhythmDBEntry): a #GList of entries to transfer
 * @defer: if %TRUE, don't start the transfer until
 *
 * Starts tranferring @entries to the target.  This returns the
 * #RBTrackTransferBatch that it starts, so the caller can track
 * the progress of the transfer, or NULL if the target doesn't
 * want any of the entries.
 *
 * Return value: (transfer full): an #RBTrackTransferBatch, or NULL
 */
RBTrackTransferBatch *
rb_transfer_target_transfer (RBTransferTarget *target, GList *entries, gboolean defer)
{
	RBTrackTransferQueue *xferq;
	RBTaskList *tasklist;
	RBShell *shell;
	GList *l;
	RhythmDBEntryType *our_entry_type;
	RBTrackTransferBatch *batch;
	gboolean start_batch = FALSE;

	g_object_get (target,
		      "shell", &shell,
		      "entry-type", &our_entry_type,
		      NULL);
	g_object_get (shell,
		      "track-transfer-queue", &xferq,
		      "task-list", &tasklist,
		      NULL);
	g_object_unref (shell);

	batch = g_object_steal_data (G_OBJECT (target), "transfer-target-batch");

	if (batch == NULL) {
		batch = rb_track_transfer_batch_new (NULL, NULL, G_OBJECT (target));

		g_signal_connect_object (batch, "get-dest-uri", G_CALLBACK (get_dest_uri_cb), target, 0);
		g_signal_connect_object (batch, "track-done", G_CALLBACK (track_done_cb), target, 0);
	} else {
		start_batch = TRUE;
	}

	for (l = entries; l != NULL; l = l->next) {
		RhythmDBEntry *entry;
		RhythmDBEntryType *entry_type;
		const char *location;

		entry = (RhythmDBEntry *)l->data;
		location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
		entry_type = rhythmdb_entry_get_entry_type (entry);

		if (entry_type != our_entry_type) {
			if (rb_transfer_target_should_transfer (target, entry)) {
				rb_debug ("pasting entry %s", location);
				rb_track_transfer_batch_add (batch, entry);
				start_batch = TRUE;
			} else {
				rb_debug ("target doesn't want entry %s", location);
			}
		} else {
			rb_debug ("can't copy entry %s from the target to itself", location);
		}
	}
	g_object_unref (our_entry_type);

	if (start_batch) {
		if (defer) {
			g_object_set_data_full (G_OBJECT (target), "transfer-target-batch", g_object_ref (batch), g_object_unref);
		} else {
			GstEncodingTarget *encoding_target;
			char *name;
			char *label;

			g_object_get (target, "encoding-target", &encoding_target, NULL);
			g_object_set (batch, "encoding-target", encoding_target, NULL);
			gst_encoding_target_unref (encoding_target);

			g_object_get (target, "name", &name, NULL);
			label = g_strdup_printf (_("Transferring tracks to %s"), name);
			g_object_set (batch, "task-label", label, NULL);
			g_free (name);
			g_free (label);
			
			rb_task_list_add_task (tasklist, RB_TASK_PROGRESS (batch));

			rb_track_transfer_queue_start_batch (xferq, batch);
		}
	} else {
		g_object_unref (batch);
		batch = NULL;
	}
	g_object_unref (xferq);
	g_object_unref (tasklist);
	return batch;
}