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 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); }
static void enum_files_cb (GObject *obj, GAsyncResult *result, gpointer data) { RBAndroidSource *source = RB_ANDROID_SOURCE (data); RBAndroidSourcePrivate *priv = GET_PRIVATE(source); GFileEnumerator *e = G_FILE_ENUMERATOR (obj); GError *error = NULL; GFileInfo *info; GList *files; GList *l; files = g_file_enumerator_next_files_finish (e, result, &error); if (error != NULL) { rb_debug ("error listing files: %s", error->message); music_dirs_done (source); return; } if (files == NULL) { priv->scanned++; g_object_unref (e); find_music_dirs (source); return; } for (l = files; l != NULL; l = l->next) { guint32 filetype; info = (GFileInfo *)l->data; filetype = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE); if (filetype == G_FILE_TYPE_DIRECTORY) { GFile *dir; if (priv->scanned == 0) { rb_debug ("got storage container %s", g_file_info_get_name (info)); dir = g_file_get_child (g_file_enumerator_get_container (e), g_file_info_get_name (info)); g_queue_push_tail (&priv->to_scan, dir); } else if (g_ascii_strcasecmp (g_file_info_get_name (info), "music") == 0) { GFile *storage; char *uri; storage = g_file_enumerator_get_container (e); dir = g_file_get_child (storage, g_file_info_get_name (info)); uri = g_file_get_uri (dir); rb_debug ("music dir found at %s", uri); /* keep the container around for space/capacity calculation */ priv->storage = g_list_append (priv->storage, dir); rhythmdb_import_job_add_uri (priv->import_job, uri); g_free (uri); } } g_object_unref (info); } g_list_free (files); g_file_enumerator_next_files_async (G_FILE_ENUMERATOR (obj), 64, G_PRIORITY_DEFAULT, priv->cancel, enum_files_cb, source); }