Commit 59dec65d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove libvlc->psz_homedir and use config_GetHomeDir() instead

parent 46c39c8e
...@@ -216,6 +216,7 @@ VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ...@@ -216,6 +216,7 @@ VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char *
VLC_EXPORT(const char *, config_GetDataDir, ( void )); VLC_EXPORT(const char *, config_GetDataDir, ( void ));
VLC_EXPORT(const char *, config_GetConfDir, ( void ) ); VLC_EXPORT(const char *, config_GetConfDir, ( void ) );
VLC_EXPORT(const char *, config_GetHomeDir, ( void ));
VLC_EXPORT(char *, config_GetUserConfDir, ( void ) ); VLC_EXPORT(char *, config_GetUserConfDir, ( void ) );
VLC_EXPORT(char *, config_GetUserDataDir, ( void ) ); VLC_EXPORT(char *, config_GetUserDataDir, ( void ) );
VLC_EXPORT(char *, config_GetCacheDir, ( void ) ); VLC_EXPORT(char *, config_GetCacheDir, ( void ) );
......
...@@ -36,12 +36,9 @@ struct libvlc_int_t ...@@ -36,12 +36,9 @@ struct libvlc_int_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
/* Global properties */ /* FIXME: this is only used by the logger module! */
const char * psz_homedir; ///< user's home directory
global_stats_t *p_stats; ///< Global statistics global_stats_t *p_stats; ///< Global statistics
/* Structure storing the action name / key associations */ /* Structure storing the action name / key associations */
struct hotkey struct hotkey
{ {
......
...@@ -267,7 +267,7 @@ static void Trigger (access_t *access) ...@@ -267,7 +267,7 @@ static void Trigger (access_t *access)
// and there is an off-by-one in the following sprintf(). // and there is an off-by-one in the following sprintf().
return; return;
const char *home = access->p_libvlc->psz_homedir; const char *home = config_GetHomeDir();
/* Hmm what about the extension?? */ /* Hmm what about the extension?? */
char filename[strlen (home) + sizeof ("/vlcdump-YYYYYYYYY-MM-DD-HH-MM-SS.ts")]; char filename[strlen (home) + sizeof ("/vlcdump-YYYYYYYYY-MM-DD-HH-MM-SS.ts")];
......
...@@ -154,8 +154,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -154,8 +154,7 @@ static int Open( vlc_object_t *p_this )
if( *psz == '\0' ) if( *psz == '\0' )
{ {
free( psz ); free( psz );
if( p_access->p_libvlc->psz_homedir ) /* XXX: This should never happen */ psz = strdup( config_GetHomeDir() );
psz = strdup( p_access->p_libvlc->psz_homedir );
} }
p_sys->psz_path = psz; p_sys->psz_path = psz;
msg_Dbg( p_access, "Record access filter path %s", psz ); msg_Dbg( p_access, "Record access filter path %s", psz );
......
...@@ -903,8 +903,7 @@ char *RealPath( intf_thread_t *p_intf, const char *psz_src ) ...@@ -903,8 +903,7 @@ char *RealPath( intf_thread_t *p_intf, const char *psz_src )
if( psz_dir[0] == '~' ) if( psz_dir[0] == '~' )
{ {
char *dir; char *dir;
/* This is incomplete : we should also support the ~cmassiot/ syntax. */ asprintf( &dir, "%s%s", config_GetHomeDir(), psz_dir + 1 );
asprintf( &dir, "%s%s", p_intf->p_libvlc->psz_homedir, psz_dir + 1 );
free( psz_dir ); free( psz_dir );
psz_dir = dir; psz_dir = dir;
} }
......
...@@ -1218,7 +1218,7 @@ static int MP4_ReadBox_sample_soun( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1218,7 +1218,7 @@ static int MP4_ReadBox_sample_soun( stream_t *p_stream, MP4_Box_t *p_box )
if( p_box->i_type == FOURCC_drms ) if( p_box->i_type == FOURCC_drms )
{ {
p_box->data.p_sample_soun->p_drms = p_box->data.p_sample_soun->p_drms =
drms_alloc( p_stream->p_libvlc->psz_homedir ); drms_alloc( config_GetHomeDir() );
if( p_box->data.p_sample_soun->p_drms == NULL ) if( p_box->data.p_sample_soun->p_drms == NULL )
{ {
......
...@@ -318,7 +318,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -318,7 +318,7 @@ static int Open( vlc_object_t *p_this )
} }
else else
{ {
p_sys->psz_current_dir = strdup( p_intf->p_libvlc->psz_homedir ); p_sys->psz_current_dir = strdup( config_GetHomeDir() );
} }
free( val.psz_string ); free( val.psz_string );
......
...@@ -299,7 +299,7 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this, ...@@ -299,7 +299,7 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
void FileConfigControl::updateField() void FileConfigControl::updateField()
{ {
QString file = QFileDialog::getOpenFileName( NULL, QString file = QFileDialog::getOpenFileName( NULL,
qtr( "Select File" ), qfu( p_this->p_libvlc->psz_homedir ) ); qtr( "Select File" ), qfu( config_GetHomeDir() ) );
if( file.isNull() ) return; if( file.isNull() ) return;
text->setText( file ); text->setText( file );
} }
...@@ -330,7 +330,7 @@ void DirectoryConfigControl::updateField() ...@@ -330,7 +330,7 @@ void DirectoryConfigControl::updateField()
QString dir = QFileDialog::getExistingDirectory( NULL, QString dir = QFileDialog::getExistingDirectory( NULL,
qtr( "Select Directory" ), qtr( "Select Directory" ),
text->text().isEmpty() ? text->text().isEmpty() ?
qfu( p_this->p_libvlc->psz_homedir ) : text->text(), qfu( config_GetHomeDir() ) : text->text(),
QFileDialog::ShowDirsOnly | QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks ); QFileDialog::DontResolveSymlinks );
if( dir.isNull() ) return; if( dir.isNull() ) return;
......
...@@ -257,7 +257,7 @@ void UpdateDialog::UpdateOrDownload() ...@@ -257,7 +257,7 @@ void UpdateDialog::UpdateOrDownload()
updateButton->setEnabled( false ); updateButton->setEnabled( false );
QString dest_dir = QFileDialog::getExistingDirectory( this, QString dest_dir = QFileDialog::getExistingDirectory( this,
qtr( "Select a directory ..." ), qtr( "Select a directory ..." ),
qfu( p_update->p_libvlc->psz_homedir ) ); qfu( config_GetHomeDir() ) );
if( dest_dir != "" ) if( dest_dir != "" )
{ {
......
...@@ -248,7 +248,7 @@ bool MessagesDialog::save() ...@@ -248,7 +248,7 @@ bool MessagesDialog::save()
{ {
QString saveLogFileName = QFileDialog::getSaveFileName( QString saveLogFileName = QFileDialog::getSaveFileName(
this, qtr( "Choose a filename to save the logs under..." ), this, qtr( "Choose a filename to save the logs under..." ),
qfu( p_intf->p_libvlc->psz_homedir ), qfu( config_GetHomeDir() ),
qtr( "Texts / Logs (*.log *.txt);; All (*.*) ") ); qtr( "Texts / Logs (*.log *.txt);; All (*.*) ") );
if( !saveLogFileName.isNull() ) if( !saveLogFileName.isNull() )
......
...@@ -264,7 +264,7 @@ bool VLMDialog::exportVLMConf() ...@@ -264,7 +264,7 @@ bool VLMDialog::exportVLMConf()
{ {
QString saveVLMConfFileName = QFileDialog::getSaveFileName( QString saveVLMConfFileName = QFileDialog::getSaveFileName(
this, qtr( "Choose a filename to save the VLM configuration..." ), this, qtr( "Choose a filename to save the VLM configuration..." ),
qfu( p_intf->p_libvlc->psz_homedir ), qfu( config_GetHomeDir() ),
qtr( "VLM conf (*.vlm) ;; All (*.*)" ) ); qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
if( !saveVLMConfFileName.isEmpty() ) if( !saveVLMConfFileName.isEmpty() )
...@@ -334,7 +334,7 @@ bool VLMDialog::importVLMConf() ...@@ -334,7 +334,7 @@ bool VLMDialog::importVLMConf()
{ {
QString openVLMConfFileName = QFileDialog::getOpenFileName( QString openVLMConfFileName = QFileDialog::getOpenFileName(
this, qtr( "Choose a VLM configuration file to open..." ), this, qtr( "Choose a VLM configuration file to open..." ),
qfu( p_intf->p_libvlc->psz_homedir ), qfu( config_GetHomeDir() ),
qtr( "VLM conf (*.vlm) ;; All (*.*)" ) ); qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
if( !openVLMConfFileName.isEmpty() ) if( !openVLMConfFileName.isEmpty() )
......
...@@ -368,7 +368,7 @@ static void Init( intf_thread_t *p_intf ) ...@@ -368,7 +368,7 @@ static void Init( intf_thread_t *p_intf )
/* retrieve last known path used in file browsing */ /* retrieve last known path used in file browsing */
char *psz_path = config_GetPsz( p_intf, "qt-filedialog-path" ); char *psz_path = config_GetPsz( p_intf, "qt-filedialog-path" );
p_intf->p_sys->psz_filepath = EMPTY_STR( psz_path ) ? psz_path p_intf->p_sys->psz_filepath = EMPTY_STR( psz_path ) ? psz_path
: p_intf->p_libvlc->psz_homedir; : config_GetHomeDir();
#ifdef UPDATE_CHECK #ifdef UPDATE_CHECK
/* Checking for VLC updates */ /* Checking for VLC updates */
......
...@@ -208,30 +208,10 @@ static int Open( vlc_object_t *p_this ) ...@@ -208,30 +208,10 @@ static int Open( vlc_object_t *p_this )
if( !psz_file ) if( !psz_file )
{ {
#ifdef __APPLE__ #ifdef __APPLE__
char *psz_homedir = p_this->p_libvlc->psz_homedir; if( asprintf( &psz_file, "%s/"LOG_DIR"/%s", config_GetHomeDir(),
(p_intf->p_sys->i_mode == MODE_HTML) ? LOG_FILE_HTML
if( !psz_homedir ) /* XXX: This should never happen */ : LOG_FILE_TEXT ) == -1 )
{ psz_file = NULL;
msg_Err( p_this, "unable to find home directory" );
return -1;
}
psz_file = (char *)malloc( sizeof("/" LOG_DIR "/" LOG_FILE_HTML) +
strlen(psz_homedir) );
if( psz_file )
{
switch( p_intf->p_sys->i_mode )
{
case MODE_HTML:
sprintf( psz_file, "%s/" LOG_DIR "/" LOG_FILE_HTML,
psz_homedir );
break;
case MODE_TEXT:
default:
sprintf( psz_file, "%s/" LOG_DIR "/" LOG_FILE_TEXT,
psz_homedir );
break;
}
}
#else #else
switch( p_intf->p_sys->i_mode ) switch( p_intf->p_sys->i_mode )
{ {
......
...@@ -160,7 +160,7 @@ int vlclua_datadir( lua_State *L ) ...@@ -160,7 +160,7 @@ int vlclua_datadir( lua_State *L )
} }
int vlclua_homedir( lua_State *L ) int vlclua_homedir( lua_State *L )
{ {
lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_homedir ); lua_pushstring( L, config_GetHomeDir() );
return 1; return 1;
} }
int vlclua_configdir( lua_State *L ) int vlclua_configdir( lua_State *L )
......
...@@ -43,7 +43,6 @@ void config_UnsetCallbacks( module_config_t *, size_t ); ...@@ -43,7 +43,6 @@ void config_UnsetCallbacks( module_config_t *, size_t );
#define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b) #define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b)
int __config_LoadCmdLine ( vlc_object_t *, int *, const char *[], bool ); int __config_LoadCmdLine ( vlc_object_t *, int *, const char *[], bool );
const char *config_GetHomeDir ( void );
char *config_GetCustomConfigFile( libvlc_int_t * ); char *config_GetCustomConfigFile( libvlc_int_t * );
int __config_LoadConfigFile( vlc_object_t *, const char * ); int __config_LoadConfigFile( vlc_object_t *, const char * );
......
...@@ -85,7 +85,7 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode ) ...@@ -85,7 +85,7 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
* Specification configs */ * Specification configs */
char *psz_old; char *psz_old;
if( asprintf( &psz_old, "%s" DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE, if( asprintf( &psz_old, "%s" DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE,
p_obj->p_libvlc->psz_homedir ) != -1 ) config_GetHomeDir() ) != -1 )
{ {
p_stream = utf8_fopen( psz_old, mode ); p_stream = utf8_fopen( psz_old, mode );
if( p_stream ) if( p_stream )
...@@ -96,7 +96,7 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode ) ...@@ -96,7 +96,7 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
"VLC will now use %s.", psz_old, psz_filename ); "VLC will now use %s.", psz_old, psz_filename );
char *psz_readme; char *psz_readme;
if( asprintf(&psz_readme,"%s"DIR_SEP CONFIG_DIR DIR_SEP"README", if( asprintf(&psz_readme,"%s"DIR_SEP CONFIG_DIR DIR_SEP"README",
p_obj->p_libvlc->psz_homedir ) != -1 ) config_GetHomeDir() ) != -1 )
{ {
FILE *p_readme = utf8_fopen( psz_readme, "wt" ); FILE *p_readme = utf8_fopen( psz_readme, "wt" );
if( p_readme ) if( p_readme )
...@@ -710,7 +710,7 @@ char *config_GetCustomConfigFile( libvlc_int_t *p_libvlc ) ...@@ -710,7 +710,7 @@ char *config_GetCustomConfigFile( libvlc_int_t *p_libvlc )
{ {
/* This is incomplete: we should also support the ~cmassiot/ syntax */ /* This is incomplete: we should also support the ~cmassiot/ syntax */
char *psz_buf; char *psz_buf;
if( asprintf( &psz_buf, "%s/%s", p_libvlc->psz_homedir, if( asprintf( &psz_buf, "%s/%s", config_GetHomeDir(),
psz_configfile + 2 ) == -1 ) psz_configfile + 2 ) == -1 )
{ {
free( psz_configfile ); free( psz_configfile );
......
...@@ -295,7 +295,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -295,7 +295,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
} }
/* Set the config file stuff */ /* Set the config file stuff */
p_libvlc->psz_homedir = config_GetHomeDir();
priv->psz_configfile = config_GetCustomConfigFile( p_libvlc ); priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
/* Check for plugins cache options */ /* Check for plugins cache options */
......
...@@ -55,6 +55,7 @@ config_GetCacheDir ...@@ -55,6 +55,7 @@ config_GetCacheDir
config_GetConfDir config_GetConfDir
config_GetDataDir config_GetDataDir
__config_GetFloat __config_GetFloat
config_GetHomeDir
__config_GetInt __config_GetInt
__config_GetPsz __config_GetPsz
__config_GetType __config_GetType
......
...@@ -576,15 +576,15 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -576,15 +576,15 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
} }
#if defined(__APPLE__) || defined(SYS_BEOS) #if defined(__APPLE__) || defined(SYS_BEOS)
if( !val.psz_string && p_vout->p_libvlc->psz_homedir ) if( !val.psz_string )
{ {
if( asprintf( &val.psz_string, "%s/Desktop", if( asprintf( &val.psz_string, "%s/Desktop",
p_vout->p_libvlc->psz_homedir ) == -1 ) config_GetHomeDir() ) == -1 )
val.psz_string = NULL; val.psz_string = NULL;
} }
#elif defined(WIN32) && !defined(UNDER_CE) #elif defined(WIN32) && !defined(UNDER_CE)
if( !val.psz_string && p_vout->p_libvlc->psz_homedir ) if( !val.psz_string )
{ {
/* Get the My Pictures folder path */ /* Get the My Pictures folder path */
...@@ -622,8 +622,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -622,8 +622,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
if( p_mypicturesdir == NULL ) if( p_mypicturesdir == NULL )
{ {
if( asprintf( &val.psz_string, "%s", if( asprintf( &val.psz_string, "%s", config_GetHomeDir() ) == -1 )
p_vout->p_libvlc->psz_homedir ) == -1 )
val.psz_string = NULL; val.psz_string = NULL;
} }
else else
......
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