]> git.sesse.net Git - vlc/commitdiff
Add --data-path option. Access the src share directory now works from build tree.
authorAntoine Cellerier <antoine@macbook.(none)>
Sun, 20 Dec 2009 14:05:02 +0000 (15:05 +0100)
committerAntoine Cellerier <dionoea@videolan.org>
Mon, 21 Dec 2009 20:45:17 +0000 (21:45 +0100)
21 files changed:
bin/vlc.c
include/vlc_configuration.h
modules/control/http/http.c
modules/gui/hildon/maemo.c
modules/gui/skins2/win32/win32_factory.cpp
modules/gui/skins2/x11/x11_factory.cpp
modules/misc/lua/intf.c
modules/misc/lua/libs/misc.c
modules/misc/lua/libs/net.c
modules/misc/lua/vlc.c
modules/misc/lua/vlc.h
modules/misc/notify/growl.m
modules/misc/notify/notify.c
src/Makefile.am
src/config/configuration.h
src/config/dirs.c [new file with mode: 0644]
src/config/dirs_macos.c
src/config/dirs_win.c
src/config/dirs_xdg.c
src/libvlc-module.c
src/libvlccore.sym

index bad420bacc584dc13f96d830ebe3b3081ff0fbb5..246ea149d52aa2208e17755fcb25303374d814ee 100644 (file)
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -133,9 +133,7 @@ int main( int i_argc, const char *ppsz_argv[] )
     argv[argc++] = FromLocale ("--plugin-path="TOP_BUILDDIR"/modules");
 #endif
 #ifdef TOP_SRCDIR
-# ifdef ENABLE_HTTPD
-    argv[argc++] = FromLocale ("--http-src="TOP_SRCDIR"/share/http");
-# endif
+    argv[argc++] = FromLocale ("--data-path="TOP_SRCDIR"/share");
 #endif
 
     int i = 1;
index c208509efc117b657e989c819e2ff83f280334df..2c7345e963e6a3ddd895763b215b82ee38355f4a 100644 (file)
@@ -214,7 +214,8 @@ VLC_EXPORT( int,    __config_SaveConfigFile, ( vlc_object_t *, const char * ) );
 VLC_EXPORT( void,   __config_ResetAll, ( vlc_object_t * ) );
 
 VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) LIBVLC_USED );
-VLC_EXPORT(const char *, config_GetDataDir, ( void ) LIBVLC_USED);
+VLC_EXPORT(char *, __config_GetDataDir, ( vlc_object_t * ) LIBVLC_USED);
+#define config_GetDataDir(a) __config_GetDataDir(VLC_OBJECT(a))
 VLC_EXPORT(const char *, config_GetConfDir, ( void ) LIBVLC_USED);
 
 typedef enum vlc_userdir
index fe043e9808f3612dbfdb1ac63056f061ec96c2c1..ec762d0bbe652816d07bb182ddd3c617efcca409 100644 (file)
@@ -232,9 +232,10 @@ static int Open( vlc_object_t *p_this )
     psz_src = config_GetPsz( p_intf, "http-src" );
     if( ( psz_src == NULL ) || ( *psz_src == '\0' ) )
     {
-        const char *data_path = config_GetDataDir ();
+        char *data_path = config_GetDataDir( p_intf );
         if( asprintf( &psz_src, "%s" DIR_SEP "http", data_path ) == -1 )
             psz_src = NULL;
+        free( data_path );
     }
 
     if( !psz_src || *psz_src == '\0' )
index 476dacf530e88d198e8e78aea7a85199fbf09707..f6d74655ee00c4a88257affa6845b88012b4b95f 100644 (file)
@@ -158,12 +158,13 @@ static void Run( intf_thread_t *p_intf )
 
     // A little theming
     char *psz_rc_file = NULL;
-    if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc",
-                  config_GetDataDir() ) != -1 )
+    char *psz_data = config_GetDataDir( p_intf );
+    if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc", psz_data ) != -1 )
     {
         gtk_rc_parse( psz_rc_file );
         free( psz_rc_file );
     }
+    free( psz_data );
 
     // We create the main vertical box
     main_vbox = gtk_vbox_new( FALSE, 0 );
index 07b6325f488e0ff7c96c88b0c87d73cff21fd127..e7bbf66952b11dc9873c403ed1b44ac65653e829 100644 (file)
@@ -229,14 +229,12 @@ bool Win32Factory::init()
     char *datadir = config_GetUserDir( VLC_DATA_DIR );
     m_resourcePath.push_back( (string)datadir + "\\skins" );
     free( datadir );
-    m_resourcePath.push_back( (string)config_GetDataDir() +
-                              "\\skins" );
-    m_resourcePath.push_back( (string)config_GetDataDir() +
-                              "\\skins2" );
-    m_resourcePath.push_back( (string)config_GetDataDir() +
-                              "\\share\\skins" );
-    m_resourcePath.push_back( (string)config_GetDataDir() +
-                              "\\share\\skins2" );
+    datadir = config_GetDataDir( getIntf() );
+    m_resourcePath.push_back( (string)datadir + "\\skins" );
+    m_resourcePath.push_back( (string)datadir + "\\skins2" );
+    m_resourcePath.push_back( (string)datadir + "\\share\\skins" );
+    m_resourcePath.push_back( (string)datadir + "\\share\\skins2" );
+    free( datadir );
 
     // All went well
     return true;
index a6b0df6f4bb0f289ebac06bc2fdd596c6a1601e4..f203de836bfed05e752bce19848ab83bdb020760 100644 (file)
@@ -80,7 +80,9 @@ bool X11Factory::init()
     m_resourcePath.push_back( (string)datadir + "/skins2" );
     free( datadir );
     m_resourcePath.push_back( (string)"share/skins2" );
-    m_resourcePath.push_back( (string)config_GetDataDir () + "/skins2" );
+    datadir = config_GetDataDir( getIntf() );
+    m_resourcePath.push_back( (string)datadir + "/skins2" );
+    free( datadir );
 
     return true;
 }
index d7430bcab9f790222b02edbaac7f7187987716f0..424a32d7bf146144acd9ac91eb34d8de55c5060e 100644 (file)
@@ -57,11 +57,11 @@ static const char * const ppsz_intf_options[] = { "intf", "config", NULL };
 /*****************************************************************************
  *
  *****************************************************************************/
-static char *FindFile( const char *psz_name )
+static char *FindFile( vlc_object_t *p_this, const char *psz_name )
 {
     char  *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
     char **ppsz_dir;
-    vlclua_dir_list( "intf", ppsz_dir_list );
+    vlclua_dir_list( p_this, "intf", ppsz_dir_list );
     for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
     {
         char *psz_filename;
@@ -162,7 +162,7 @@ int Open_LuaIntf( vlc_object_t *p_this )
         return VLC_ENOMEM;
     }
     p_sys = p_intf->p_sys;
-    p_sys->psz_filename = FindFile( psz_name );
+    p_sys->psz_filename = FindFile( p_this, psz_name );
     if( !p_sys->psz_filename )
     {
         msg_Err( p_intf, "Couldn't find lua interface script \"%s\".",
index 37fdb72c95ae9143c47351260b5043fae34261fa..e5a1f02aa175fc1681ca86b9e56fe784c4348ae1 100644 (file)
@@ -114,7 +114,9 @@ static int vlclua_quit( lua_State *L )
  *****************************************************************************/
 static int vlclua_datadir( lua_State *L )
 {
-    lua_pushstring( L, config_GetDataDir() );
+    char *psz_data = config_GetDataDir( vlclua_get_this( L ) );
+    lua_pushstring( L, psz_data );
+    free( psz_data );
     return 1;
 }
 
@@ -157,7 +159,8 @@ static int vlclua_datadir_list( lua_State *L )
     char **ppsz_dir = ppsz_dir_list;
     int i = 1;
 
-    if( vlclua_dir_list( psz_dirname, ppsz_dir_list ) != VLC_SUCCESS )
+    if( vlclua_dir_list( vlclua_get_this( L ), psz_dirname, ppsz_dir_list )
+        != VLC_SUCCESS )
         return 0;
     lua_newtable( L );
     for( ; *ppsz_dir; ppsz_dir++ )
index 4e4b5787ddab20c412440da156c413835ced19db..6d2c30a16a8d75bea51e97fcb90f8c8490d3e545 100644 (file)
@@ -132,7 +132,7 @@ static int vlclua_net_accept( lua_State *L )
     int i_fd = -1;
 
     unsigned int i_count = 1;
-    while( pi_fd[0][i_count] != -1 )
+    while( pi_fd[i_count] != -1 )
         i_count++;
 
     struct pollfd ufd[i_count+1];
index 2fa37dc027e30da701d13f2c388f4d0ee58bbe50..f26638eb65f0e34ba0dd88850cb1b437b777bac5 100644 (file)
@@ -105,7 +105,7 @@ static int file_compare( const char **a, const char **b )
     return strcmp( *a, *b );
 }
 
-int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list )
+int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char **ppsz_dir_list )
 {
     int i = 0;
     char *datadir = config_GetUserDir( VLC_DATA_DIR );
@@ -121,25 +121,26 @@ int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list )
     free( datadir );
     i++;
 
+    char *psz_datapath = config_GetDataDir( p_this );
 #   if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
     {
-        const char *psz_vlcpath = config_GetDataDir();
         if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
-                      psz_vlcpath, luadirname )  < 0 )
+                      psz_datapath, luadirname )  < 0 )
             return VLC_ENOMEM;
         i++;
         if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "share" DIR_SEP "lua" DIR_SEP "%s",
-                      psz_vlcpath, luadirname )  < 0 )
+                      psz_datapath, luadirname )  < 0 )
             return VLC_ENOMEM;
         i++;
 
     }
 #   else
     if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
-                  config_GetDataDir (), luadirname ) < 0 )
+                  psz_datapath, luadirname ) < 0 )
         return VLC_ENOMEM;
     i++;
 #   endif
+    free( psz_datapath );
     return VLC_SUCCESS;
 }
 
@@ -169,7 +170,7 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
     char  *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
     char **ppsz_dir;
 
-    i_ret = vlclua_dir_list( luadirname, ppsz_dir_list );
+    i_ret = vlclua_dir_list( p_this, luadirname, ppsz_dir_list );
     if( i_ret != VLC_SUCCESS )
         return i_ret;
     i_ret = VLC_EGENERIC;
index 94d69f6357a5b200bc181491410d47d25467c284..f455f4e0dc84dda7cd3e7c94592c05d9f29a24c2 100644 (file)
@@ -105,7 +105,7 @@ int vlclua_push_ret( lua_State *, int i_error );
 int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname,
         int (*func)(vlc_object_t *, const char *, lua_State *, void *),
         lua_State * L, void * user_data );
-int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list );
+int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char **ppsz_dir_list );
 void vlclua_dir_list_free( char **ppsz_dir_list );
 
 /*****************************************************************************
index 68e27541b2039fe216f988254571ff47047bf76f..575739f24881571e7148919a9af525f523c64d6b 100644 (file)
@@ -115,9 +115,10 @@ static int Open( vlc_object_t *p_this )
     p_sys->app_name = CFSTR( "VLC media player" );
     p_sys->notification_type = CFSTR( "New input playing" );
 
-    const char *data_path = config_GetDataDir ();
+    char *data_path = config_GetDataDir ( p_this );
     char buf[strlen (data_path) + sizeof ("/vlc48x48.png")];
     snprintf (buf, sizeof (buf), "%s/vlc48x48.png", data_path);
+    free( data_path );
     p_sys->default_icon = (CFDataRef) readFile( buf );
 
     playlist_t *p_playlist = pl_Hold( p_intf );
index 1bbcc2073ece5eb37ee8962ef44dac65125e06dc..99453869273ea5ac82fdaa7afd19d5767e7dc5ce 100644 (file)
@@ -224,11 +224,13 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     {
         GError *p_error = NULL;
         char *psz_pixbuf;
-        if( asprintf( &psz_pixbuf, "%s/vlc48x48.png", config_GetDataDir() ) >= 0 )
+        char *psz_data = config_GetDataDir( p_this );
+        if( asprintf( &psz_pixbuf, "%s/vlc48x48.png", psz_data ) >= 0 )
         {
             pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
             free( psz_pixbuf );
         }
+        free( psz_data );
     }
 
     free( psz_arturl );
index 4da4a1068ada5894c3001c100786afd2f8e7c65c..2f81f6f9ee315be5c65cd16886b99b8a9c971d8e 100644 (file)
@@ -428,6 +428,7 @@ SOURCES_libvlc_common = \
        config/intf.c \
        config/keys.c \
        config/cmdline.c \
+       config/dirs.c \
        misc/events.c \
        misc/image.c \
        misc/messages.c \
index 79e041e047fe211e873520873f2d1caffd934e12..2e88f9981cc62b44acd898011216e0fdce1e614d 100644 (file)
@@ -45,6 +45,8 @@ void config_UnsetCallbacks( module_config_t *, size_t );
 int __config_LoadCmdLine   ( vlc_object_t *, int *, const char *[], bool );
 int __config_LoadConfigFile( vlc_object_t *, const char * );
 
+const char *config_GetDataDirDefault( void );
+
 int IsConfigStringType( int type );
 int IsConfigIntegerType (int type);
 static inline int IsConfigFloatType (int type)
diff --git a/src/config/dirs.c b/src/config/dirs.c
new file mode 100644 (file)
index 0000000..d490975
--- /dev/null
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * dirs.c: crossplatform directories configuration
+ *****************************************************************************
+ * Copyright (C) 2009 the VideoLAN team
+ *
+ * Authors: Antoine Cellerier <dionoea at videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+
+#include "../libvlc.h"
+
+#include "configuration.h"
+
+/**
+ * Determines the shared data directory
+ *
+ * @return a string (always succeeds). Needs to be freed.
+ */
+char *__config_GetDataDir( vlc_object_t *p_obj )
+{
+    char *psz_path = config_GetPsz( p_obj, "data-path" );
+    if( psz_path && *psz_path )
+        return psz_path;
+    free( psz_path );
+    return strdup( config_GetDataDirDefault() );
+}
+
index a7d5e5ff20f495748b911d13844d4a1a0ea39559..a411fc67de758717f2861c75b1df39a2410c52bf 100644 (file)
@@ -49,7 +49,7 @@ const char *config_GetConfDir( void )
     return configdir;
 }
 
-const char *config_GetDataDir (void)
+const char *config_GetDataDirDefault (void)
 {
     pthread_once(&once, init_dirs);
     return datadir;
index 65d7aefa88cf3e92afc4ebfa8b7ae04474f3c6ed..ea7410ebaee264ea8eef64306242bf5b50cb2f18 100644 (file)
@@ -43,7 +43,7 @@
 #include <assert.h>
 #include <limits.h>
 
-const char *config_GetDataDir( void )
+const char *config_GetDataDirDefault( void )
 {
     static char path[PATH_MAX] = "";
 #warning FIXME: thread-safety!
index 6f6c0046bc5ea821a639c35e5a9004070829418c..7398cf0ddbdd456b9d220a71e903213440646880 100644 (file)
@@ -40,7 +40,7 @@
  *
  * @return a string (always succeeds).
  */
-const char *config_GetDataDir( void )
+const char *config_GetDataDirDefault( void )
 {
     return DATA_PATH;
 }
index a8a83baa73741ec53ba7e53cc26221439d6b772f..c8b95f2b45494fef0c3c05da539d0519418500ca 100644 (file)
@@ -1120,6 +1120,10 @@ static const char *const ppsz_clock_descriptions[] =
     "Additional path for VLC to look for its modules. You can add " \
     "several paths by concatenating them using \" PATH_SEP \" as separator")
 
+#define DATA_PATH_TEXT N_("Data search path")
+#define DATA_PATH_LONGTEXT N_( \
+    "Override the default data/share search path.")
+
 #define VLM_CONF_TEXT N_("VLM configuration file")
 #define VLM_CONF_LONGTEXT N_( \
     "Read a VLM configuration file as soon as VLM is started." )
@@ -2033,6 +2037,9 @@ vlc_module_begin ()
     add_directory( "plugin-path", NULL, NULL, PLUGIN_PATH_TEXT,
                    PLUGIN_PATH_LONGTEXT, true )
         change_need_restart ()
+    add_directory( "data-path", NULL, NULL, DATA_PATH_TEXT,
+                   DATA_PATH_LONGTEXT, true )
+        change_need_restart ()
 
     set_section( N_("Performance options"), NULL )
     add_obsolete_bool( "minimize-threads" )
index 5b895e41d30f2192ac6c5d69005dd39290410043..080f31e84635e9fe832b0634e75b88d28037bb6f 100644 (file)
@@ -52,7 +52,7 @@ __config_ChainParse
 __config_ExistIntf
 config_FindConfig
 config_GetConfDir
-config_GetDataDir
+__config_GetDataDir
 __config_GetFloat
 config_GetUserDir
 __config_GetInt