Mercurial > audlegacy
comparison src/audacious/playlist.c @ 2579:364714f2d555 trunk
[svn] - urldecode playlist paths
author | nenolod |
---|---|
date | Mon, 26 Feb 2007 01:14:48 -0800 |
parents | 9713b5a67cba |
children | 48288757d7c7 |
comparison
equal
deleted
inserted
replaced
2578:33911de063cb | 2579:364714f2d555 |
---|---|
877 playlist_add_url(Playlist * playlist, const gchar * url) | 877 playlist_add_url(Playlist * playlist, const gchar * url) |
878 { | 878 { |
879 return playlist_ins_url(playlist, url, -1); | 879 return playlist_ins_url(playlist, url, -1); |
880 } | 880 } |
881 | 881 |
882 static gchar * | |
883 _playlist_urldecode_basic_path(const gchar * encoded_path) | |
884 { | |
885 const gchar *cur, *ext; | |
886 gchar *path, *tmp; | |
887 gint realchar; | |
888 | |
889 if (!encoded_path) | |
890 return NULL; | |
891 | |
892 if (!str_has_prefix_nocase(encoded_path, "file:")) | |
893 return NULL; | |
894 | |
895 cur = encoded_path + 5; | |
896 | |
897 if (str_has_prefix_nocase(cur, "//localhost")) | |
898 cur += 11; | |
899 | |
900 if (*cur == '/') | |
901 while (cur[1] == '/') | |
902 cur++; | |
903 | |
904 tmp = g_malloc0(strlen(cur) + 1); | |
905 | |
906 while ((ext = strchr(cur, '%')) != NULL) { | |
907 strncat(tmp, cur, ext - cur); | |
908 ext++; | |
909 cur = ext + 2; | |
910 if (!sscanf(ext, "%2x", &realchar)) { | |
911 /* Assume it is a literal '%'. Several file | |
912 * managers send unencoded file: urls on drag | |
913 * and drop. */ | |
914 realchar = '%'; | |
915 cur -= 2; | |
916 } | |
917 tmp[strlen(tmp)] = realchar; | |
918 } | |
919 | |
920 path = g_strconcat(tmp, cur, NULL); | |
921 g_free(tmp); | |
922 return path; | |
923 } | |
924 | |
882 guint | 925 guint |
883 playlist_ins_dir(Playlist * playlist, const gchar * path, | 926 playlist_ins_dir(Playlist * playlist, const gchar * path, |
884 gint pos, | 927 gint pos, |
885 gboolean background) | 928 gboolean background) |
886 { | 929 { |
887 guint entries = 0; | 930 guint entries = 0; |
888 GList *list, *node; | 931 GList *list, *node; |
889 GHashTable *htab; | 932 GHashTable *htab; |
933 gchar *path2 = _playlist_urldecode_basic_path(path); | |
890 | 934 |
891 htab = g_hash_table_new(devino_hash, devino_compare); | 935 htab = g_hash_table_new(devino_hash, devino_compare); |
892 | 936 |
893 list = playlist_dir_find_files(path, background, htab); | 937 list = playlist_dir_find_files(path2, background, htab); |
894 list = g_list_sort(list, (GCompareFunc) path_compare); | 938 list = g_list_sort(list, (GCompareFunc) path_compare); |
895 | 939 |
896 g_hash_table_foreach_remove(htab, devino_destroy, NULL); | 940 g_hash_table_foreach_remove(htab, devino_destroy, NULL); |
897 | 941 |
898 for (node = list; node; node = g_list_next(node)) { | 942 for (node = list; node; node = g_list_next(node)) { |
902 if (pos >= 0) | 946 if (pos >= 0) |
903 pos++; | 947 pos++; |
904 } | 948 } |
905 | 949 |
906 g_list_free(list); | 950 g_list_free(list); |
951 g_free(path2); | |
907 | 952 |
908 playlist_recalc_total_time(playlist); | 953 playlist_recalc_total_time(playlist); |
909 playlist_generate_shuffle_list(playlist); | 954 playlist_generate_shuffle_list(playlist); |
910 playlistwin_update_list(playlist); | 955 playlistwin_update_list(playlist); |
911 playlist_manager_update(); | 956 playlist_manager_update(); |