]> git.sesse.net Git - vlc/commitdiff
Remove libvlc->psz_homedir and use config_GetHomeDir() instead
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 22 May 2008 18:28:54 +0000 (21:28 +0300)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 22 May 2008 18:29:04 +0000 (21:29 +0300)
19 files changed:
include/vlc_configuration.h
include/vlc_main.h
modules/access_filter/dump.c
modules/access_filter/record.c
modules/control/http/util.c
modules/demux/mp4/libmp4.c
modules/gui/ncurses.c
modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/dialogs/help.cpp
modules/gui/qt4/dialogs/messages.cpp
modules/gui/qt4/dialogs/vlm.cpp
modules/gui/qt4/qt4.cpp
modules/misc/logger.c
modules/misc/lua/vlc.c
src/config/configuration.h
src/config/file.c
src/libvlc-common.c
src/libvlccore.sym
src/video_output/vout_intf.c

index e65f8b0606b2df1073829f5792678ae4210ed889..15c6a2202083577b92f0a37cc3602b34f01b8cdc 100644 (file)
@@ -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 ) );
index 58dcc8e043cedc41887517b0cf8106f7978658c4..c67281f031ae84c82d5f6ba44ab49b84c7fdccc8 100644 (file)
@@ -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
     {
index b914b1a6cb84f8454b4b13c60ce3ca5aa384b47e..8760ca91ef82794b37e2ead5d0e1c922cbe2837c 100644 (file)
@@ -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")];
index 70d720f4fd07649708a0718606b95a1c86283081..3e7576291eac1af45b69bbd6f56732d8ce2d6484 100644 (file)
@@ -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 );
index 97767bdc0001f40f3dd807ad9e767fefe5108f90..d9699ccde25fe2d11ae8b2ee3c0431c1efa60706 100644 (file)
@@ -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;
     }
index 16cb872646fbd1c9320c4d80c0725c67b59411d1..43be5994c8a38c02780f273d86766eafa91ae91a 100644 (file)
@@ -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 )
         {
index f1da1448b09dfcaba67ffa84b0d21258c3bc6734..75696d8ffba2715df60d81aa6532223bfdd52b48 100644 (file)
@@ -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 );
index 310c9f9fb7bc19d9e4c0379f0a7bdaa24d3cc5ea..1f69d35f5cbfc540ef213f82ca67d1187dea9551 100644 (file)
@@ -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;
index c6ced9b08dc723933f377e319b4c706728e699be..f2422db3f65c1b11b3f97776f6c8592a6d85fe5a 100644 (file)
@@ -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 != "" )
         {
index 74ac7be87788a5f70d391d4767a59d412b6fdb76..8d56eee6a7ee4bb4687a32bf6ae8c1c0537832c0 100644 (file)
@@ -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() )
index 3bc4725753d2e94ac324d65d33a39ce76bb5fdb1..ba6e60d40326b187265f74410133fc6067ca23e1 100644 (file)
@@ -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() )
index 45b4c562e5a34c745cd95e3e47c918338f9088a8..28b4c7cb70fc6cb91470a0f95758af1cc3fa0879 100644 (file)
@@ -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 */
index 1a905e5804ac6a8a9da3ae0c75b49d33a307ab42..eb06269595148c5cc67f556cdd073170c3d25603 100644 (file)
@@ -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 )
             {
index 3402c4ff41bf859c4ea79155d519e559d32b0db7..75adb224461c8937c2b953748bf425ead3526fc0 100644 (file)
@@ -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 )
index bd7ae607ffa208357986a780fad9572389db8545..9d1ba85220777e1a5c34f5d992c7b3c1d70c9855 100644 (file)
@@ -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 * );
 
index b6ce5eff06286289bb9d4baaaa9ed52daa1dac50..c77c2bfe423d5200e0c7871a95e9e7d87cd86be7 100644 (file)
@@ -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 );
index 2811eb7b9e588083c3d8e02228f52409de9d0484..f5891ddcc22cdf1eef6b3fd6acf5d152fcfea46b 100644 (file)
@@ -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 */
index 87944caf1fc2fe4bb18f7bbbd956b4725a6b1650..222f00823766c48fbddaffc86b5613126afe4dc3 100644 (file)
@@ -55,6 +55,7 @@ config_GetCacheDir
 config_GetConfDir
 config_GetDataDir
 __config_GetFloat
+config_GetHomeDir
 __config_GetInt
 __config_GetPsz
 __config_GetType
index 6218844119e4da1620e7b8167e4fc54adf861812..9103b22a3c5335972670144efe16db4a2852f219 100644 (file)
@@ -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