Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5cc33382
Commit
5cc33382
authored
Aug 14, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v0.17.x'
Conflicts: src/mapper.h
parents
3047bdf6
1ae89728
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
104 additions
and
76 deletions
+104
-76
NEWS
NEWS
+1
-0
command.c
src/command.c
+1
-1
inotify_update.c
src/inotify_update.c
+2
-2
input_stream.h
src/input_stream.h
+0
-4
main.c
src/main.c
+0
-2
mapper.c
src/mapper.c
+57
-32
mapper.h
src/mapper.h
+13
-2
lastfm_playlist_plugin.c
src/playlist/lastfm_playlist_plugin.c
+0
-2
playlist_song.c
src/playlist_song.c
+30
-31
No files found.
NEWS
View file @
5cc33382
...
@@ -4,6 +4,7 @@ ver 0.18 (2012/??/??)
...
@@ -4,6 +4,7 @@ ver 0.18 (2012/??/??)
ver 0.17.2 (2012/??/??)
ver 0.17.2 (2012/??/??)
* protocol:
* protocol:
- fix crash in local file check
- fix crash in local file check
* mapper: fix non-UTF8 music directory name
ver 0.17.1 (2012/07/31)
ver 0.17.1 (2012/07/31)
...
...
src/command.c
View file @
5cc33382
...
@@ -1183,7 +1183,7 @@ handle_config(struct client *client,
...
@@ -1183,7 +1183,7 @@ handle_config(struct client *client,
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
const
char
*
path
=
mapper_get_music_directory
();
const
char
*
path
=
mapper_get_music_directory
_utf8
();
if
(
path
!=
NULL
)
if
(
path
!=
NULL
)
client_printf
(
client
,
"music_directory: %s
\n
"
,
path
);
client_printf
(
client
,
"music_directory: %s
\n
"
,
path
);
...
...
src/inotify_update.c
View file @
5cc33382
...
@@ -266,7 +266,7 @@ mpd_inotify_callback(int wd, unsigned mask,
...
@@ -266,7 +266,7 @@ mpd_inotify_callback(int wd, unsigned mask,
(
mask
&
IN_ISDIR
)
!=
0
)
{
(
mask
&
IN_ISDIR
)
!=
0
)
{
/* a sub directory was changed: register those in
/* a sub directory was changed: register those in
inotify */
inotify */
const
char
*
root
=
mapper_get_music_directory
();
const
char
*
root
=
mapper_get_music_directory
_fs
();
const
char
*
path_fs
;
const
char
*
path_fs
;
char
*
allocated
=
NULL
;
char
*
allocated
=
NULL
;
...
@@ -308,7 +308,7 @@ mpd_inotify_init(unsigned max_depth)
...
@@ -308,7 +308,7 @@ mpd_inotify_init(unsigned max_depth)
g_debug
(
"initializing inotify"
);
g_debug
(
"initializing inotify"
);
const
char
*
path
=
mapper_get_music_directory
();
const
char
*
path
=
mapper_get_music_directory
_fs
();
if
(
path
==
NULL
)
{
if
(
path
==
NULL
)
{
g_debug
(
"no music directory configured"
);
g_debug
(
"no music directory configured"
);
return
;
return
;
...
...
src/input_stream.h
View file @
5cc33382
...
@@ -29,10 +29,6 @@
...
@@ -29,10 +29,6 @@
#include <stdbool.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/types.h>
#if !GLIB_CHECK_VERSION(2,14,0)
typedef
gint64
goffset
;
#endif
struct
input_stream
{
struct
input_stream
{
/**
/**
* the plugin which implements this input stream
* the plugin which implements this input stream
...
...
src/main.c
View file @
5cc33382
...
@@ -133,10 +133,8 @@ glue_mapper_init(GError **error_r)
...
@@ -133,10 +133,8 @@ glue_mapper_init(GError **error_r)
return
false
;
return
false
;
}
}
#if GLIB_CHECK_VERSION(2,14,0)
if
(
music_dir
==
NULL
)
if
(
music_dir
==
NULL
)
music_dir
=
g_strdup
(
g_get_user_special_dir
(
G_USER_DIRECTORY_MUSIC
));
music_dir
=
g_strdup
(
g_get_user_special_dir
(
G_USER_DIRECTORY_MUSIC
));
#endif
mapper_init
(
music_dir
,
playlist_dir
);
mapper_init
(
music_dir
,
playlist_dir
);
...
...
src/mapper.c
View file @
5cc33382
...
@@ -36,10 +36,24 @@
...
@@ -36,10 +36,24 @@
#include <errno.h>
#include <errno.h>
#include <dirent.h>
#include <dirent.h>
static
char
*
music_dir
;
/**
static
size_t
music_dir_length
;
* The absolute path of the music directory encoded in UTF-8.
*/
static
char
*
music_dir_utf8
;
static
size_t
music_dir_utf8_length
;
static
char
*
playlist_dir
;
/**
* The absolute path of the music directory encoded in the filesystem
* character set.
*/
static
char
*
music_dir_fs
;
static
size_t
music_dir_fs_length
;
/**
* The absolute path of the playlist directory encoded in the
* filesystem character set.
*/
static
char
*
playlist_dir_fs
;
/**
/**
* Duplicate a string, chop all trailing slashes.
* Duplicate a string, chop all trailing slashes.
...
@@ -86,20 +100,21 @@ check_directory(const char *path)
...
@@ -86,20 +100,21 @@ check_directory(const char *path)
}
}
static
void
static
void
mapper_set_music_dir
(
const
char
*
path
)
mapper_set_music_dir
(
const
char
*
path
_utf8
)
{
{
check_directory
(
path
);
music_dir_utf8
=
strdup_chop_slash
(
path_utf8
);
music_dir_utf8_length
=
strlen
(
music_dir_utf8
);
music_dir
=
strdup_chop_slash
(
path
);
music_dir_fs
=
utf8_to_fs_charset
(
music_dir_utf8
);
music_dir_length
=
strlen
(
music_dir
);
check_directory
(
music_dir_fs
);
music_dir_fs_length
=
strlen
(
music_dir_fs
);
}
}
static
void
static
void
mapper_set_playlist_dir
(
const
char
*
path
)
mapper_set_playlist_dir
(
const
char
*
path
_utf8
)
{
{
check_directory
(
path
);
playlist_dir_fs
=
utf8_to_fs_charset
(
path_utf8
);
check_directory
(
playlist_dir_fs
);
playlist_dir
=
g_strdup
(
path
);
}
}
void
mapper_init
(
const
char
*
_music_dir
,
const
char
*
_playlist_dir
)
void
mapper_init
(
const
char
*
_music_dir
,
const
char
*
_playlist_dir
)
...
@@ -113,23 +128,31 @@ void mapper_init(const char *_music_dir, const char *_playlist_dir)
...
@@ -113,23 +128,31 @@ void mapper_init(const char *_music_dir, const char *_playlist_dir)
void
mapper_finish
(
void
)
void
mapper_finish
(
void
)
{
{
g_free
(
music_dir
);
g_free
(
music_dir_utf8
);
g_free
(
playlist_dir
);
g_free
(
music_dir_fs
);
g_free
(
playlist_dir_fs
);
}
}
const
char
*
const
char
*
mapper_get_music_directory
(
void
)
mapper_get_music_directory
_utf8
(
void
)
{
{
return
music_dir
;
return
music_dir_utf8
;
}
const
char
*
mapper_get_music_directory_fs
(
void
)
{
return
music_dir_fs
;
}
}
const
char
*
const
char
*
map_to_relative_path
(
const
char
*
path_utf8
)
map_to_relative_path
(
const
char
*
path_utf8
)
{
{
return
music_dir
!=
NULL
&&
return
music_dir_utf8
!=
NULL
&&
memcmp
(
path_utf8
,
music_dir
,
music_dir_length
)
==
0
&&
memcmp
(
path_utf8
,
music_dir_utf8
,
G_IS_DIR_SEPARATOR
(
path_utf8
[
music_dir_length
])
music_dir_utf8_length
)
==
0
&&
?
path_utf8
+
music_dir_length
+
1
G_IS_DIR_SEPARATOR
(
path_utf8
[
music_dir_utf8_length
])
?
path_utf8
+
music_dir_utf8_length
+
1
:
path_utf8
;
:
path_utf8
;
}
}
...
@@ -141,14 +164,14 @@ map_uri_fs(const char *uri)
...
@@ -141,14 +164,14 @@ map_uri_fs(const char *uri)
assert
(
uri
!=
NULL
);
assert
(
uri
!=
NULL
);
assert
(
*
uri
!=
'/'
);
assert
(
*
uri
!=
'/'
);
if
(
music_dir
==
NULL
)
if
(
music_dir
_fs
==
NULL
)
return
NULL
;
return
NULL
;
uri_fs
=
utf8_to_fs_charset
(
uri
);
uri_fs
=
utf8_to_fs_charset
(
uri
);
if
(
uri_fs
==
NULL
)
if
(
uri_fs
==
NULL
)
return
NULL
;
return
NULL
;
path_fs
=
g_build_filename
(
music_dir
,
uri_fs
,
NULL
);
path_fs
=
g_build_filename
(
music_dir
_fs
,
uri_fs
,
NULL
);
g_free
(
uri_fs
);
g_free
(
uri_fs
);
return
path_fs
;
return
path_fs
;
...
@@ -157,10 +180,11 @@ map_uri_fs(const char *uri)
...
@@ -157,10 +180,11 @@ map_uri_fs(const char *uri)
char
*
char
*
map_directory_fs
(
const
struct
directory
*
directory
)
map_directory_fs
(
const
struct
directory
*
directory
)
{
{
assert
(
music_dir
!=
NULL
);
assert
(
music_dir_utf8
!=
NULL
);
assert
(
music_dir_fs
!=
NULL
);
if
(
directory_is_root
(
directory
))
if
(
directory_is_root
(
directory
))
return
g_strdup
(
music_dir
);
return
g_strdup
(
music_dir
_fs
);
return
map_uri_fs
(
directory_get_path
(
directory
));
return
map_uri_fs
(
directory_get_path
(
directory
));
}
}
...
@@ -168,9 +192,10 @@ map_directory_fs(const struct directory *directory)
...
@@ -168,9 +192,10 @@ map_directory_fs(const struct directory *directory)
char
*
char
*
map_directory_child_fs
(
const
struct
directory
*
directory
,
const
char
*
name
)
map_directory_child_fs
(
const
struct
directory
*
directory
,
const
char
*
name
)
{
{
char
*
name_fs
,
*
parent_fs
,
*
path
;
assert
(
music_dir_utf8
!=
NULL
);
assert
(
music_dir_fs
!=
NULL
);
assert
(
music_dir
!=
NULL
)
;
char
*
name_fs
,
*
parent_fs
,
*
path
;
/* check for invalid or unauthorized base names */
/* check for invalid or unauthorized base names */
if
(
*
name
==
0
||
strchr
(
name
,
'/'
)
!=
NULL
||
if
(
*
name
==
0
||
strchr
(
name
,
'/'
)
!=
NULL
||
...
@@ -208,11 +233,11 @@ map_song_fs(const struct song *song)
...
@@ -208,11 +233,11 @@ map_song_fs(const struct song *song)
char
*
char
*
map_fs_to_utf8
(
const
char
*
path_fs
)
map_fs_to_utf8
(
const
char
*
path_fs
)
{
{
if
(
music_dir
!=
NULL
&&
if
(
music_dir
_fs
!=
NULL
&&
strncmp
(
path_fs
,
music_dir
,
music_dir
_length
)
==
0
&&
strncmp
(
path_fs
,
music_dir
_fs
,
music_dir_fs
_length
)
==
0
&&
G_IS_DIR_SEPARATOR
(
path_fs
[
music_dir_length
]))
G_IS_DIR_SEPARATOR
(
path_fs
[
music_dir_
fs_
length
]))
/* remove musicDir prefix */
/* remove musicDir prefix */
path_fs
+=
music_dir_length
+
1
;
path_fs
+=
music_dir_
fs_
length
+
1
;
else
if
(
G_IS_DIR_SEPARATOR
(
path_fs
[
0
]))
else
if
(
G_IS_DIR_SEPARATOR
(
path_fs
[
0
]))
/* not within musicDir */
/* not within musicDir */
return
NULL
;
return
NULL
;
...
@@ -226,7 +251,7 @@ map_fs_to_utf8(const char *path_fs)
...
@@ -226,7 +251,7 @@ map_fs_to_utf8(const char *path_fs)
const
char
*
const
char
*
map_spl_path
(
void
)
map_spl_path
(
void
)
{
{
return
playlist_dir
;
return
playlist_dir
_fs
;
}
}
char
*
char
*
...
@@ -234,7 +259,7 @@ map_spl_utf8_to_fs(const char *name)
...
@@ -234,7 +259,7 @@ map_spl_utf8_to_fs(const char *name)
{
{
char
*
filename_utf8
,
*
filename_fs
,
*
path
;
char
*
filename_utf8
,
*
filename_fs
,
*
path
;
if
(
playlist_dir
==
NULL
)
if
(
playlist_dir
_fs
==
NULL
)
return
NULL
;
return
NULL
;
filename_utf8
=
g_strconcat
(
name
,
PLAYLIST_FILE_SUFFIX
,
NULL
);
filename_utf8
=
g_strconcat
(
name
,
PLAYLIST_FILE_SUFFIX
,
NULL
);
...
@@ -243,7 +268,7 @@ map_spl_utf8_to_fs(const char *name)
...
@@ -243,7 +268,7 @@ map_spl_utf8_to_fs(const char *name)
if
(
filename_fs
==
NULL
)
if
(
filename_fs
==
NULL
)
return
NULL
;
return
NULL
;
path
=
g_build_filename
(
playlist_dir
,
filename_fs
,
NULL
);
path
=
g_build_filename
(
playlist_dir
_fs
,
filename_fs
,
NULL
);
g_free
(
filename_fs
);
g_free
(
filename_fs
);
return
path
;
return
path
;
...
...
src/mapper.h
View file @
5cc33382
...
@@ -39,9 +39,20 @@ void mapper_init(const char *_music_dir, const char *_playlist_dir);
...
@@ -39,9 +39,20 @@ void mapper_init(const char *_music_dir, const char *_playlist_dir);
void
mapper_finish
(
void
);
void
mapper_finish
(
void
);
/**
* Return the absolute path of the music directory encoded in UTF-8.
*/
gcc_const
const
char
*
mapper_get_music_directory_utf8
(
void
);
/**
* Return the absolute path of the music directory encoded in the
* filesystem character set.
*/
gcc_const
gcc_const
const
char
*
const
char
*
mapper_get_music_directory
(
void
);
mapper_get_music_directory
_fs
(
void
);
/**
/**
* Returns true if a music directory was configured.
* Returns true if a music directory was configured.
...
@@ -50,7 +61,7 @@ gcc_const
...
@@ -50,7 +61,7 @@ gcc_const
static
inline
bool
static
inline
bool
mapper_has_music_directory
(
void
)
mapper_has_music_directory
(
void
)
{
{
return
mapper_get_music_directory
()
!=
NULL
;
return
mapper_get_music_directory
_utf8
()
!=
NULL
;
}
}
/**
/**
...
...
src/playlist/lastfm_playlist_plugin.c
View file @
5cc33382
...
@@ -58,12 +58,10 @@ lastfm_init(const struct config_param *param)
...
@@ -58,12 +58,10 @@ lastfm_init(const struct config_param *param)
lastfm_config
.
user
=
g_uri_escape_string
(
user
,
NULL
,
false
);
lastfm_config
.
user
=
g_uri_escape_string
(
user
,
NULL
,
false
);
#if GLIB_CHECK_VERSION(2,16,0)
if
(
strlen
(
passwd
)
!=
32
)
if
(
strlen
(
passwd
)
!=
32
)
lastfm_config
.
md5
=
g_compute_checksum_for_string
(
G_CHECKSUM_MD5
,
lastfm_config
.
md5
=
g_compute_checksum_for_string
(
G_CHECKSUM_MD5
,
passwd
,
strlen
(
passwd
));
passwd
,
strlen
(
passwd
));
else
else
#endif
lastfm_config
.
md5
=
g_strdup
(
passwd
);
lastfm_config
.
md5
=
g_strdup
(
passwd
);
return
true
;
return
true
;
...
...
src/playlist_song.c
View file @
5cc33382
...
@@ -83,17 +83,36 @@ apply_song_metadata(struct song *dest, const struct song *src)
...
@@ -83,17 +83,36 @@ apply_song_metadata(struct song *dest, const struct song *src)
return
tmp
;
return
tmp
;
}
}
static
struct
song
*
playlist_check_load_song
(
struct
song
*
song
,
const
char
*
uri
,
bool
secure
)
{
struct
song
*
dest
;
if
(
uri_has_scheme
(
uri
))
{
dest
=
song_remote_new
(
uri
);
}
else
if
(
g_path_is_absolute
(
uri
)
&&
secure
)
{
dest
=
song_file_load
(
uri
,
NULL
);
if
(
dest
==
NULL
)
return
NULL
;
}
else
{
dest
=
db_get_song
(
uri
);
if
(
dest
==
NULL
)
/* not found in database */
return
NULL
;
}
return
apply_song_metadata
(
dest
,
song
);
}
struct
song
*
struct
song
*
playlist_check_translate_song
(
struct
song
*
song
,
const
char
*
base_uri
,
playlist_check_translate_song
(
struct
song
*
song
,
const
char
*
base_uri
,
bool
secure
)
bool
secure
)
{
{
struct
song
*
dest
;
if
(
song_in_database
(
song
))
if
(
song_in_database
(
song
))
/* already ok */
/* already ok */
return
song
;
return
song
;
char
*
uri
=
song
->
uri
;
c
onst
c
har
*
uri
=
song
->
uri
;
if
(
uri_has_scheme
(
uri
))
{
if
(
uri_has_scheme
(
uri
))
{
if
(
uri_supported_scheme
(
uri
))
if
(
uri_supported_scheme
(
uri
))
...
@@ -115,11 +134,11 @@ playlist_check_translate_song(struct song *song, const char *base_uri,
...
@@ -115,11 +134,11 @@ playlist_check_translate_song(struct song *song, const char *base_uri,
if
(
g_path_is_absolute
(
uri
))
{
if
(
g_path_is_absolute
(
uri
))
{
/* XXX fs_charset vs utf8? */
/* XXX fs_charset vs utf8? */
const
char
*
prefix
=
mapper_get_music_directory
();
const
char
*
suffix
=
map_to_relative_path
(
uri
);
assert
(
suffix
!=
NULL
);
if
(
prefix
!=
NULL
&&
g_str_has_prefix
(
uri
,
prefix
)
&&
if
(
suffix
!=
uri
)
uri
[
strlen
(
prefix
)]
==
'/'
)
uri
=
suffix
;
uri
+=
strlen
(
prefix
)
+
1
;
else
if
(
!
secure
)
{
else
if
(
!
secure
)
{
/* local files must be relative to the music
/* local files must be relative to the music
directory when "secure" is enabled */
directory when "secure" is enabled */
...
@@ -130,32 +149,12 @@ playlist_check_translate_song(struct song *song, const char *base_uri,
...
@@ -130,32 +149,12 @@ playlist_check_translate_song(struct song *song, const char *base_uri,
base_uri
=
NULL
;
base_uri
=
NULL
;
}
}
char
*
allocated
=
NULL
;
if
(
base_uri
!=
NULL
)
if
(
base_uri
!=
NULL
)
uri
=
g_build_filename
(
base_uri
,
uri
,
NULL
);
uri
=
allocated
=
g_build_filename
(
base_uri
,
uri
,
NULL
);
else
uri
=
g_strdup
(
uri
);
if
(
uri_has_scheme
(
uri
))
{
struct
song
*
dest
=
playlist_check_load_song
(
song
,
uri
,
secure
);
dest
=
song_remote_new
(
uri
);
g_free
(
uri
);
}
else
if
(
g_path_is_absolute
(
uri
)
&&
secure
)
{
dest
=
song_file_load
(
uri
,
NULL
);
if
(
dest
==
NULL
)
{
song_free
(
song
);
song_free
(
song
);
return
NULL
;
g_free
(
allocated
);
}
}
else
{
dest
=
db_get_song
(
uri
);
g_free
(
uri
);
if
(
dest
==
NULL
)
{
/* not found in database */
song_free
(
song
);
return
dest
;
}
}
dest
=
apply_song_metadata
(
dest
,
song
);
song_free
(
song
);
return
dest
;
return
dest
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment