VLC 4.0.0-dev
Loading...
Searching...
No Matches
libvlc_dialog.h
Go to the documentation of this file.
1/*****************************************************************************
2 * libvlc_dialog.h: libvlc dialog API
3 *****************************************************************************
4 * Copyright © 2016 VLC authors and VideoLAN
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20
21#ifndef LIBVLC_DIALOG_H
22#define LIBVLC_DIALOG_H 1
23
24#include <stdbool.h>
25
26# ifdef __cplusplus
27extern "C" {
28# endif
29
31
32/**
33 * @defgroup libvlc_dialog LibVLC dialog
34 * @ingroup libvlc
35 * @{
36 * @file
37 * LibVLC dialog external API
38 */
39
46
47/**
48 * Dialog callbacks to be implemented
49 *
50 * @attention starting with vlc 4.0.0 the error callback (pf_display_error) is
51 * no longer part of this struct and need to be registered separately
52 * using @a libvlc_dialog_set_error_callback
53 *
54 * @see libvlc_dialog_set_error_callback
55 */
56typedef struct libvlc_dialog_cbs
57{
58 /**
59 * Version of struct libvlc_dialog_cbs
60 */
61 uint32_t version;
62
63 /**
64 * Called when a login dialog needs to be displayed
65 *
66 * You can interact with this dialog by calling libvlc_dialog_post_login()
67 * to post an answer or libvlc_dialog_dismiss() to cancel this dialog.
68 *
69 * @note to receive this callback, libvlc_dialog_cbs.pf_cancel should not be
70 * NULL.
71 *
72 * @param p_data opaque pointer for the callback
73 * @param p_id id used to interact with the dialog
74 * @param psz_title title of the dialog
75 * @param psz_text text of the dialog
76 * @param psz_default_username user name that should be set on the user form
77 * @param b_ask_store if true, ask the user if he wants to save the
78 * credentials
79 */
80 void (*pf_display_login)(void *p_data, libvlc_dialog_id *p_id,
81 const char *psz_title, const char *psz_text,
82 const char *psz_default_username,
83 bool b_ask_store);
84
85 /**
86 * Called when a question dialog needs to be displayed
87 *
88 * You can interact with this dialog by calling libvlc_dialog_post_action()
89 * to post an answer or libvlc_dialog_dismiss() to cancel this dialog.
90 *
91 * @note to receive this callback, libvlc_dialog_cbs.pf_cancel should not be
92 * NULL.
93 *
94 * @param p_data opaque pointer for the callback
95 * @param p_id id used to interact with the dialog
96 * @param psz_title title of the dialog
97 * @param psz_text text of the dialog
98 * @param i_type question type (or severity) of the dialog
99 * @param psz_cancel text of the cancel button
100 * @param psz_action1 text of the first button, if NULL, don't display this
101 * button
102 * @param psz_action2 text of the second button, if NULL, don't display
103 * this button
104 */
105 void (*pf_display_question)(void *p_data, libvlc_dialog_id *p_id,
106 const char *psz_title, const char *psz_text,
108 const char *psz_cancel, const char *psz_action1,
109 const char *psz_action2);
110
111 /**
112 * Called when a progress dialog needs to be displayed
113 *
114 * If cancellable (psz_cancel != NULL), you can cancel this dialog by
115 * calling libvlc_dialog_dismiss()
116 *
117 * @note to receive this callback, libvlc_dialog_cbs.pf_cancel and
118 * libvlc_dialog_cbs.pf_update_progress should not be NULL.
119 *
120 * @param p_data opaque pointer for the callback
121 * @param p_id id used to interact with the dialog
122 * @param psz_title title of the dialog
123 * @param psz_text text of the dialog
124 * @param b_indeterminate true if the progress dialog is indeterminate
125 * @param f_position initial position of the progress bar (between 0.0 and
126 * 1.0)
127 * @param psz_cancel text of the cancel button, if NULL the dialog is not
128 * cancellable
129 */
130 void (*pf_display_progress)(void *p_data, libvlc_dialog_id *p_id,
131 const char *psz_title, const char *psz_text,
132 bool b_indeterminate, float f_position,
133 const char *psz_cancel);
134
135 /**
136 * Called when a displayed dialog needs to be cancelled
137 *
138 * The implementation must call libvlc_dialog_dismiss() to really release
139 * the dialog.
140 *
141 * @param p_data opaque pointer for the callback
142 * @param p_id id of the dialog
143 */
144 void (*pf_cancel)(void *p_data, libvlc_dialog_id *p_id);
145
146 /**
147 * Called when a progress dialog needs to be updated
148 *
149 * @param p_data opaque pointer for the callback
150 * @param p_id id of the dialog
151 * @param f_position osition of the progress bar (between 0.0 and 1.0)
152 * @param psz_text new text of the progress dialog
153 */
154 void (*pf_update_progress)(void *p_data, libvlc_dialog_id *p_id,
155 float f_position, const char *psz_text);
157
158
159/**
160 * Called when an error message needs to be displayed
161 *
162 * @param p_data opaque pointer for the callback
163 * @param psz_title title of the dialog
164 * @param psz_text text of the dialog
165 */
166typedef void (*libvlc_dialog_error_cbs)(void *p_data, const char *psz_title, const char *psz_text);
167
168/**
169 * Register callbacks in order to handle VLC dialogs
170 *
171 * @version LibVLC 3.0.0 and later.
172 *
173 * @param p_instance the libvlc instance to attach the dialog callbacks to
174 * @param p_cbs a pointer to callbacks, or NULL to unregister callbacks.
175 * @param p_data opaque pointer for the callback
176 */
177LIBVLC_API void
179 const libvlc_dialog_cbs *p_cbs, void *p_data);
180
181/*
182* Register callback in order to handle VLC error messages
183*
184* @version LibVLC 4.0.0 and later.
185*
186* @param p_cbs a pointer to callback, or NULL to unregister callback.
187* @param p_data opaque pointer for the callback
188*/
189LIBVLC_API void
191 libvlc_dialog_error_cbs p_cbs, void *p_data);
192
193/**
194 * Associate an opaque pointer with the dialog id
195 *
196 * @version LibVLC 3.0.0 and later.
197 */
198LIBVLC_API void
200
201/**
202 * Return the opaque pointer associated with the dialog id
203 * \see libvlc_dialog_set_context
204 * @version LibVLC 3.0.0 and later.
205 */
206LIBVLC_API void *
208
209/**
210 * Post a login answer
211 *
212 * After this call, p_id won't be valid anymore
213 *
214 * @see libvlc_dialog_cbs.pf_display_login
215 *
216 * @version LibVLC 3.0.0 and later.
217 *
218 * @param p_id id of the dialog
219 * @param psz_username valid and non empty string
220 * @param psz_password valid string (can be empty)
221 * @param b_store if true, store the credentials
222 * @return 0 on success, or -1 on error
223 */
224LIBVLC_API int
225libvlc_dialog_post_login(libvlc_dialog_id *p_id, const char *psz_username,
226 const char *psz_password, bool b_store);
227
228/**
229 * Post a question answer
230 *
231 * After this call, p_id won't be valid anymore
232 *
233 * @see libvlc_dialog_cbs.pf_display_question
234 *
235 * @version LibVLC 3.0.0 and later.
236 *
237 * @param p_id id of the dialog
238 * @param i_action 1 for action1, 2 for action2
239 * @return 0 on success, or -1 on error
240 */
241LIBVLC_API int
243
244/**
245 * Dismiss a dialog
246 *
247 * After this call, p_id won't be valid anymore
248 *
249 * @see libvlc_dialog_cbs.pf_cancel
250 *
251 * @version LibVLC 3.0.0 and later.
252 *
253 * @param p_id id of the dialog
254 * @return 0 on success, or -1 on error
255 */
256LIBVLC_API int
258
259/** @} */
260
261# ifdef __cplusplus
262}
263# endif
264
265#endif /* LIBVLC_DIALOG_H */
struct libvlc_instance_t libvlc_instance_t
This structure is opaque.
Definition libvlc.h:76
LIBVLC_API void libvlc_dialog_set_error_callback(libvlc_instance_t *p_instance, libvlc_dialog_error_cbs p_cbs, void *p_data)
libvlc_dialog_question_type
Definition libvlc_dialog.h:41
LIBVLC_API int libvlc_dialog_dismiss(libvlc_dialog_id *p_id)
Dismiss a dialog.
LIBVLC_API int libvlc_dialog_post_action(libvlc_dialog_id *p_id, int i_action)
Post a question answer.
LIBVLC_API void libvlc_dialog_set_callbacks(libvlc_instance_t *p_instance, const libvlc_dialog_cbs *p_cbs, void *p_data)
Register callbacks in order to handle VLC dialogs.
LIBVLC_API void libvlc_dialog_set_context(libvlc_dialog_id *p_id, void *p_context)
Associate an opaque pointer with the dialog id.
void(* libvlc_dialog_error_cbs)(void *p_data, const char *psz_title, const char *psz_text)
Called when an error message needs to be displayed.
Definition libvlc_dialog.h:166
LIBVLC_API int libvlc_dialog_post_login(libvlc_dialog_id *p_id, const char *psz_username, const char *psz_password, bool b_store)
Post a login answer.
LIBVLC_API void * libvlc_dialog_get_context(libvlc_dialog_id *p_id)
Return the opaque pointer associated with the dialog id.
@ LIBVLC_DIALOG_QUESTION_WARNING
Definition libvlc_dialog.h:43
@ LIBVLC_DIALOG_QUESTION_CRITICAL
Definition libvlc_dialog.h:44
@ LIBVLC_DIALOG_QUESTION_NORMAL
Definition libvlc_dialog.h:42
#define LIBVLC_API
Definition libvlc.h:42
int i_type
Definition httpd.c:1299
struct libvlc_dialog_id libvlc_dialog_id
Definition libvlc_dialog.h:30
Dialog callbacks to be implemented.
Definition libvlc_dialog.h:57
void(* pf_display_login)(void *p_data, libvlc_dialog_id *p_id, const char *psz_title, const char *psz_text, const char *psz_default_username, bool b_ask_store)
Called when a login dialog needs to be displayed.
Definition libvlc_dialog.h:80
void(* pf_update_progress)(void *p_data, libvlc_dialog_id *p_id, float f_position, const char *psz_text)
Called when a progress dialog needs to be updated.
Definition libvlc_dialog.h:154
void(* pf_cancel)(void *p_data, libvlc_dialog_id *p_id)
Called when a displayed dialog needs to be cancelled.
Definition libvlc_dialog.h:144
uint32_t version
Version of struct libvlc_dialog_cbs.
Definition libvlc_dialog.h:61
void(* pf_display_question)(void *p_data, libvlc_dialog_id *p_id, const char *psz_title, const char *psz_text, libvlc_dialog_question_type i_type, const char *psz_cancel, const char *psz_action1, const char *psz_action2)
Called when a question dialog needs to be displayed.
Definition libvlc_dialog.h:105
void(* pf_display_progress)(void *p_data, libvlc_dialog_id *p_id, const char *psz_title, const char *psz_text, bool b_indeterminate, float f_position, const char *psz_cancel)
Called when a progress dialog needs to be displayed.
Definition libvlc_dialog.h:130