static gboolean load_uri_args (const char **args, GFunc handler, gpointer user_data) { gboolean handled; guint i; handled = FALSE; for (i = 0; args && args[i]; i++) { GFile *file; char *uri; rb_debug ("examining argument %s", args[i]); file = g_file_new_for_commandline_arg (args[i]); uri = g_file_get_uri (file); /* * rb_uri_exists won't work if the location isn't mounted. * however, things that are interesting to mount are generally * non-local, so we'll process them anyway. */ if (rb_uri_is_local (uri) == FALSE || rb_uri_exists (uri)) { handler (uri, user_data); } g_free (uri); g_object_unref (file); handled = TRUE; } return handled; }
static void default_load_playlists (RBGenericPlayerSource *source) { RBGenericPlayerSourcePrivate *priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (source); char *mount_path; char *playlist_path; char *full_playlist_path; char **playlist_formats; mount_path = rb_generic_player_source_get_mount_path (source); g_object_get (priv->device_info, "playlist-path", &playlist_path, NULL); if (playlist_path) { /* If the device only supports a single playlist, just load that */ if (g_str_has_suffix (playlist_path, ".m3u") || g_str_has_suffix (playlist_path, ".pls")) { full_playlist_path = rb_uri_append_path (mount_path, playlist_path); if (rb_uri_exists (full_playlist_path)) { load_playlist_file (source, full_playlist_path, playlist_path); } g_free (full_playlist_path); g_free (playlist_path); return; } /* Otherwise, limit the search to the device's playlist folder */ if (g_str_has_suffix (playlist_path, "/%File")) { playlist_path[strlen (playlist_path) - strlen("/%File")] = '\0'; } full_playlist_path = rb_uri_append_path (mount_path, playlist_path); rb_debug ("constructed playlist search path %s", full_playlist_path); } else { full_playlist_path = g_strdup (mount_path); } /* only try to load playlists if the device has at least one playlist format */ g_object_get (priv->device_info, "playlist-formats", &playlist_formats, NULL); if (playlist_formats != NULL && g_strv_length (playlist_formats) > 0) { rb_debug ("searching for playlists in %s", playlist_path); rb_uri_handle_recursively (full_playlist_path, NULL, (RBUriRecurseFunc) visit_playlist_dirs, source); } g_strfreev (playlist_formats); g_free (playlist_path); g_free (full_playlist_path); g_free (mount_path); }
static void default_load_playlists (RBGenericPlayerSource *source) { RBGenericPlayerSourcePrivate *priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (source); char *mount_path; char *playlist_path = NULL; mount_path = rb_generic_player_source_get_mount_path (source); if (priv->playlist_path) { /* If the device only supports a single playlist, just load that */ if (g_str_has_suffix (priv->playlist_path, ".m3u") || g_str_has_suffix (priv->playlist_path, ".pls")) { char *playlist_path = rb_uri_append_path (mount_path, priv->playlist_path); if (rb_uri_exists (playlist_path)) { load_playlist_file (source, playlist_path, priv->playlist_path); } return; } /* Otherwise, limit the search to the device's playlist folder. * The optional trailing '/%File' is stripped in set_playlist_path */ playlist_path = rb_uri_append_path (mount_path, priv->playlist_path); rb_debug ("constructed playlist search path %s", playlist_path); } rb_uri_handle_recursively (playlist_path ? playlist_path : mount_path, NULL, (RBUriRecurseFunc) visit_playlist_dirs, source); g_free (playlist_path); g_free (mount_path); }