vlc_interaction.h 6.33 KB
Newer Older
1
2
3
/*****************************************************************************
 * vlc_interaction.h: structures and function for user interaction
 *****************************************************************************
4
5
 * Copyright (C) 2005-2006 VideoLAN
 * $Id$
6
 *
7
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Felix Kühne <fkuehne@videolan.org>
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
dionoea's avatar
dionoea committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
24
25
26
27
28
29
 *****************************************************************************/

/**
 * This structure describes an interaction widget
 */
struct user_widget_t
{
dionoea's avatar
dionoea committed
30
31
    int             i_type;             ///< Type identifier;
    char           *psz_text;           ///< Free text
32
33
34
35
36
37
38
39
40

    vlc_value_t     val;
};

/**
 * Possible widget types
 */
enum
{
dionoea's avatar
dionoea committed
41
42
43
    WIDGET_TEXT,                        ///< Text display
    WIDGET_PROGRESS,                    ///< A progress bar
    WIDGET_INPUT_TEXT                   ///< Input (backed up by a variable)
44
45
46
47
48
49
50
};

/**
 * This structure describes a piece of interaction with the user
 */
struct interaction_dialog_t
{
dionoea's avatar
dionoea committed
51
52
53
54
    int             i_id;               ///< Unique ID
    int             i_type;             ///< Type identifier
    char           *psz_title;          ///< Title
    char           *psz_description;    ///< Descriptor string
55

56
57
    char           *psz_returned[1];    ///< returned responses from the user

58
59
    vlc_value_t     val;                ///< a value coming from core for dialogue

dionoea's avatar
dionoea committed
60
61
    int             i_widgets;          ///< Number of dialog widgets
    user_widget_t **pp_widgets;         ///< Dialog widgets
62

dionoea's avatar
dionoea committed
63
    void *          p_private;          ///< Private interface data
64

dionoea's avatar
dionoea committed
65
66
67
68
    int             i_status;           ///< Dialog status;
    int             i_action;           ///< Action to perform;
    int             i_flags;            ///< Misc flags
    int             i_return;           ///< Return status
zorglub's avatar
zorglub committed
69

dionoea's avatar
dionoea committed
70
71
    interaction_t  *p_interaction;      ///< Parent interaction object
    vlc_object_t   *p_parent;           ///< The vlc object that asked
zorglub's avatar
zorglub committed
72
73
74
75
76
77
                                        //for interaction
};

/**
 * Possible flags . Reusable and button types
 */
78
79
80
81
82
83
84
#define DIALOG_REUSABLE             0x01
#define DIALOG_OK_CANCEL            0x02
#define DIALOG_YES_NO               0x04
#define DIALOG_YES_NO_CANCEL        0x04
#define DIALOG_CLEAR_NOSHOW         0x08
#define DIALOG_GOT_ANSWER           0x10
#define DIALOG_LOGIN_PW_OK_CANCEL   0x20
85
#define DIALOG_USER_PROGRESS        0x40
86
#define DIALOG_PSZ_INPUT_OK_CANCEL      0x80
zorglub's avatar
zorglub committed
87
88
89
90
91
92
93
94
95
96

/**
 * Possible return codes
 */
enum
{
    DIALOG_DEFAULT,
    DIALOG_OK_YES,
    DIALOG_NO,
    DIALOG_CANCELLED
zorglub's avatar
zorglub committed
97
98
99
100
101
102
103
};

/**
 * Possible status
 */
enum
{
dionoea's avatar
dionoea committed
104
105
106
107
108
109
110
    NEW_DIALOG,                 ///< Just created
    SENT_DIALOG,                ///< Sent to interface
    UPDATED_DIALOG,             ///< Update to send
    ANSWERED_DIALOG,            ///< Got "answer"
    HIDING_DIALOG,              ///< Hiding requested
    HIDDEN_DIALOG,              ///< Now hidden. Requesting destruction
    DESTROYED_DIALOG,           ///< Interface has destroyed it
111
112
};

zorglub's avatar
zorglub committed
113
114
115
116
117
/**
 * Possible interaction types
 */
enum
{
dionoea's avatar
dionoea committed
118
119
120
    INTERACT_PROGRESS,          ///< Progress bar (in the main interface ?)
    INTERACT_DIALOG_ONEWAY,     ///< Dialog box without feedback
    INTERACT_DIALOG_TWOWAY,     ///< Dialog box with feedback
zorglub's avatar
zorglub committed
121
122
123
124
125
126
127
};

/**
 * Predefined reusable dialogs
 */
enum
{
zorglub's avatar
zorglub committed
128
    DIALOG_FIRST,
zorglub's avatar
zorglub committed
129
    DIALOG_ERRORS,
zorglub's avatar
zorglub committed
130
131
132
133

    DIALOG_LAST_PREDEFINED,
};

134
135
136
137
138
139
140
141
/**
 * This structure contains the active interaction dialogs, and is
 * used by teh manager
 */
struct interaction_t
{
    VLC_COMMON_MEMBERS

dionoea's avatar
dionoea committed
142
143
    int                         i_dialogs;      ///< Number of dialogs
    interaction_dialog_t      **pp_dialogs;     ///< Dialogs
144

dionoea's avatar
dionoea committed
145
    intf_thread_t              *p_intf;         ///< Interface to use
zorglub's avatar
zorglub committed
146

dionoea's avatar
dionoea committed
147
    int                         i_last_id;      ///< Last attributed ID
zorglub's avatar
zorglub committed
148
};
149
/**
zorglub's avatar
zorglub committed
150
 * Possible actions
151
152
153
 */
enum
{
zorglub's avatar
zorglub committed
154
155
    INTERACT_NEW,
    INTERACT_UPDATE,
zorglub's avatar
zorglub committed
156
157
    INTERACT_HIDE,
    INTERACT_DESTROY
158
159
};

zorglub's avatar
zorglub committed
160
161
162
163
/***************************************************************************
 * Exported symbols
 ***************************************************************************/

164
165
166
#define intf_Interact( a,b ) __intf_Interact( VLC_OBJECT(a), b )
VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) );

zorglub's avatar
zorglub committed
167
#define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),c,d, ## e )
zorglub's avatar
zorglub committed
168
VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, const char*, const char*, ...) );
dionoea's avatar
dionoea committed
169
#define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e)
zorglub's avatar
zorglub committed
170
VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) );
dionoea's avatar
dionoea committed
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
174
#define intf_UserOkayCancel( a, b, c ) __intf_UserOkayCancel( VLC_OBJECT(a),b,c )
VLC_EXPORT( int, __intf_UserOkayCancel,( vlc_object_t*, const char*, const char*) );
175

dionoea's avatar
dionoea committed
176
#define intf_UserProgress( a, b, c, d ) __intf_UserProgress( VLC_OBJECT(a),b,c, d )
zorglub's avatar
zorglub committed
177
178
VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float) );

dionoea's avatar
ooops    
dionoea committed
179
#define intf_UserProgressUpdate( a, b, c, d ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c, d )
zorglub's avatar
zorglub committed
180
181
VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float) );

182
183
184
#define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d )
VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) );

zorglub's avatar
zorglub committed
185
186
187
#define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b )
VLC_EXPORT( void, __intf_UserHide,( vlc_object_t *, int ));

zorglub's avatar
zorglub committed
188
189
VLC_EXPORT( void, intf_InteractionManage,( playlist_t *) );
VLC_EXPORT( void, intf_InteractionDestroy,( interaction_t *) );