#include <vlc_common.h>
#include <vlc_input.h>
+#include <vlc_interface.h>
#include <vlc_events.h>
#include <vlc_dialog.h>
* Extensions capabilities
* Note: #define and ppsz_capabilities must be in sync
*/
+static const char caps[][20] = {
#define EXT_HAS_MENU (1 << 0) ///< Hook: menu
-#define EXT_TRIGGER_ONLY (1 << 1) ///< Hook: trigger. Not activable
-#define EXT_INPUT_LISTENER (1 << 2) ///< Hook: input_changed
-#define EXT_META_LISTENER (1 << 3) ///< Hook: meta_changed
-#define EXT_PLAYING_LISTENER (1 << 4) ///< Hook: status_changed
-
-static const char* const ppsz_capabilities[] = {
"menu",
+#define EXT_TRIGGER_ONLY (1 << 1) ///< Hook: trigger. Not activable
"trigger",
+#define EXT_INPUT_LISTENER (1 << 2) ///< Hook: input_changed
"input-listener",
+#define EXT_META_LISTENER (1 << 3) ///< Hook: meta_changed
"meta-listener",
+#define EXT_PLAYING_LISTENER (1 << 4) ///< Hook: status_changed
"playing-listener",
- NULL
};
#define WATCH_TIMER_PERIOD (10 * CLOCK_FREQ) ///< 10s period for the timer
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 );
**/
int Open_Extension( vlc_object_t *p_this )
{
- msg_Dbg( p_this, "Opening EXPERIMENTAL Lua Extension module" );
+ msg_Dbg( p_this, "Opening Lua Extension module" );
extensions_manager_t *p_mgr = ( extensions_manager_t* ) p_this;
FOREACH_END()
ARRAY_RESET( p_mgr->extensions );
+
+ var_DelCallback( p_this, "dialog-event",
+ vlclua_extension_dialog_callback, NULL );
}
/**
* @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;
{
/* Key is at index -2 and value at index -1. Discard key */
const char *psz_cap = luaL_checkstring( L, -1 );
- int i_cap = 0;
bool b_ok = false;
/* Find this capability's flag */
- for( const char *iter = *ppsz_capabilities;
- iter != NULL;
- iter = ppsz_capabilities[ ++i_cap ])
+ for( size_t i = 0; i < sizeof(caps)/sizeof(caps[0]); i++ )
{
- if( !strcmp( iter, psz_cap ) )
+ if( !strcmp( caps[i], psz_cap ) )
{
/* Flag it! */
- p_ext->p_sys->i_capabilities |= 1 << i_cap;
+ p_ext->p_sys->i_capabilities |= 1 << i;
b_ok = true;
break;
}
}
break;
}
+ case EXTENSION_META_CHANGED:
+ {
+ extension_t *p_ext;
+ p_ext = ( extension_t* ) va_arg( args, extension_t* );
+ PushCommand( p_ext, CMD_UPDATE_META );
+ break;
+ }
default:
msg_Warn( p_mgr, "Control '%d' not yet implemented in Extension",
i_control );
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 )
{
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;
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 );
if( p_ext )
{
/* Load more libraries */
- luaopen_acl( L );
luaopen_config( L );
luaopen_dialog( L, p_ext );
luaopen_input( L );
- luaopen_md5( L );
luaopen_msg( L );
- luaopen_misc( 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 );
luaopen_vlm( L );
luaopen_volume( L );
luaopen_xml( L );
+#if defined(_WIN32) && !VLC_WINSTORE_APP
+ luaopen_win( L );
+#endif
/* Register extension specific functions */
lua_getglobal( L, "vlc" );
}
else
{
- if( vlclua_add_modules_path( p_mgr, L, p_ext->psz_name ) )
+ if( vlclua_add_modules_path( L, p_ext->psz_name ) )
{
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;
}
{
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;
}
/* 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;
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 )
{