]> git.sesse.net Git - vlc/blobdiff - modules/lua/extension.c
Remove WPL module
[vlc] / modules / lua / extension.c
index 79843960a9f762fe06d515230276f9e5a01547e5..5958af15e41f8db28068e1961317f0ed018203cf 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <vlc_common.h>
 #include <vlc_input.h>
+#include <vlc_interface.h>
 #include <vlc_events.h>
 #include <vlc_dialog.h>
 
@@ -49,7 +50,7 @@ static const luaL_Reg p_reg[] =
  * Extensions capabilities
  * Note: #define and ppsz_capabilities must be in sync
  */
-static const char const caps[][20] = {
+static const char caps[][20] = {
 #define EXT_HAS_MENU          (1 << 0)   ///< Hook: menu
     "menu",
 #define EXT_TRIGGER_ONLY      (1 << 1)   ///< Hook: trigger. Not activable
@@ -66,7 +67,7 @@ static const char const caps[][20] = {
 
 static int ScanExtensions( extensions_manager_t *p_this );
 static int ScanLuaCallback( vlc_object_t *p_this, const char *psz_script,
-                            void *dummy );
+                            const struct luabatch_context_t * );
 static int Control( extensions_manager_t *, int, va_list );
 static int GetMenuEntries( extensions_manager_t *p_mgr, extension_t *p_ext,
                     char ***pppsz_titles, uint16_t **ppi_ids );
@@ -274,7 +275,7 @@ static int vlclua_extension_require( lua_State *L )
  * @param dummy: unused
  **/
 int ScanLuaCallback( vlc_object_t *p_this, const char *psz_filename,
-                     void *dummy )
+                     const struct luabatch_context_t *dummy )
 {
     VLC_UNUSED(dummy);
     extensions_manager_t *p_mgr = ( extensions_manager_t* ) p_this;
@@ -649,6 +650,8 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
     if( !p_ext->p_sys->L )
         return VLC_SUCCESS;
 
+    vlclua_fd_interrupt( &p_ext->p_sys->dtable );
+
     // Unset and release input objects
     if( p_ext->p_sys->p_input )
     {
@@ -665,6 +668,7 @@ int lua_ExtensionDeactivate( extensions_manager_t *p_mgr, extension_t *p_ext )
     int i_ret = lua_ExecuteFunction( p_mgr, p_ext, "deactivate", LUA_END );
 
     /* Clear Lua State */
+    vlclua_fd_cleanup( &p_ext->p_sys->dtable );
     lua_close( p_ext->p_sys->L );
     p_ext->p_sys->L = NULL;
 
@@ -808,6 +812,8 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
             return NULL;
         }
         vlclua_set_this( L, p_mgr );
+        vlclua_set_playlist_internal( L,
+            pl_Get((intf_thread_t *)(p_mgr->p_parent)) );
         vlclua_extension_set( L, p_ext );
 
         luaL_openlibs( L );
@@ -821,11 +827,15 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
             luaopen_dialog( L, p_ext );
             luaopen_input( L );
             luaopen_msg( L );
-            luaopen_net( L );
+            if( vlclua_fd_init( L, &p_ext->p_sys->dtable ) )
+            {
+                lua_close( L );
+                return NULL;
+            }
             luaopen_object( L );
             luaopen_osd( L );
             luaopen_playlist( L );
-            luaopen_sd( L );
+            luaopen_sd_intf( L );
             luaopen_stream( L );
             luaopen_strings( L );
             luaopen_variables( L );
@@ -856,6 +866,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
                 {
                     msg_Warn( p_mgr, "Error while setting the module "
                               "search path for %s", p_ext->psz_name );
+                    vlclua_fd_cleanup( &p_ext->p_sys->dtable );
                     lua_close( L );
                     return NULL;
                 }
@@ -865,6 +876,7 @@ static lua_State* GetLuaState( extensions_manager_t *p_mgr,
             {
                 msg_Warn( p_mgr, "Error loading script %s: %s", p_ext->psz_name,
                           lua_tostring( L, lua_gettop( L ) ) );
+                vlclua_fd_cleanup( &p_ext->p_sys->dtable );
                 lua_close( L );
                 return NULL;
             }
@@ -1041,7 +1053,10 @@ static int TriggerExtension( extensions_manager_t *p_mgr,
 
     /* Close lua state for trigger-only extensions */
     if( p_ext->p_sys->L )
+    {
+        vlclua_fd_cleanup( &p_ext->p_sys->dtable );
         lua_close( p_ext->p_sys->L );
+    }
     p_ext->p_sys->L = NULL;
 
     return i_ret;
@@ -1207,21 +1222,20 @@ static void WatchTimerCallback( void *data )
 
     vlc_mutex_lock( &p_ext->p_sys->command_lock );
 
-    // Do we have a pending Deactivate command?
-    if( ( p_ext->p_sys->command &&
-          p_ext->p_sys->command->i_command == CMD_DEACTIVATE )
-        || ( p_ext->p_sys->command->next
-             && p_ext->p_sys->command->next->i_command == CMD_DEACTIVATE) )
-    {
-        if( p_ext->p_sys->progress )
-        {
-            dialog_ProgressDestroy( p_ext->p_sys->progress );
-            p_ext->p_sys->progress = NULL;
+    for( struct command_t *cmd = p_ext->p_sys->command;
+         cmd != NULL;
+         cmd = cmd->next )
+        if( cmd->i_command == CMD_DEACTIVATE )
+        {   /* We have a pending Deactivate command... */
+            if( p_ext->p_sys->progress )
+            {
+                dialog_ProgressDestroy( p_ext->p_sys->progress );
+                p_ext->p_sys->progress = NULL;
+            }
+            vlc_mutex_unlock( &p_ext->p_sys->command_lock );
+            KillExtension( p_mgr, p_ext );
+            return;
         }
-        vlc_mutex_unlock( &p_ext->p_sys->command_lock );
-        KillExtension( p_mgr, p_ext );
-        return;
-    }
 
     if( !p_ext->p_sys->progress )
     {