]> git.sesse.net Git - vlc/blob - modules/misc/lua/extension.h
99b850a081b27699181a9b5b7f8bbfe92e70f488
[vlc] / modules / misc / lua / extension.h
1 /*****************************************************************************
2  * extension.h: Lua Extensions (meta data, web information, ...)
3  *****************************************************************************
4  * Copyright (C) 2009-2010 VideoLAN and authors
5  * $Id$
6  *
7  * Authors: Jean-Philippe AndrĂ© < jpeg # videolan.org >
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef LUA_EXTENSION_H
25 #define LUA_EXTENSION_H
26
27 #include <vlc_extensions.h>
28 #include <vlc_arrays.h>
29
30 ///< Array of extension_t
31 TYPEDEF_ARRAY( extension_t, array_extension_t );
32
33 /* List of available commands */
34 #define CMD_ACTIVATE    1
35 #define CMD_DEACTIVATE  2
36 #define CMD_TRIGGERMENU 3    /* Arg1 = int*, pointing to id to trigger. free */
37 #define CMD_CLICK       4    /* Arg1 = extension_widget_t* */
38 #define CMD_CLOSE       5
39
40 struct extensions_manager_sys_t
41 {
42     /* List of activated extensions */
43     DECL_ARRAY( extension_t* ) activated_extensions;
44
45     /* Lua specific */
46     lua_State *L;
47
48     vlc_mutex_t lock;
49     bool b_killed;
50 };
51
52 struct extension_sys_t
53 {
54     /* Extension general */
55     int i_capabilities;
56
57     /* Lua specific */
58     lua_State *L;
59
60     /* Thread data */
61     vlc_thread_t thread;
62     vlc_mutex_t command_lock;
63     vlc_mutex_t running_lock;
64     vlc_cond_t wait;
65     bool b_exiting;
66     extensions_manager_t *p_mgr;     ///< Parent
67     /* Queue of commands to execute */
68     struct command_t
69     {
70         int i_command;
71         void *data[10];         ///< Optional void* arguments
72         struct command_t *next; ///< Next command
73     } *command;
74 };
75
76 /* Extensions: manager functions */
77 int Activate( extensions_manager_t *p_mgr, extension_t * );
78 bool IsActivated( extensions_manager_t *p_mgr, extension_t * );
79 int Deactivate( extensions_manager_t *p_mgr, extension_t * );
80 void WaitForDeactivation( extension_t *p_ext );
81 int PushCommand( extension_t *p_ext, int i_command, ... );
82 bool LockExtension( extension_t *p_ext );
83 void UnlockExtension( extension_t *p_ext );
84
85 /* Lua specific functions */
86 extension_t *vlclua_extension_get( lua_State *L );
87 int lua_ExtensionActivate( extensions_manager_t *, extension_t * );
88 int lua_ExtensionDeactivate( extensions_manager_t *, extension_t * );
89 int lua_ExecuteFunction( extensions_manager_t *p_mgr, extension_t *p_ext,
90                          const char *psz_function );
91 int lua_ExtensionWidgetClick( extensions_manager_t *p_mgr,
92                               extension_t *p_ext,
93                               extension_widget_t *p_widget );
94 int lua_ExtensionTriggerMenu( extensions_manager_t *p_mgr,
95                               extension_t *p_ext, int id );
96
97 #endif // LUA_EXTENSION_H