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; 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; }