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); }
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; }
static void load_songs (RBGenericPlayerSource *source) { RBGenericPlayerSourcePrivate *priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (source); RhythmDBEntryType entry_type; char **audio_folders; char *mount_path; 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_signal_connect_object (priv->import_job, "complete", G_CALLBACK (import_complete_cb), source, 0); g_signal_connect_object (priv->import_job, "status-changed", G_CALLBACK (import_status_changed_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_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type); g_free (mount_path); }
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); }