]> git.sesse.net Git - vlc/blob - include/vlc_interaction.h
1873d9afa543efca49d9dea49e634f62e88973c6
[vlc] / include / vlc_interaction.h
1 /*****************************************************************************
2  * vlc_interaction.h: structures and function for user interaction
3  *****************************************************************************
4  * Copyright (C) 2005-2006 VideoLAN
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Felix Kühne <fkuehne@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /**
26  * This structure describes an interaction widget
27  */
28 struct user_widget_t
29 {
30     int             i_type;             ///< Type identifier;
31     char           *psz_text;           ///< Free text
32
33     vlc_value_t     val;
34 };
35
36 /**
37  * Possible widget types
38  */
39 enum
40 {
41     WIDGET_TEXT,                        ///< Text display
42     WIDGET_PROGRESS,                    ///< A progress bar
43     WIDGET_INPUT_TEXT                   ///< Input (backed up by a variable)
44 };
45
46 /**
47  * This structure describes a piece of interaction with the user
48  */
49 struct interaction_dialog_t
50 {
51     int             i_id;               ///< Unique ID
52     int             i_type;             ///< Type identifier
53     char           *psz_title;          ///< Title
54     char           *psz_description;    ///< Descriptor string
55
56     char           *psz_returned[1];    ///< returned responses from the user
57
58     vlc_value_t     val;                ///< a value coming from core for dialogue
59
60     int             i_widgets;          ///< Number of dialog widgets
61     user_widget_t **pp_widgets;         ///< Dialog widgets
62
63     void *          p_private;          ///< Private interface data
64
65     int             i_status;           ///< Dialog status;
66     int             i_action;           ///< Action to perform;
67     int             i_flags;            ///< Misc flags
68     int             i_return;           ///< Return status
69
70     interaction_t  *p_interaction;      ///< Parent interaction object
71     vlc_object_t   *p_parent;           ///< The vlc object that asked
72                                         //for interaction
73 };
74
75 /**
76  * Possible flags . Reusable and button types
77  */
78 #define DIALOG_REUSABLE             0x01
79 #define DIALOG_OK_CANCEL            0x02
80 #define DIALOG_YES_NO               0x04
81 #define DIALOG_YES_NO_CANCEL        0x04
82 #define DIALOG_CLEAR_NOSHOW         0x08
83 #define DIALOG_GOT_ANSWER           0x10
84 #define DIALOG_LOGIN_PW_OK_CANCEL   0x20
85 #define DIALOG_USER_PROGRESS        0x40
86 #define DIALOG_PSZ_INPUT_OK_CANCEL      0x80
87
88 /**
89  * Possible return codes
90  */
91 enum
92 {
93     DIALOG_DEFAULT,
94     DIALOG_OK_YES,
95     DIALOG_NO,
96     DIALOG_CANCELLED
97 };
98
99 /**
100  * Possible status
101  */
102 enum
103 {
104     NEW_DIALOG,                 ///< Just created
105     SENT_DIALOG,                ///< Sent to interface
106     UPDATED_DIALOG,             ///< Update to send
107     ANSWERED_DIALOG,            ///< Got "answer"
108     HIDING_DIALOG,              ///< Hiding requested
109     HIDDEN_DIALOG,              ///< Now hidden. Requesting destruction
110     DESTROYED_DIALOG,           ///< Interface has destroyed it
111 };
112
113 /**
114  * Possible interaction types
115  */
116 enum
117 {
118     INTERACT_PROGRESS,          ///< Progress bar (in the main interface ?)
119     INTERACT_DIALOG_ONEWAY,     ///< Dialog box without feedback
120     INTERACT_DIALOG_TWOWAY,     ///< Dialog box with feedback
121 };
122
123 /**
124  * Predefined reusable dialogs
125  */
126 enum
127 {
128     DIALOG_FIRST,
129     DIALOG_ERRORS,
130
131     DIALOG_LAST_PREDEFINED,
132 };
133
134 /**
135  * This structure contains the active interaction dialogs, and is
136  * used by teh manager
137  */
138 struct interaction_t
139 {
140     VLC_COMMON_MEMBERS
141
142     int                         i_dialogs;      ///< Number of dialogs
143     interaction_dialog_t      **pp_dialogs;     ///< Dialogs
144
145     intf_thread_t              *p_intf;         ///< Interface to use
146
147     int                         i_last_id;      ///< Last attributed ID
148 };
149 /**
150  * Possible actions
151  */
152 enum
153 {
154     INTERACT_NEW,
155     INTERACT_UPDATE,
156     INTERACT_HIDE,
157     INTERACT_DESTROY
158 };
159
160 /***************************************************************************
161  * Exported symbols
162  ***************************************************************************/
163
164 #define intf_Interact( a,b ) __intf_Interact( VLC_OBJECT(a), b )
165 VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) );
166
167 #define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),c,d, ## e )
168 VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, const char*, const char*, ...) );
169 #define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e)
170 VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) );
171 #define intf_UserYesNo( a, b, c ) __intf_UserYesNo( VLC_OBJECT(a),b,c )
172 VLC_EXPORT( int, __intf_UserYesNo,( vlc_object_t*, const char*, const char*) );
173 #define intf_UserOkayCancel( a, b, c ) __intf_UserOkayCancel( VLC_OBJECT(a),b,c )
174 VLC_EXPORT( int, __intf_UserOkayCancel,( vlc_object_t*, const char*, const char*) );
175
176 #define intf_UserProgress( a, b, c, d ) __intf_UserProgress( VLC_OBJECT(a),b,c, d )
177 VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float) );
178
179 #define intf_UserProgressUpdate( a, b, c, d ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c, d )
180 VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) );
181
182 #define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d )
183 VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) );
184
185 #define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b )
186 VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int ));
187
188 VLC_EXPORT( void, intf_InteractionManage,( playlist_t *) );
189 VLC_EXPORT( void, intf_InteractionDestroy,( interaction_t *) );