GList * append_mobj_list_from_unknown_filename(GList *list, gchar *filename) { PraghaMusicobject *mobj; PraghaMediaType file_type; if (is_dir_and_accessible(filename)) { list = append_mobj_list_from_folder (list, filename); } else { file_type = pragha_file_get_media_type (filename); switch (file_type) { case MEDIA_TYPE_AUDIO: mobj = new_musicobject_from_file (filename); if (G_LIKELY(mobj)) { list = g_list_append(list, mobj); add_recent_file(filename); } break; case MEDIA_TYPE_PLAYLIST: list = pragha_pl_parser_append_mobj_list_by_extension (list, filename); break; case MEDIA_TYPE_IMAGE: case MEDIA_TYPE_UNKNOWN: default: break; } } /* Have to give control to GTK periodically ... */ pragha_process_gtk_events (); return list; }
static void dbus_add_file(DBusMessage *msg, struct con_win *cwin) { gchar *file; DBusError error; struct musicobject *mobj = NULL; dbus_error_init(&error); dbus_message_get_args(msg, &error, DBUS_TYPE_STRING, &file, DBUS_TYPE_INVALID); if (dbus_error_is_set(&error)) { g_critical("Unable to get file name out of add file signal"); dbus_error_free(&error); return; } gdk_threads_enter(); if (is_dir_and_accessible(file, cwin)) { if(cwin->cpref->add_recursively_files) __recur_add(file, cwin); else __non_recur_add(file, TRUE, cwin); } else if (is_playable_file(file)) { mobj = new_musicobject_from_file(file); if (mobj) append_current_playlist(mobj, cwin); CDEBUG(DBG_INFO, "Add file from command line: %s", file); } else { g_warning("Unable to add %s", file); } gdk_threads_leave(); }
GList * append_mobj_list_from_folder(GList *list, gchar *dir_name) { PraghaPreferences *preferences; PraghaMusicobject *mobj = NULL; PraghaMediaType file_type; GDir *dir; const gchar *next_file = NULL; gchar *ab_file; GError *error = NULL; dir = g_dir_open(dir_name, 0, &error); if (!dir) { g_critical("Unable to open library : %s", dir_name); return list; } next_file = g_dir_read_name(dir); while (next_file) { ab_file = g_strconcat(dir_name, G_DIR_SEPARATOR_S, next_file, NULL); if (is_dir_and_accessible(ab_file)) { preferences = pragha_preferences_get(); if(pragha_preferences_get_add_recursively(preferences)) list = append_mobj_list_from_folder(list, ab_file); g_object_unref(G_OBJECT(preferences)); } else { file_type = pragha_file_get_media_type (ab_file); switch (file_type) { case MEDIA_TYPE_AUDIO: mobj = new_musicobject_from_file (ab_file); if (G_LIKELY(mobj)) list = g_list_append(list, mobj); break; case MEDIA_TYPE_PLAYLIST: list = pragha_pl_parser_append_mobj_list_by_extension (list, ab_file); break; case MEDIA_TYPE_IMAGE: case MEDIA_TYPE_UNKNOWN: default: break; } } /* Have to give control to GTK periodically ... */ pragha_process_gtk_events (); g_free(ab_file); next_file = g_dir_read_name(dir); } g_dir_close(dir); return list; }
GList * append_mobj_list_from_folder(GList *list, gchar *dir_name) { PraghaPreferences *preferences; PraghaMusicobject *mobj = NULL; GDir *dir; const gchar *next_file = NULL; gchar *ab_file; GError *error = NULL; dir = g_dir_open(dir_name, 0, &error); if (!dir) { g_critical("Unable to open library : %s", dir_name); return list; } next_file = g_dir_read_name(dir); while (next_file) { ab_file = g_strconcat(dir_name, G_DIR_SEPARATOR_S, next_file, NULL); if (is_dir_and_accessible(ab_file)) { preferences = pragha_preferences_get(); if(pragha_preferences_get_add_recursively(preferences)) list = append_mobj_list_from_folder(list, ab_file); g_object_unref(G_OBJECT(preferences)); } else { if (is_playable_file(ab_file)) { mobj = new_musicobject_from_file(ab_file); if (G_LIKELY(mobj)) list = g_list_append(list, mobj); } } /* Have to give control to GTK periodically ... */ pragha_process_gtk_events (); g_free(ab_file); next_file = g_dir_read_name(dir); } g_dir_close(dir); return list; }