]> git.sesse.net Git - vlc/blobdiff - modules/misc/lua/vlc.c
Remove libvlc->psz_homedir and use config_GetHomeDir() instead
[vlc] / modules / misc / lua / vlc.c
index d1cc1e3215a658d470c2368b2c1f04ceaad72ab3..75adb224461c8937c2b953748bf425ead3526fc0 100644 (file)
@@ -34,6 +34,7 @@
 #endif
 
 #include <vlc/vlc.h>
+#include <vlc_plugin.h>
 #include <vlc_meta.h>
 #include <vlc_charset.h>
 #include <vlc_aout.h>
 #define CONFIG_LONGTEXT N_("Lua interface configuration string. Format is: '[\"<interface module name>\"] = { <option> = <value>, ...}, ...'.")
 
 vlc_module_begin();
-    add_submodule();
-        add_shortcut( "luameta" );
-        set_shortname( N_( "Lua Meta" ) );
-        set_description( _("Fetch metadata using lua scripts") );
-        set_capability( "meta fetcher", 10 );
-        set_callbacks( E_(FindMeta), NULL );
     add_submodule();
         set_shortname( N_( "Lua Art" ) );
-        set_description( _("Fetch artwork using lua scripts") );
+        set_description( N_("Fetch artwork using lua scripts") );
         set_capability( "art finder", 10 );
-        set_callbacks( E_(FindArt), NULL );
+        set_callbacks( FindArt, NULL );
     add_submodule();
         add_shortcut( "luaplaylist" );
         set_category( CAT_INPUT );
         set_subcategory( SUBCAT_INPUT_DEMUX );
-        set_shortname( _("Lua Playlist") );
-        set_description( _("Lua Playlist Parser Interface") );
+        set_shortname( N_("Lua Playlist") );
+        set_description( N_("Lua Playlist Parser Interface") );
         set_capability( "demux", 2 );
-        set_callbacks( E_(Import_LuaPlaylist), E_(Close_LuaPlaylist) );
+        set_callbacks( Import_LuaPlaylist, Close_LuaPlaylist );
     add_submodule();
         add_shortcut( "luaintf" );
         add_shortcut( "luarc" );
@@ -84,13 +79,13 @@ vlc_module_begin();
         /* add_shortcut( "telnet" ); */
         add_shortcut( "luahttp" );
         /* add_shortcut( "http" ); */
-        set_description( _("Lua Interface Module") );
+        set_description( N_("Lua Interface Module") );
         set_capability( "interface", 0 );
         add_string( "lua-intf", "dummy", NULL,
                     INTF_TEXT, INTF_LONGTEXT, false );
         add_string( "lua-config", "", NULL,
                     CONFIG_TEXT, CONFIG_LONGTEXT, false );
-        set_callbacks( E_(Open_LuaIntf), E_(Close_LuaIntf) );
+        set_callbacks( Open_LuaIntf, Close_LuaIntf );
 vlc_module_end();
 
 /*****************************************************************************
@@ -165,17 +160,21 @@ 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 )
 {
-    lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_configdir );
+    char *dir = config_GetUserConfDir();
+    lua_pushstring( L, dir );
+    free( dir );
     return 1;
 }
 int vlclua_cachedir( lua_State *L )
 {
-    lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_cachedir );
+    char *dir = config_GetCacheDir();
+    lua_pushstring( L, dir );
+    free( dir );
     return 1;
 }
 int vlclua_datadir_list( lua_State *L )
@@ -260,7 +259,7 @@ int vlclua_stream_read( lua_State *L )
 {
     stream_t * p_stream;
     int n;
-    byte_t *p_read;
+    uint8_t *p_read;
     int i_read;
     p_stream = (stream_t *)luaL_checklightuserdata( L, 1 );
     n = luaL_checkint( L, 2 );
@@ -406,9 +405,17 @@ int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
                      char **ppsz_dir_list )
 {
     int i = 0;
+    char *datadir = config_GetUserDataDir();
+    if( datadir == NULL )
+        return VLC_ENOMEM;
+
     if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
-                   p_this->p_libvlc->psz_datadir, luadirname ) < 0 )
+                   datadir, luadirname ) < 0 )
+    {
+        free( datadir );
         return VLC_ENOMEM;
+    }
+    free( datadir );
     i++;
 
 #   if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
@@ -418,17 +425,10 @@ int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
                       psz_vlcpath, luadirname )  < 0 )
             return VLC_ENOMEM;
         i++;
-#       ifdef WIN32
-        if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "scripts" DIR_SEP "%s",
+        if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "share" DIR_SEP "lua" DIR_SEP "%s",
                       psz_vlcpath, luadirname )  < 0 )
             return VLC_ENOMEM;
         i++;
-#       else
-         if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "share" DIR_SEP "lua" DIR_SEP "%s",
-                      psz_vlcpath, luadirname )  < 0 )
-            return VLC_ENOMEM;
-        i++;
-#       endif
 
     }
 #   else
@@ -466,7 +466,6 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
 {
     int i_ret = VLC_EGENERIC;
 
-    DIR   *dir           = NULL;
     char **ppsz_filelist = NULL;
     char **ppsz_fileend  = NULL;
     char **ppsz_file;
@@ -493,16 +492,8 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
             ppsz_filelist = NULL;
         }
 
-        if( dir )
-        {
-            closedir( dir );
-        }
-
         msg_Dbg( p_this, "Trying Lua scripts in %s", *ppsz_dir );
-        dir = utf8_opendir( *ppsz_dir );
-
-        if( !dir ) continue;
-        i_files = utf8_loaddir( dir, &ppsz_filelist, file_select,
+        i_files = utf8_scandir( *ppsz_dir, &ppsz_filelist, file_select,
                                 file_compare );
         if( i_files < 1 ) continue;
         ppsz_fileend = ppsz_filelist + i_files;
@@ -534,8 +525,6 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
     for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
         free( *ppsz_dir );
 
-    if( dir ) closedir( dir );
-
     return i_ret;
 }