Commit 16f32e15 authored by Antoine Cellerier's avatar Antoine Cellerier

On OSes other than Windows, Mac OS X and BeOS (so it's Linux) comply with the...

On OSes other than Windows, Mac OS X and BeOS (so it's Linux) comply with the XDG Base Directory Specification version 0.6. The old configuration file (vlcrc) will be copied to the new location. Other data like caches will have to be rebuilt (the album art cache in VLC was new in 0.9.0 so it's ok to lose it). Closes #1267
parent e8f97c66
......@@ -112,6 +112,11 @@ Interfaces:
finished: http://wiki.xmms2.xmms.se/index.php/Media_Player_Interfaces .
* Motion module use disk accelerometers to keep video horizontal
Linux Port:
* VLC now complies with the XDG Base Directory Specification version 0.6
http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
(which means that VLC doesn't use the $HOME/.vlc directory anymore)
Capture:
* new BDA device driver plugin for DVB-C/S/T capture cards on Microsoft
Windows
......
......@@ -38,8 +38,11 @@ struct libvlc_int_t
/* Global properties */
int i_argc; ///< command line arguments count
char ** ppsz_argv; ///< command line arguments
char * psz_homedir; ///< configuration directory
char * psz_userdir; ///< user's home directory
char * psz_homedir; ///< user's home directory
char * psz_configdir; ///< user's configuration directory
char * psz_datadir; ///< user's data/cache directory
char * psz_configfile; ///< location of config file
playlist_t *p_playlist; ///< playlist object
......
......@@ -48,19 +48,6 @@
* outputting an error message (in second) */
#define THREAD_COND_TIMEOUT 1
/* The configuration file and directory */
#if defined (SYS_BEOS)
# define CONFIG_DIR "config/settings/VideoLAN Client"
#elif defined (__APPLE__)
# define CONFIG_DIR "Library/Preferences/VLC"
#elif defined( WIN32 ) || defined( UNDER_CE )
# define CONFIG_DIR "vlc"
#else
# define CONFIG_DIR ".vlc"
#endif
#define CONFIG_FILE "vlcrc"
#define PLUGINSCACHE_DIR "cache"
/*****************************************************************************
* Interface configuration
*****************************************************************************/
......
......@@ -148,7 +148,7 @@ static int Open( vlc_object_t *p_this )
if( *psz == '\0' )
{
free( psz );
if( p_access->p_libvlc->psz_homedir )
if( p_access->p_libvlc->psz_homedir ) /* XXX: This should never happen */
psz = strdup( p_access->p_libvlc->psz_homedir );
}
p_sys->psz_path = psz;
......
......@@ -989,7 +989,7 @@ char *E_(RealPath)( intf_thread_t *p_intf, const char *psz_src )
{
char *dir;
/* This is incomplete : we should also support the ~cmassiot/ syntax. */
asprintf( &dir, "%s%s", p_intf->p_libvlc->psz_userdir, psz_dir + 1 );
asprintf( &dir, "%s%s", p_intf->p_libvlc->psz_homedir, psz_dir + 1 );
free( psz_dir );
psz_dir = dir;
}
......
......@@ -225,9 +225,9 @@ bool Win32Factory::init()
}
// Initialize the resource path
m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_homedir +
"\\" + CONFIG_DIR + "\\skins" );
m_resourcePath.push_back( (string)config_GetDataDir() +
m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_datadir +
"\\skins" );
m_resourcePath.push_back( (dstring)config_GetDataDir() +
"\\skins" );
m_resourcePath.push_back( (string)config_GetDataDir() +
"\\skins2" );
......
......@@ -71,8 +71,8 @@ bool X11Factory::init()
ConnectionNumber( pDisplay ) );
// Initialize the resource path
m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_homedir +
m_dirSep + CONFIG_DIR + "/skins2" );
m_resourcePath.push_back( (string)getIntf()->p_libvlc->psz_datadir +
+ "/skins2" );
m_resourcePath.push_back( (string)"share/skins2" );
m_resourcePath.push_back( (string)DATA_PATH + "/skins2" );
......
......@@ -702,11 +702,11 @@ gnutls_ClientCreate( tls_t *p_tls )
vlc_object_attach( p_session, p_tls );
const char *homedir = p_tls->p_libvlc->psz_homedir,
const char *homedir = p_tls->p_libvlc->psz_datadir,
*datadir = config_GetDataDir ();
size_t l1 = strlen (homedir), l2 = strlen (datadir);
char path[((l1 > l2) ? l1 : l2) + sizeof ("/"CONFIG_DIR"/ssl/private")];
// > sizeof ("/"CONFIG_DIR"/ssl/certs")
char path[((l1 > l2) ? l1 : l2) + sizeof ("/ssl/private")];
// > sizeof ("/ssl/certs")
// > sizeof ("/ca-certificates.crt")
i_val = gnutls_certificate_allocate_credentials( &p_sys->x509_cred );
......@@ -719,7 +719,7 @@ gnutls_ClientCreate( tls_t *p_tls )
if (var_CreateGetBool (p_tls, "tls-check-cert"))
{
sprintf (path, "%s/"CONFIG_DIR"/ssl/certs", homedir);
sprintf (path, "%s/ssl/certs", homedir);
gnutls_Addx509Directory ((vlc_object_t *)p_session,
p_sys->x509_cred, path, VLC_FALSE);
......@@ -731,7 +731,7 @@ gnutls_ClientCreate( tls_t *p_tls )
else
p_session->pf_handshake2 = gnutls_ContinueHandshake;
sprintf (path, "%s/"CONFIG_DIR"/ssl/private", homedir);
sprintf (path, "%s/ssl/private", homedir);
gnutls_Addx509Directory ((vlc_object_t *)p_session, p_sys->x509_cred,
path, VLC_TRUE);
......
......@@ -201,7 +201,7 @@ static int Open( vlc_object_t *p_this )
#ifdef __APPLE__
char *psz_homedir = p_this->p_libvlc->psz_homedir;
if( !psz_homedir )
if( !psz_homedir ) /* XXX: This should never happen */
{
msg_Err( p_this, "unable to find home directory" );
return -1;
......
......@@ -245,8 +245,8 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
char *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
char **ppsz_dir;
if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP CONFIG_DIR DIR_SEP "%s", p_this->p_libvlc->psz_homedir,
luadirname ) < 0 )
if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP "%s",
p_this->p_libvlc->psz_datadir, luadirname ) < 0 )
return VLC_ENOMEM;
# if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
......
......@@ -88,17 +88,17 @@ void
libvlc_media_library_load( libvlc_media_library_t * p_mlib,
libvlc_exception_t * p_e )
{
const char *psz_homedir = p_mlib->p_libvlc_instance->p_libvlc_int->psz_homedir;
const char *psz_datadir = p_mlib->p_libvlc_instance->p_libvlc_int->psz_datadir;
char * psz_uri;
if( !psz_homedir )
if( !psz_datadir ) /* XXX: i doubt that this can ever happen */
{
libvlc_exception_raise( p_e, "Can't get HOME DIR" );
libvlc_exception_raise( p_e, "Can't get data directory" );
return;
}
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP CONFIG_DIR DIR_SEP
"ml.xsp", psz_homedir ) == -1 )
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp",
psz_datadir ) == -1 )
{
libvlc_exception_raise( p_e, "Can't get create the path" );
return;
......
......@@ -273,9 +273,9 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
char * psz_album_sanitized = ArtCacheGetSanitizedFileName( psz_album );
char * psz_artist_sanitized = ArtCacheGetSanitizedFileName( psz_artist );
snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP CONFIG_DIR DIR_SEP
snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP
"art" DIR_SEP "artistalbum" DIR_SEP "%s" DIR_SEP "%s",
p_obj->p_libvlc->psz_homedir,
p_obj->p_libvlc->psz_datadir,
psz_artist_sanitized, psz_album_sanitized );
free( psz_album_sanitized );
free( psz_artist_sanitized );
......@@ -283,9 +283,9 @@ static void __ArtCacheGetDirPath( vlc_object_t *p_obj,
else
{
char * psz_title_sanitized = ArtCacheGetSanitizedFileName( psz_title );
snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP CONFIG_DIR DIR_SEP
snprintf( psz_dir, MAX_PATH, "%s" DIR_SEP
"art" DIR_SEP "title" DIR_SEP "%s",
p_obj->p_libvlc->psz_homedir,
p_obj->p_libvlc->psz_datadir,
psz_title_sanitized );
free( psz_title_sanitized );
}
......
......@@ -325,25 +325,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
}
/* Set the config file stuff */
p_libvlc->psz_homedir = config_GetHomeDir();
p_libvlc->psz_userdir = config_GetUserDir();
if( p_libvlc->psz_userdir == NULL )
p_libvlc->psz_userdir = strdup(p_libvlc->psz_homedir);
p_libvlc->psz_configfile = config_GetPsz( p_libvlc, "config" );
if( (p_libvlc->psz_configfile != NULL) && (p_libvlc->psz_configfile[0] == '~')
&& (p_libvlc->psz_configfile[1] == '/') )
{
char *psz = malloc( strlen(p_libvlc->psz_userdir)
+ strlen(p_libvlc->psz_configfile) );
if( psz )
{
/* This is incomplete : we should also support the ~cmassiot/ syntax. */
sprintf( psz, "%s/%s", p_libvlc->psz_userdir,
p_libvlc->psz_configfile + 2 );
free( p_libvlc->psz_configfile );
p_libvlc->psz_configfile = psz;
} /* else keep old config stuff */
}
p_libvlc->psz_homedir = config_GetHomeDir();
p_libvlc->psz_configdir = config_GetConfigDir( p_libvlc );
p_libvlc->psz_datadir = config_GetUserDataDir( p_libvlc );
p_libvlc->psz_configfile = config_GetCustomConfigFile( p_libvlc );
/* Check for plugins cache options */
if( config_GetInt( p_libvlc, "reset-plugins-cache" ) )
......@@ -1067,7 +1052,8 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
module_EndBank( p_libvlc );
FREENULL( p_libvlc->psz_homedir );
FREENULL( p_libvlc->psz_userdir );
FREENULL( p_libvlc->psz_configdir );
FREENULL( p_libvlc->psz_datadir );
FREENULL( p_libvlc->psz_configfile );
FREENULL( p_libvlc->p_hotkeys );
......
This diff is collapsed.
......@@ -33,17 +33,33 @@ int config_AutoSaveConfigFile( vlc_object_t * );
void config_Free( module_t * );
void config_SetCallbacks( module_config_t *, module_config_t *, size_t );
void config_UnsetCallbacks ( module_config_t *, size_t );
void config_UnsetCallbacks( module_config_t *, size_t );
#define config_LoadCmdLine(a,b,c,d) __config_LoadCmdLine(VLC_OBJECT(a),b,c,d)
#define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b)
int __config_LoadCmdLine ( vlc_object_t *, int *, char *[], vlc_bool_t );
char * config_GetHomeDir ( void );
char * config_GetUserDir ( void );
int __config_LoadConfigFile ( vlc_object_t *, const char * );
int __config_LoadCmdLine ( vlc_object_t *, int *, char *[], vlc_bool_t );
char *config_GetHomeDir ( void );
char *config_GetConfigDir ( libvlc_int_t * );
char *config_GetUserDataDir( libvlc_int_t * );
char *config_GetConfigFile ( libvlc_int_t * );
char *config_GetCustomConfigFile( libvlc_int_t * );
int __config_LoadConfigFile( vlc_object_t *, const char * );
int IsConfigStringType (int type);
int IsConfigStringType( int type );
/* The configuration file and directory */
#if defined (SYS_BEOS)
# define CONFIG_DIR "config/settings/VideoLAN Client"
#elif defined (__APPLE__)
# define CONFIG_DIR "Library/Preferences/VLC"
#elif defined( WIN32 ) || defined( UNDER_CE )
# define CONFIG_DIR "vlc"
#else
# define CONFIG_DIR ".vlc"
#endif
#define CONFIG_FILE "vlcrc"
#define PLUGINSCACHE_DIR "cache"
# ifdef __cplusplus
}
......
......@@ -1665,7 +1665,7 @@ static char * GetWindowsError( void )
*****************************************************************************/
static void CacheLoad( vlc_object_t *p_this )
{
char *psz_filename, *psz_homedir;
char *psz_filename, *psz_datadir;
FILE *file;
int i, j, i_size, i_read;
char p_cachestring[sizeof(PLUGINSCACHE_DIR COPYRIGHT_MESSAGE)];
......@@ -1675,15 +1675,15 @@ static void CacheLoad( vlc_object_t *p_this )
int32_t i_file_size, i_marker;
libvlc_global_data_t *p_libvlc_global = vlc_global();
psz_homedir = p_this->p_libvlc->psz_homedir;
if( !psz_homedir )
psz_datadir = p_this->p_libvlc->psz_datadir;
if( !psz_datadir ) /* XXX: this should never happen */
{
msg_Err( p_this, "psz_homedir is null" );
msg_Err( p_this, "Unable to get cache directory" );
return;
}
i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s"DIR_SEP"%s",
psz_homedir, CONFIG_DIR, PLUGINSCACHE_DIR, CacheName() );
i_size = asprintf( &psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s",
psz_datadir, PLUGINSCACHE_DIR, CacheName() );
if( i_size <= 0 )
{
msg_Err( p_this, "out of memory" );
......@@ -2022,22 +2022,23 @@ static void CacheSave( vlc_object_t *p_this )
"# For information about cache directory tags, see:\r\n"
"# http://www.brynosaurus.com/cachedir/\r\n";
char *psz_filename, *psz_homedir;
char *psz_filename, *psz_datadir;
FILE *file;
int i, j, i_cache;
module_cache_t **pp_cache;
int32_t i_file_size = 0;
libvlc_global_data_t *p_libvlc_global = vlc_global();
psz_homedir = p_this->p_libvlc->psz_homedir;
if( !psz_homedir )
psz_datadir = p_this->p_libvlc->psz_datadir;
if( !psz_datadir ) /* XXX: this should never happen */
{
msg_Err( p_this, "psz_homedir is null" );
msg_Err( p_this, "Unable to get cache directory" );
return;
}
psz_filename =
(char *)malloc( sizeof(DIR_SEP CONFIG_DIR DIR_SEP PLUGINSCACHE_DIR DIR_SEP ) +
strlen(psz_homedir) + strlen(CacheName()) );
(char *)malloc( sizeof(DIR_SEP PLUGINSCACHE_DIR DIR_SEP ) +
strlen(psz_datadir) + strlen(CacheName()) );
if( !psz_filename )
{
......@@ -2045,7 +2046,7 @@ static void CacheSave( vlc_object_t *p_this )
return;
}
sprintf( psz_filename, "%s"DIR_SEP"%s", psz_homedir, CONFIG_DIR );
sprintf( psz_filename, "%s", psz_datadir );
config_CreateDir( p_this, psz_filename );
......@@ -2062,7 +2063,7 @@ static void CacheSave( vlc_object_t *p_this )
fclose( file );
}
sprintf( psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s"DIR_SEP"%s", psz_homedir, CONFIG_DIR,
sprintf( psz_filename, "%s"DIR_SEP"%s"DIR_SEP"%s", psz_datadir,
PLUGINSCACHE_DIR, CacheName() );
msg_Dbg( p_this, "saving plugins cache file %s", psz_filename );
......
......@@ -89,19 +89,18 @@ int playlist_Export( playlist_t * p_playlist, const char *psz_filename ,
int playlist_MLLoad( playlist_t *p_playlist )
{
const char *psz_homedir = p_playlist->p_libvlc->psz_homedir;
const char *psz_datadir = p_playlist->p_libvlc->psz_datadir;
char *psz_uri = NULL;
input_item_t *p_input;
if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS;
if( !psz_homedir )
if( !psz_datadir ) /* XXX: This should never happen */
{
msg_Err( p_playlist, "no home directory, cannot load media library") ;
msg_Err( p_playlist, "no data directory, cannot load media library") ;
return VLC_EGENERIC;
}
if( asprintf( &psz_uri, "%s" DIR_SEP CONFIG_DIR DIR_SEP
"ml.xsp", psz_homedir ) == -1 )
if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xsp", psz_datadir ) == -1 )
{
psz_uri = NULL;
goto error;
......@@ -115,8 +114,8 @@ int playlist_MLLoad( playlist_t *p_playlist )
}
free( psz_uri );
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP CONFIG_DIR DIR_SEP
"ml.xsp", psz_homedir ) == -1 )
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp",
psz_datadir ) == -1 )
{
psz_uri = NULL;
goto error;
......@@ -146,24 +145,24 @@ error:
int playlist_MLDump( playlist_t *p_playlist )
{
char *psz_homedir = p_playlist->p_libvlc->psz_homedir;
char *psz_datadir = p_playlist->p_libvlc->psz_datadir;
if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS;
if( !psz_homedir )
if( !psz_datadir ) /* XXX: This should never happen */
{
msg_Err( p_playlist, "no home directory, cannot save media library") ;
msg_Err( p_playlist, "no data directory, cannot save media library") ;
return VLC_EGENERIC;
}
char psz_dirname[ strlen( psz_homedir )
+ sizeof( DIR_SEP CONFIG_DIR DIR_SEP "ml.xsl")];
sprintf( psz_dirname, "%s" DIR_SEP CONFIG_DIR, psz_homedir );
char psz_dirname[ strlen( psz_datadir )
+ sizeof( DIR_SEP "ml.xsl")];
sprintf( psz_dirname, "%s", psz_datadir );
if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) )
{
return VLC_EGENERIC;
}
strcat( psz_dirname, DIR_SEP "ml.xsp" );
stats_TimerStart( p_playlist, "ML Dump", STATS_TIMER_ML_DUMP );
playlist_Export( p_playlist, psz_dirname, p_playlist->p_ml_category,
"export-xspf" );
......
......@@ -619,7 +619,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
if( p_mypicturesdir == NULL )
{
if( asprintf( &val.psz_string, "%s\\" CONFIG_DIR,
if( asprintf( &val.psz_string, "%s",
p_vout->p_libvlc->psz_homedir ) == -1 )
val.psz_string = NULL;
}
......@@ -632,10 +632,12 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
}
#else
if( !val.psz_string && p_vout->p_libvlc->psz_homedir )
/* XXX: This saves in the data directory. Shouldn't we try saving
* to psz_homedir/Desktop or something nicer ? */
if( !val.psz_string && p_vout->p_libvlc->psz_datadir )
{
if( asprintf( &val.psz_string, "%s/" CONFIG_DIR,
p_vout->p_libvlc->psz_homedir ) == -1 )
if( asprintf( &val.psz_string, "%s",
p_vout->p_libvlc->psz_datadir ) == -1 )
val.psz_string = NULL;
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment