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 *
VLC_EXPORT(const char *, config_GetDataDir, ( 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_GetUserDataDir, ( void ) );
VLC_EXPORT(char *, config_GetCacheDir, ( void ) );
......
......@@ -36,12 +36,9 @@ struct libvlc_int_t
{
VLC_COMMON_MEMBERS
/* Global properties */
const char * psz_homedir; ///< user's home directory
/* FIXME: this is only used by the logger module! */
global_stats_t *p_stats; ///< Global statistics
/* Structure storing the action name / key associations */
struct hotkey
{
......
......@@ -267,7 +267,7 @@ static void Trigger (access_t *access)
// and there is an off-by-one in the following sprintf().
return;
const char *home = access->p_libvlc->psz_homedir;
const char *home = config_GetHomeDir();
/* Hmm what about the extension?? */
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 )
if( *psz == '\0' )
{
free( psz );
if( p_access->p_libvlc->psz_homedir ) /* XXX: This should never happen */
psz = strdup( p_access->p_libvlc->psz_homedir );
psz = strdup( config_GetHomeDir() );
}
p_sys->psz_path = 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 )
if( psz_dir[0] == '~' )
{
char *dir;
/* This is incomplete : we should also support the ~cmassiot/ syntax. */
asprintf( &dir, "%s%s", p_intf->p_libvlc->psz_homedir, psz_dir + 1 );
asprintf( &dir, "%s%s", config_GetHomeDir(), psz_dir + 1 );
free( psz_dir );
psz_dir = dir;
}
......
......@@ -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 )
{
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 )
{
......
......@@ -318,7 +318,7 @@ static int Open( vlc_object_t *p_this )
}
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 );
......
......@@ -299,7 +299,7 @@ FileConfigControl::FileConfigControl( vlc_object_t *_p_this,
void FileConfigControl::updateField()
{
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;
text->setText( file );
}
......@@ -330,7 +330,7 @@ void DirectoryConfigControl::updateField()
QString dir = QFileDialog::getExistingDirectory( NULL,
qtr( "Select Directory" ),
text->text().isEmpty() ?
qfu( p_this->p_libvlc->psz_homedir ) : text->text(),
qfu( config_GetHomeDir() ) : text->text(),
QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks );
if( dir.isNull() ) return;
......
......@@ -257,7 +257,7 @@ void UpdateDialog::UpdateOrDownload()
updateButton->setEnabled( false );
QString dest_dir = QFileDialog::getExistingDirectory( this,
qtr( "Select a directory ..." ),
qfu( p_update->p_libvlc->psz_homedir ) );
qfu( config_GetHomeDir() ) );
if( dest_dir != "" )
{
......
......@@ -248,7 +248,7 @@ bool MessagesDialog::save()
{
QString saveLogFileName = QFileDialog::getSaveFileName(
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 (*.*) ") );
if( !saveLogFileName.isNull() )
......
......@@ -264,7 +264,7 @@ bool VLMDialog::exportVLMConf()
{
QString saveVLMConfFileName = QFileDialog::getSaveFileName(
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 (*.*)" ) );
if( !saveVLMConfFileName.isEmpty() )
......@@ -334,7 +334,7 @@ bool VLMDialog::importVLMConf()
{
QString openVLMConfFileName = QFileDialog::getOpenFileName(
this, qtr( "Choose a VLM configuration file to open..." ),
qfu( p_intf->p_libvlc->psz_homedir ),
qfu( config_GetHomeDir() ),
qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
if( !openVLMConfFileName.isEmpty() )
......
......@@ -368,7 +368,7 @@ static void Init( intf_thread_t *p_intf )
/* retrieve last known path used in file browsing */
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_libvlc->psz_homedir;
: config_GetHomeDir();
#ifdef UPDATE_CHECK
/* Checking for VLC updates */
......
......@@ -208,30 +208,10 @@ static int Open( vlc_object_t *p_this )
if( !psz_file )
{
#ifdef __APPLE__
char *psz_homedir = p_this->p_libvlc->psz_homedir;
if( !psz_homedir ) /* XXX: This should never happen */
{
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;
}
}
if( asprintf( &psz_file, "%s/"LOG_DIR"/%s", config_GetHomeDir(),
(p_intf->p_sys->i_mode == MODE_HTML) ? LOG_FILE_HTML
: LOG_FILE_TEXT ) == -1 )
psz_file = NULL;
#else
switch( p_intf->p_sys->i_mode )
{
......
......@@ -160,7 +160,7 @@ int vlclua_datadir( 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;
}
int vlclua_configdir( lua_State *L )
......
......@@ -43,7 +43,6 @@ void config_UnsetCallbacks( module_config_t *, size_t );
#define config_LoadConfigFile(a,b) __config_LoadConfigFile(VLC_OBJECT(a),b)
int __config_LoadCmdLine ( vlc_object_t *, int *, const char *[], bool );
const char *config_GetHomeDir ( void );
char *config_GetCustomConfigFile( libvlc_int_t * );
int __config_LoadConfigFile( vlc_object_t *, const char * );
......
......@@ -85,7 +85,7 @@ static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
* Specification configs */
char *psz_old;
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 );
if( p_stream )
......@@ -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 );
char *psz_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" );
if( p_readme )
......@@ -710,7 +710,7 @@ char *config_GetCustomConfigFile( libvlc_int_t *p_libvlc )
{
/* This is incomplete: we should also support the ~cmassiot/ syntax */
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 )
{
free( psz_configfile );
......
......@@ -295,7 +295,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
}
/* Set the config file stuff */
p_libvlc->psz_homedir = config_GetHomeDir();
priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
/* Check for plugins cache options */
......
......@@ -55,6 +55,7 @@ config_GetCacheDir
config_GetConfDir
config_GetDataDir
__config_GetFloat
config_GetHomeDir
__config_GetInt
__config_GetPsz
__config_GetType
......
......@@ -576,15 +576,15 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
}
#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",
p_vout->p_libvlc->psz_homedir ) == -1 )
config_GetHomeDir() ) == -1 )
val.psz_string = NULL;
}
#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 */
......@@ -622,8 +622,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
if( p_mypicturesdir == NULL )
{
if( asprintf( &val.psz_string, "%s",
p_vout->p_libvlc->psz_homedir ) == -1 )
if( asprintf( &val.psz_string, "%s", config_GetHomeDir() ) == -1 )
val.psz_string = NULL;
}
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