Commit b37866a8 authored by Thomas Guillem's avatar Thomas Guillem

dialog: re-order callback arguments

The opaque p_data is now the first argument for the sake of consistency.
parent 86ca39d5
......@@ -277,12 +277,12 @@ typedef struct vlc_dialog_cbs
/**
* Called when an error message needs to be displayed
*
* @param p_data opaque pointer for the callback
* @param psz_title title of the diaog
* @param psz_text text of the dialog
* @param p_data opaque pointer for the callback
*/
void (*pf_display_error)(const char *psz_title, const char *psz_text,
void *p_data);
void (*pf_display_error)(void *p_data, const char *psz_title,
const char *psz_text);
/**
* Called when a login dialog needs to be displayed
......@@ -293,18 +293,18 @@ typedef struct vlc_dialog_cbs
* @note to receive this callack, vlc_dialog_cbs.pf_cancel should not be
* NULL.
*
* @param p_data opaque pointer for the callback
* @param p_id id used to interact with the dialog
* @param psz_title title of the diaog
* @param psz_text text of the dialog
* @param psz_default_username user name that should be set on the user form
* @param b_ask_store if true, ask the user if he wants to save the
* credentials
* @param p_data opaque pointer for the callback
*/
void (*pf_display_login)(vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text,
void (*pf_display_login)(void *p_data, vlc_dialog_id *p_id,
const char *psz_title, const char *psz_text,
const char *psz_default_username,
bool b_ask_store, void *p_data);
bool b_ask_store);
/**
* Called when a question dialog needs to be displayed
......@@ -315,6 +315,7 @@ typedef struct vlc_dialog_cbs
* @note to receive this callack, vlc_dialog_cbs.pf_cancel should not be
* NULL.
*
* @param p_data opaque pointer for the callback
* @param p_id id used to interact with the dialog
* @param psz_title title of the diaog
* @param psz_text text of the dialog
......@@ -324,13 +325,12 @@ typedef struct vlc_dialog_cbs
* button
* @param psz_action2 text of the second button, if NULL, don't display
* this button
* @param p_data opaque pointer for the callback
*/
void (*pf_display_question)(vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text,
void (*pf_display_question)(void *p_data, vlc_dialog_id *p_id,
const char *psz_title, const char *psz_text,
vlc_dialog_question_type i_type,
const char *psz_cancel, const char *psz_action1,
const char *psz_action2, void *p_data);
const char *psz_action2);
/**
* Called when a progress dialog needs to be displayed
......@@ -341,6 +341,7 @@ typedef struct vlc_dialog_cbs
* @note to receive this callack, vlc_dialog_cbs.pf_cancel and
* vlc_dialog_cbs.pf_update_progress should not be NULL.
*
* @param p_data opaque pointer for the callback
* @param p_id id used to interact with the dialog
* @param psz_title title of the diaog
* @param psz_text text of the dialog
......@@ -349,12 +350,11 @@ typedef struct vlc_dialog_cbs
* 1.0)
* @param psz_cancel text of the cancel button, if NULL the dialog is not
* cancellable
* @param p_data opaque pointer for the callback
*/
void (*pf_display_progress)(vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, bool b_indeterminate,
float f_position, const char *psz_cancel,
void *p_data);
void (*pf_display_progress)(void *p_data, vlc_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 displayed dialog needs to be cancelled
......@@ -362,21 +362,21 @@ typedef struct vlc_dialog_cbs
* The implementation must call vlc_dialog_id_dismiss() to really release
* the dialog.
*
* @param p_id id of the dialog
* @param p_data opaque pointer for the callback
* @param p_id id of the dialog
*/
void (*pf_cancel)(vlc_dialog_id *p_id, void *p_data);
void (*pf_cancel)(void *p_data, vlc_dialog_id *p_id);
/**
* Called when a progress dialog needs to be updated
*
* @param p_data opaque pointer for the callback
* @param p_id id of the dialog
* @param f_position osition of the progress bar (between 0.0 and 1.0)
* @param psz_text new text of the progress dialog
* @param p_data opaque pointer for the callback
*/
void (*pf_update_progress)(vlc_dialog_id *p_id, float f_position,
const char *psz_text, void *p_data);
void (*pf_update_progress)(void *p_data, vlc_dialog_id *p_id,
float f_position, const char *psz_text);
} vlc_dialog_cbs;
/**
......
......@@ -45,7 +45,7 @@ vlc_to_libvlc_dialog_question_type(vlc_dialog_question_type i_type)
}
static void
display_error_cb(const char *psz_title, const char *psz_text, void *p_data)
display_error_cb(void *p_data, const char *psz_title, const char *psz_text)
{
libvlc_instance_t *p_instance = p_data;
......@@ -54,9 +54,9 @@ display_error_cb(const char *psz_title, const char *psz_text, void *p_data)
}
static void
display_login_cb(vlc_dialog_id *p_id, const char *psz_title,
display_login_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, const char *psz_default_username,
bool b_ask_store, void *p_data)
bool b_ask_store)
{
libvlc_instance_t *p_instance = p_data;
......@@ -68,10 +68,10 @@ display_login_cb(vlc_dialog_id *p_id, const char *psz_title,
}
static void
display_question_cb(vlc_dialog_id *p_id, const char *psz_title,
display_question_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, vlc_dialog_question_type i_type,
const char *psz_cancel, const char *psz_action1,
const char *psz_action2, void *p_data)
const char *psz_action2)
{
libvlc_instance_t *p_instance = p_data;
const libvlc_dialog_question_type i_ltype =
......@@ -85,9 +85,9 @@ display_question_cb(vlc_dialog_id *p_id, const char *psz_title,
}
static void
display_progress_cb(vlc_dialog_id *p_id, const char *psz_title,
display_progress_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, bool b_indeterminate,
float f_position, const char *psz_cancel, void *p_data)
float f_position, const char *psz_cancel)
{
libvlc_instance_t *p_instance = p_data;
......@@ -99,7 +99,7 @@ display_progress_cb(vlc_dialog_id *p_id, const char *psz_title,
}
static void
cancel_cb(vlc_dialog_id *p_id, void *p_data)
cancel_cb(void *p_data, vlc_dialog_id *p_id)
{
libvlc_instance_t *p_instance = p_data;
p_instance->dialog.cbs.pf_cancel((libvlc_dialog_id *)p_id,
......@@ -107,8 +107,8 @@ cancel_cb(vlc_dialog_id *p_id, void *p_data)
}
static void
update_progress_cb(vlc_dialog_id *p_id, float f_position, const char *psz_text,
void *p_data)
update_progress_cb(void *p_data, vlc_dialog_id *p_id, float f_position,
const char *psz_text)
{
libvlc_instance_t *p_instance = p_data;
p_instance->dialog.cbs.pf_update_progress((libvlc_dialog_id *) p_id,
......
......@@ -44,9 +44,9 @@
@end
static void displayErrorCallback(const char *psz_title,
const char *psz_text,
void *p_data)
static void displayErrorCallback(void *p_data,
const char *psz_title,
const char *psz_text)
{
@autoreleasepool {
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
......@@ -57,12 +57,12 @@ static void displayErrorCallback(const char *psz_title,
}
}
static void displayLoginCallback(vlc_dialog_id *p_id,
static void displayLoginCallback(void *p_data,
vlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
const char *psz_default_username,
bool b_ask_store,
void *p_data)
bool b_ask_store)
{
@autoreleasepool {
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
......@@ -76,14 +76,14 @@ static void displayLoginCallback(vlc_dialog_id *p_id,
}
}
static void displayQuestionCallback(vlc_dialog_id *p_id,
static void displayQuestionCallback(void *p_data,
vlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
vlc_dialog_question_type i_type,
const char *psz_cancel,
const char *psz_action1,
const char *psz_action2,
void *p_data)
const char *psz_action2)
{
@autoreleasepool {
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
......@@ -99,13 +99,13 @@ static void displayQuestionCallback(vlc_dialog_id *p_id,
}
}
static void displayProgressCallback(vlc_dialog_id *p_id,
static void displayProgressCallback(void *p_data,
vlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
bool b_indeterminate,
float f_position,
const char *psz_cancel,
void *p_data)
const char *psz_cancel)
{
@autoreleasepool {
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
......@@ -120,18 +120,18 @@ static void displayProgressCallback(vlc_dialog_id *p_id,
}
}
static void cancelCallback(vlc_dialog_id *p_id,
void *p_data)
static void cancelCallback(void *p_data,
vlc_dialog_id *p_id)
{
@autoreleasepool {
[NSApp stopModalWithCode: 0];
}
}
static void updateProgressCallback(vlc_dialog_id *p_id,
static void updateProgressCallback(void *p_data,
vlc_dialog_id *p_id,
float f_value,
const char *psz_text,
void *p_data)
const char *psz_text)
{
@autoreleasepool {
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
......
......@@ -81,8 +81,8 @@ DialogHandler::~DialogHandler()
}
void
DialogHandler::displayErrorCb(const char *psz_title, const char *psz_text,
void *p_data)
DialogHandler::displayErrorCb(void *p_data, const char *psz_title,
const char *psz_text)
{
DialogHandler *self = static_cast<DialogHandler *>(p_data);
const QString title = qfu(psz_title);
......@@ -93,10 +93,10 @@ DialogHandler::displayErrorCb(const char *psz_title, const char *psz_text,
void
DialogHandler::displayLoginCb(vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text,
DialogHandler::displayLoginCb(void *p_data, vlc_dialog_id *p_id,
const char *psz_title, const char *psz_text,
const char *psz_default_username,
bool b_ask_store, void *p_data)
bool b_ask_store)
{
DialogHandler *self = static_cast<DialogHandler *>(p_data);
const QString title = qfu(psz_title);
......@@ -110,11 +110,11 @@ DialogHandler::displayLoginCb(vlc_dialog_id *p_id, const char *psz_title,
}
void
DialogHandler::displayQuestionCb(vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text,
DialogHandler::displayQuestionCb(void *p_data, vlc_dialog_id *p_id,
const char *psz_title, const char *psz_text,
vlc_dialog_question_type i_type,
const char *psz_cancel, const char *psz_action1,
const char *psz_action2, void *p_data)
const char *psz_action2)
{
DialogHandler *self = static_cast<DialogHandler *>(p_data);
const QString title = qfu(psz_title);
......@@ -129,10 +129,10 @@ DialogHandler::displayQuestionCb(vlc_dialog_id *p_id, const char *psz_title,
}
void
DialogHandler::displayProgressCb(vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, bool b_indeterminate,
float f_position, const char *psz_cancel,
void *p_data)
DialogHandler::displayProgressCb(void *p_data, vlc_dialog_id *p_id,
const char *psz_title, const char *psz_text,
bool b_indeterminate, float f_position,
const char *psz_cancel)
{
DialogHandler *self = static_cast<DialogHandler *>(p_data);
const QString title = qfu(psz_title);
......@@ -143,14 +143,14 @@ DialogHandler::displayProgressCb(vlc_dialog_id *p_id, const char *psz_title,
f_position, cancel);
}
void DialogHandler::cancelCb(vlc_dialog_id *p_id, void *p_data)
void DialogHandler::cancelCb(void *p_data, vlc_dialog_id *p_id)
{
DialogHandler *self = static_cast<DialogHandler *>(p_data);
emit self->cancelled(p_id);
}
void DialogHandler::updateProgressCb(vlc_dialog_id *p_id, float f_value,
const char *psz_text, void *p_data)
void DialogHandler::updateProgressCb(void *p_data, vlc_dialog_id *p_id,
float f_value, const char *psz_text)
{
DialogHandler *self = static_cast<DialogHandler *>(p_data);
emit self->progressUpdated(p_id, f_value, qfu(psz_text));
......
......@@ -78,16 +78,16 @@ private slots:
private:
intf_thread_t *p_intf;
static void displayErrorCb(const char *, const char *, void *);
static void displayLoginCb(vlc_dialog_id *, const char *, const char *,
const char *, bool, void *);
static void displayQuestionCb(vlc_dialog_id *, const char *, const char *,
vlc_dialog_question_type, const char *,
const char *, const char *, void *);
static void displayProgressCb(vlc_dialog_id *, const char *, const char *,
bool, float, const char *, void *);
static void cancelCb(vlc_dialog_id *, void *);
static void updateProgressCb(vlc_dialog_id *, float, const char *, void *);
static void displayErrorCb(void *, const char *, const char *);
static void displayLoginCb(void *, vlc_dialog_id *, const char *,
const char *, const char *, bool);
static void displayQuestionCb(void *, vlc_dialog_id *, const char *,
const char *, vlc_dialog_question_type,
const char *, const char *, const char *);
static void displayProgressCb(void *, vlc_dialog_id *, const char *,
const char *, bool, float, const char *);
static void cancelCb(void *, vlc_dialog_id *);
static void updateProgressCb(void *, vlc_dialog_id *, float, const char *);
};
class DialogWrapper : public QObject
......
......@@ -189,7 +189,7 @@ dialog_cancel_locked(vlc_dialog_provider *p_provider, vlc_dialog_id *p_id)
p_id->b_cancelled = true;
vlc_mutex_unlock(&p_id->lock);
p_provider->cbs.pf_cancel(p_id, p_provider->p_cbs_data);
p_provider->cbs.pf_cancel(p_provider->p_cbs_data, p_id);
}
static vlc_dialog_id *
......@@ -349,7 +349,7 @@ dialog_display_error_va(vlc_dialog_provider *p_provider, const char *psz_title,
return VLC_ENOMEM;
}
p_provider->cbs.pf_display_error(psz_title, psz_text, p_provider->p_cbs_data);
p_provider->cbs.pf_display_error(p_provider->p_cbs_data, psz_title, psz_text);
free(psz_text);
vlc_mutex_unlock(&p_provider->lock);
......@@ -418,9 +418,8 @@ dialog_display_login_va(vlc_dialog_provider *p_provider, vlc_dialog_id **pp_id,
vlc_mutex_unlock(&p_provider->lock);
return VLC_ENOMEM;
}
p_provider->cbs.pf_display_login(p_id, psz_title, psz_text,
psz_default_username, b_ask_store,
p_provider->p_cbs_data);
p_provider->cbs.pf_display_login(p_provider->p_cbs_data, p_id, psz_title,
psz_text, psz_default_username, b_ask_store);
free(psz_text);
vlc_mutex_unlock(&p_provider->lock);
*pp_id = p_id;
......@@ -506,9 +505,9 @@ dialog_display_question_va(vlc_dialog_provider *p_provider, vlc_dialog_id **pp_i
vlc_mutex_unlock(&p_provider->lock);
return VLC_ENOMEM;
}
p_provider->cbs.pf_display_question(p_id, psz_title, psz_text,
i_type, psz_cancel, psz_action1,
psz_action2, p_provider->p_cbs_data);
p_provider->cbs.pf_display_question(p_provider->p_cbs_data, p_id, psz_title,
psz_text, i_type, psz_cancel, psz_action1,
psz_action2);
free(psz_text);
vlc_mutex_unlock(&p_provider->lock);
*pp_id = p_id;
......@@ -597,9 +596,9 @@ display_progress_va(vlc_dialog_provider *p_provider, vlc_dialog_id **pp_id,
}
p_id->b_progress_indeterminate = b_indeterminate;
p_id->psz_progress_text = psz_text;
p_provider->cbs.pf_display_progress(p_id, psz_title, psz_text,
b_indeterminate, f_position, psz_cancel,
p_provider->p_cbs_data);
p_provider->cbs.pf_display_progress(p_provider->p_cbs_data, p_id, psz_title,
psz_text, b_indeterminate, f_position,
psz_cancel);
vlc_mutex_unlock(&p_provider->lock);
*pp_id = p_id;
......@@ -666,8 +665,8 @@ dialog_update_progress(vlc_object_t *p_obj, vlc_dialog_id *p_id, float f_value,
free(p_id->psz_progress_text);
p_id->psz_progress_text = psz_text;
}
p_provider->cbs.pf_update_progress(p_id, f_value, p_id->psz_progress_text,
p_provider->p_cbs_data);
p_provider->cbs.pf_update_progress(p_provider->p_cbs_data, p_id, f_value,
p_id->psz_progress_text);
vlc_mutex_unlock(&p_provider->lock);
return VLC_SUCCESS;
......
......@@ -48,10 +48,10 @@ static int tlspair(int fds[2])
}
static void
dialog_display_question_cb(vlc_dialog_id *p_id, const char *psz_title,
dialog_display_question_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, vlc_dialog_question_type i_type,
const char *psz_cancel, const char *psz_action1,
const char *psz_action2, void *p_data)
const char *psz_action2)
{
(void) psz_title;
(void) psz_text;
......@@ -63,9 +63,9 @@ dialog_display_question_cb(vlc_dialog_id *p_id, const char *psz_title,
vlc_dialog_id_post_action(p_id, *value);
}
static void dialog_cancel_cb(vlc_dialog_id *id, void *data)
static void dialog_cancel_cb(void *p_data, vlc_dialog_id *id)
{
(void)data;
(void)p_data;
vlc_dialog_id_dismiss(id);
}
......
......@@ -54,16 +54,16 @@ struct cb_answer
static void
display_error_cb(const char *psz_title, const char *psz_text, void *p_data)
display_error_cb(void *p_data, const char *psz_title, const char *psz_text)
{
(void) p_data;
printf("error message: title: '%s', text: '%s'\n", psz_title, psz_text);
}
static void
display_login_cb(vlc_dialog_id *p_id, const char *psz_title,
display_login_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, const char *psz_default_username,
bool b_ask_store, void *p_data)
bool b_ask_store)
{
struct cb_answer *p_ans = p_data;
printf("login dialog: title: '%s', text: '%s', "
......@@ -77,10 +77,10 @@ display_login_cb(vlc_dialog_id *p_id, const char *psz_title,
}
static void
display_question_cb(vlc_dialog_id *p_id, const char *psz_title,
display_question_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, vlc_dialog_question_type i_type,
const char *psz_cancel, const char *psz_action1,
const char *psz_action2, void *p_data)
const char *psz_action2)
{
struct cb_answer *p_ans = p_data;
printf("question dialog: title: '%s', text: '%s', "
......@@ -94,9 +94,9 @@ display_question_cb(vlc_dialog_id *p_id, const char *psz_title,
}
static void
display_progress_cb(vlc_dialog_id *p_id, const char *psz_title,
display_progress_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, bool b_indeterminate,
float f_position, const char *psz_cancel, void *p_data)
float f_position, const char *psz_cancel)
{
struct cb_answer *p_ans = p_data;
printf("progress dialog: title: '%s', text: '%s', "
......@@ -107,14 +107,14 @@ display_progress_cb(vlc_dialog_id *p_id, const char *psz_title,
vlc_dialog_id_dismiss(p_id);
}
static void cancel_cb(vlc_dialog_id *p_id, void *p_data)
static void cancel_cb(void *p_data, vlc_dialog_id *p_id)
{
(void) p_data;
vlc_dialog_id_dismiss(p_id);
}
static void update_progress_cb(vlc_dialog_id *p_id, float f_position,
const char *psz_text, void *p_data)
static void update_progress_cb(void *p_data, vlc_dialog_id *p_id, float f_position,
const char *psz_text)
{
(void) p_id;
(void) p_data;
......
......@@ -200,9 +200,9 @@ static const struct testcase
};
static void
display_login_cb(vlc_dialog_id *p_id, const char *psz_title,
display_login_cb(void *p_data, vlc_dialog_id *p_id, const char *psz_title,
const char *psz_text, const char *psz_default_username,
bool b_ask_store, void *p_data)
bool b_ask_store)
{
(void) psz_title;
(void) psz_text;
......@@ -220,7 +220,7 @@ display_login_cb(vlc_dialog_id *p_id, const char *psz_title,
}
static void
cancel_cb(vlc_dialog_id *p_id, void *p_data)
cancel_cb(void *p_data, vlc_dialog_id *p_id)
{
(void) p_data;
vlc_dialog_id_dismiss(p_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment