Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GSoC
GSoC2018
macOS
vlc
Commits
093de856
Commit
093de856
authored
Aug 02, 2006
by
zorglub
Browse files
Interaction cleanup, remove some unused functions, factorize some code, ...
parent
7eee710f
Changes
7
Hide whitespace changes
Inline
Side-by-side
include/vlc_common.h
View file @
093de856
...
...
@@ -618,10 +618,13 @@ static int64_t GCD( int64_t a, int64_t b )
if( !var ) goto error; }
#define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return;
#define DECMALLOC_ERR( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return VLC_ENOMEM;
#define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return NULL;
#define FREENULL(a) if( a ) { free( a ); a = NULL; }
#define FREE(a) if( a ) { free( a ); }
/* Dynamic array handling: realloc array, move data, increment position */
#if defined( _MSC_VER ) && _MSC_VER < 1300 && !defined( UNDER_CE )
...
...
include/vlc_interaction.h
View file @
093de856
...
...
@@ -169,32 +169,24 @@ enum
* Exported symbols
***************************************************************************/
#define intf_Interact( a,b ) __intf_Interact( VLC_OBJECT(a), b )
VLC_EXPORT
(
int
,
__intf_Interact
,(
vlc_object_t
*
,
interaction_dialog_t
*
)
);
#define intf_UserFatal( a, b, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),b,c,d, ## e )
VLC_EXPORT
(
void
,
__intf_UserFatal
,(
vlc_object_t
*
,
vlc_bool_t
,
const
char
*
,
const
char
*
,
...)
);
VLC_EXPORT
(
int
,
__intf_UserFatal
,(
vlc_object_t
*
,
vlc_bool_t
,
const
char
*
,
const
char
*
,
...)
);
#define intf_UserWarn( a, c, d, e... ) __intf_UserWarn( VLC_OBJECT(a),c,d, ## e )
VLC_EXPORT
(
void
,
__intf_UserWarn
,(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
...)
);
VLC_EXPORT
(
int
,
__intf_UserWarn
,(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
...)
);
#define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT
(
int
,
__intf_UserLoginPassword
,(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
char
**
,
char
**
)
);
#define intf_UserYesNo( a, b, c, d, e, f ) __intf_UserYesNo( VLC_OBJECT(a),b,c, d, e, f )
VLC_EXPORT
(
int
,
__intf_UserYesNo
,(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
)
);
#define intf_UserProgress( a, b, c, d, e ) __intf_UserProgress( VLC_OBJECT(a),b,c,d,e )
VLC_EXPORT
(
int
,
__intf_UserProgress
,(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
float
,
int
)
);
#define intf_UserProgressUpdate( a, b, c, d, e ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c,d,e )
VLC_EXPORT
(
void
,
__intf_UserProgressUpdate
,(
vlc_object_t
*
,
int
,
const
char
*
,
float
,
int
)
);
#define intf_UserProgressIsCancelled( a, b ) __intf_UserProgressIsCancelled( VLC_OBJECT(a),b )
VLC_EXPORT
(
vlc_bool_t
,
__intf_UserProgressIsCancelled
,(
vlc_object_t
*
,
int
)
);
#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
**
)
);
#define intf_IntfProgress( a, b, c ) __intf_IntfProgress( VLC_OBJECT(a),b,c )
VLC_EXPORT
(
int
,
__intf_IntfProgress
,(
vlc_object_t
*
,
const
char
*
,
float
)
);
#define intf_IntfProgressUpdate( a, b, c, d ) __intf_IntfProgressUpdate( VLC_OBJECT(a),b,c,d )
VLC_EXPORT
(
void
,
__intf_IntfProgressUpdate
,(
vlc_object_t
*
,
int
,
const
char
*
,
float
)
);
#define intf_IntfProgress( a, b, c ) __intf_Progress( VLC_OBJECT(a), NULL, b,c, -1 )
#define intf_UserProgress( a, b, c, d, e ) __intf_Progress( VLC_OBJECT(a),b,c,d,e )
VLC_EXPORT
(
int
,
__intf_Progress
,(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
float
,
int
)
);
#define intf_ProgressUpdate( a, b, c, d, e ) __intf_ProgressUpdate( VLC_OBJECT(a),b,c,d,e )
VLC_EXPORT
(
void
,
__intf_ProgressUpdate
,(
vlc_object_t
*
,
int
,
const
char
*
,
float
,
int
)
);
#define intf_ProgressIsCancelled( a, b ) __intf_UserProgressIsCancelled( VLC_OBJECT(a),b )
VLC_EXPORT
(
vlc_bool_t
,
__intf_UserProgressIsCancelled
,(
vlc_object_t
*
,
int
)
);
#define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b )
VLC_EXPORT
(
void
,
__intf_UserHide
,(
vlc_object_t
*
,
int
));
...
...
include/vlc_symbols.h
View file @
093de856
...
...
@@ -429,14 +429,14 @@ struct module_symbols_t
char
*
(
*
FromUTF32_inner
)
(
const
uint32_t
*
);
int
(
*
__input_Read_inner
)
(
vlc_object_t
*
,
input_item_t
*
,
vlc_bool_t
);
int
(
*
__net_ConnectUDP_inner
)
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
hlim
);
int
(
*
__intf_Interact_
inner
)
(
vlc_object_t
*
,
interaction_dialog_t
*
)
;
void
*
__intf_Interact_
deprecated
;
void
(
*
intf_InteractionManage_inner
)
(
playlist_t
*
);
void
(
*
intf_InteractionDestroy_inner
)
(
interaction_t
*
);
void
(
*
__intf_UserFatal_inner
)
(
vlc_object_t
*
,
vlc_bool_t
,
const
char
*
,
const
char
*
,
...);
int
(
*
__intf_UserFatal_inner
)
(
vlc_object_t
*
,
vlc_bool_t
,
const
char
*
,
const
char
*
,
...);
int
(
*
__intf_UserLoginPassword_inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
char
**
,
char
**
);
int
(
*
__intf_UserYesNo_inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
);
int
(
*
__intf_UserProgress_
inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
float
,
int
)
;
void
(
*
__intf_UserProgressUpdate_
inner
)
(
vlc_object_t
*
,
int
,
const
char
*
,
float
,
int
)
;
void
*
__intf_UserProgress_
deprecated
;
void
*
__intf_UserProgressUpdate_
deprecated
;
void
(
*
__intf_UserHide_inner
)
(
vlc_object_t
*
,
int
);
void
*
__stats_Create_deprecated
;
int
(
*
__stats_Update_inner
)
(
vlc_object_t
*
,
counter_t
*
,
vlc_value_t
,
vlc_value_t
*
);
...
...
@@ -517,11 +517,13 @@ struct module_symbols_t
void
*
stats_TimerClean_deprecated
;
void
*
stats_TimersClean_deprecated
;
void
(
*
__stats_TimersClean_inner
)
(
vlc_object_t
*
);
void
(
*
__intf_IntfProgressUpdate_
inner
)
(
vlc_object_t
*
,
int
,
const
char
*
,
float
)
;
int
(
*
__intf_IntfProgress_
inner
)
(
vlc_object_t
*
,
const
char
*
,
float
)
;
void
*
__intf_IntfProgressUpdate_
deprecated
;
void
*
__intf_IntfProgress_
deprecated
;
void
*
streaming_ChainToPsz_deprecated
;
void
(
*
__intf_UserWarn_inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
...);
int
(
*
__intf_UserWarn_inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
...);
vlc_bool_t
(
*
__intf_UserProgressIsCancelled_inner
)
(
vlc_object_t
*
,
int
);
int
(
*
__intf_Progress_inner
)
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
float
,
int
);
void
(
*
__intf_ProgressUpdate_inner
)
(
vlc_object_t
*
,
int
,
const
char
*
,
float
,
int
);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...
...
@@ -908,14 +910,11 @@ struct module_symbols_t
# define FromUTF32 (p_symbols)->FromUTF32_inner
# define __input_Read (p_symbols)->__input_Read_inner
# define __net_ConnectUDP (p_symbols)->__net_ConnectUDP_inner
# define __intf_Interact (p_symbols)->__intf_Interact_inner
# define intf_InteractionManage (p_symbols)->intf_InteractionManage_inner
# define intf_InteractionDestroy (p_symbols)->intf_InteractionDestroy_inner
# define __intf_UserFatal (p_symbols)->__intf_UserFatal_inner
# define __intf_UserLoginPassword (p_symbols)->__intf_UserLoginPassword_inner
# define __intf_UserYesNo (p_symbols)->__intf_UserYesNo_inner
# define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner
# define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner
# define __intf_UserHide (p_symbols)->__intf_UserHide_inner
# define __stats_Update (p_symbols)->__stats_Update_inner
# define __stats_Get (p_symbols)->__stats_Get_inner
...
...
@@ -988,10 +987,10 @@ struct module_symbols_t
# define input_AddSubtitles (p_symbols)->input_AddSubtitles_inner
# define __stats_CounterCreate (p_symbols)->__stats_CounterCreate_inner
# define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner
# define __intf_IntfProgressUpdate (p_symbols)->__intf_IntfProgressUpdate_inner
# define __intf_IntfProgress (p_symbols)->__intf_IntfProgress_inner
# define __intf_UserWarn (p_symbols)->__intf_UserWarn_inner
# define __intf_UserProgressIsCancelled (p_symbols)->__intf_UserProgressIsCancelled_inner
# define __intf_Progress (p_symbols)->__intf_Progress_inner
# define __intf_ProgressUpdate (p_symbols)->__intf_ProgressUpdate_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...
...
@@ -1381,14 +1380,11 @@ struct module_symbols_t
((p_symbols)->FromUTF32_inner) = FromUTF32; \
((p_symbols)->__input_Read_inner) = __input_Read; \
((p_symbols)->__net_ConnectUDP_inner) = __net_ConnectUDP; \
((p_symbols)->__intf_Interact_inner) = __intf_Interact; \
((p_symbols)->intf_InteractionManage_inner) = intf_InteractionManage; \
((p_symbols)->intf_InteractionDestroy_inner) = intf_InteractionDestroy; \
((p_symbols)->__intf_UserFatal_inner) = __intf_UserFatal; \
((p_symbols)->__intf_UserLoginPassword_inner) = __intf_UserLoginPassword; \
((p_symbols)->__intf_UserYesNo_inner) = __intf_UserYesNo; \
((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \
((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \
((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \
((p_symbols)->__stats_Update_inner) = __stats_Update; \
((p_symbols)->__stats_Get_inner) = __stats_Get; \
...
...
@@ -1461,10 +1457,10 @@ struct module_symbols_t
((p_symbols)->input_AddSubtitles_inner) = input_AddSubtitles; \
((p_symbols)->__stats_CounterCreate_inner) = __stats_CounterCreate; \
((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \
((p_symbols)->__intf_IntfProgressUpdate_inner) = __intf_IntfProgressUpdate; \
((p_symbols)->__intf_IntfProgress_inner) = __intf_IntfProgress; \
((p_symbols)->__intf_UserWarn_inner) = __intf_UserWarn; \
((p_symbols)->__intf_UserProgressIsCancelled_inner) = __intf_UserProgressIsCancelled; \
((p_symbols)->__intf_Progress_inner) = __intf_Progress; \
((p_symbols)->__intf_ProgressUpdate_inner) = __intf_ProgressUpdate; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
(p_symbols)->playlist_ItemAddParent_deprecated = NULL; \
...
...
@@ -1491,6 +1487,9 @@ struct module_symbols_t
(p_symbols)->playlist_Sort_deprecated = NULL; \
(p_symbols)->playlist_Move_deprecated = NULL; \
(p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \
(p_symbols)->__intf_Interact_deprecated = NULL; \
(p_symbols)->__intf_UserProgress_deprecated = NULL; \
(p_symbols)->__intf_UserProgressUpdate_deprecated = NULL; \
(p_symbols)->__stats_Create_deprecated = NULL; \
(p_symbols)->__stats_CounterGet_deprecated = NULL; \
(p_symbols)->stats_HandlerDestroy_deprecated = NULL; \
...
...
@@ -1499,6 +1498,8 @@ struct module_symbols_t
(p_symbols)->__intf_UserOkayCancel_deprecated = NULL; \
(p_symbols)->stats_TimerClean_deprecated = NULL; \
(p_symbols)->stats_TimersClean_deprecated = NULL; \
(p_symbols)->__intf_IntfProgressUpdate_deprecated = NULL; \
(p_symbols)->__intf_IntfProgress_deprecated = NULL; \
(p_symbols)->streaming_ChainToPsz_deprecated = NULL; \
# endif
/* __PLUGIN__ */
...
...
modules/demux/avi/avi.c
View file @
093de856
...
...
@@ -2298,8 +2298,8 @@ static void AVI_IndexCreate( demux_t *p_demux )
stream_Size
(
p_demux
->
s
);
float
f_pos
=
(
float
)
i_pos
;
p_demux
->
p_sys
->
last_update
=
mdate
();
intf_
Intf
ProgressUpdate
(
p_demux
,
p_demux
->
p_sys
->
i_dialog_id
,
_
(
"Fixing AVI Index..."
),
f_pos
);
intf_ProgressUpdate
(
p_demux
,
p_demux
->
p_sys
->
i_dialog_id
,
_
(
"Fixing AVI Index..."
),
f_pos
,
-
1
);
}
if
(
AVI_PacketGetHeader
(
p_demux
,
&
pk
)
)
...
...
modules/services_discovery/shout.c
View file @
093de856
...
...
@@ -196,7 +196,8 @@ static void Run( services_discovery_t *p_sd )
int
i_id
=
input_Read
(
p_sd
,
p_sys
->
p_input
,
VLC_FALSE
);
int
i_dialog_id
;
i_dialog_id
=
intf_UserProgress
(
p_sd
,
"Shoutcast"
,
"Connecting..."
,
0
.
0
,
0
);
i_dialog_id
=
intf_UserProgress
(
p_sd
,
"Shoutcast"
,
_
(
"Connecting..."
)
,
0
.
0
,
0
);
p_sys
->
b_dialog
=
VLC_TRUE
;
while
(
!
p_sd
->
b_die
)
...
...
@@ -214,8 +215,8 @@ static void Run( services_discovery_t *p_sd )
{
float
f_pos
=
(
float
)(
p_sys
->
p_node_cat
->
i_children
)
*
2
*
100
.
0
/
260
/* gruiiik FIXME */
;
intf_
User
ProgressUpdate
(
p_sd
,
i_dialog_id
,
"Downloading"
,
f_pos
,
0
);
intf_ProgressUpdate
(
p_sd
,
i_dialog_id
,
"Downloading"
,
f_pos
,
0
);
}
vlc_object_release
(
p_input
);
}
...
...
src/interface/interaction.c
View file @
093de856
...
...
@@ -36,6 +36,7 @@
#include
<vlc/vlc.h>
#include
<vlc/input.h>
#include
<assert.h>
#include
"vlc_interaction.h"
#include
"vlc_interface.h"
...
...
@@ -44,57 +45,13 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
void
intf_
InteractionInit
(
playlist_t
*
p_playlist
);
static
interaction_t
*
intf_
InteractionGet
(
vlc_object_t
*
p_this
);
static
void
intf_
InteractionSearchInterface
(
interaction_t
*
static
void
InteractionInit
(
playlist_t
*
p_playlist
);
static
interaction_t
*
InteractionGet
(
vlc_object_t
*
p_this
);
static
void
InteractionSearchInterface
(
interaction_t
*
p_interaction
);
static
int
intf_WaitAnswer
(
interaction_t
*
p_interact
,
interaction_dialog_t
*
p_dialog
);
static
int
intf_Send
(
interaction_t
*
p_interact
,
interaction_dialog_t
*
p_dialog
);
static
interaction_dialog_t
*
intf_InteractionGetById
(
vlc_object_t
*
,
int
);
static
void
intf_InteractionDialogDestroy
(
interaction_dialog_t
*
p_dialog
);
/**
* Send an interaction element to the user
*
* \param p_this the calling vlc_object_t
* \param p_interact the interaction element
* \return VLC_SUCCESS or an error code
*/
int
__intf_Interact
(
vlc_object_t
*
p_this
,
interaction_dialog_t
*
p_dialog
)
{
interaction_t
*
p_interaction
=
intf_InteractionGet
(
p_this
);
/* Get an id, if we don't already have one */
if
(
p_dialog
->
i_id
==
0
)
{
p_dialog
->
i_id
=
++
p_interaction
->
i_last_id
;
}
if
(
p_this
->
i_flags
&
OBJECT_FLAGS_NOINTERACT
)
return
VLC_EGENERIC
;
if
(
config_GetInt
(
p_this
,
"interact"
)
||
p_dialog
->
i_flags
&
DIALOG_BLOCKING_ERROR
||
p_dialog
->
i_flags
&
DIALOG_NONBLOCKING_ERROR
)
{
p_dialog
->
p_interaction
=
p_interaction
;
p_dialog
->
p_parent
=
p_this
;
if
(
p_dialog
->
i_type
==
INTERACT_DIALOG_TWOWAY
)
{
return
intf_WaitAnswer
(
p_interaction
,
p_dialog
);
}
else
{
p_dialog
->
i_flags
|=
DIALOG_GOT_ANSWER
;
return
intf_Send
(
p_interaction
,
p_dialog
);
}
}
else
return
VLC_EGENERIC
;
}
static
interaction_dialog_t
*
DialogGetById
(
interaction_t
*
,
int
);
static
void
DialogDestroy
(
interaction_dialog_t
*
p_dialog
);
static
int
DialogSend
(
vlc_object_t
*
p_this
,
interaction_dialog_t
*
p_dialog
);
/**
* Destroy the interaction system
...
...
@@ -104,16 +61,13 @@ int __intf_Interact( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
void
intf_InteractionDestroy
(
interaction_t
*
p_interaction
)
{
int
i
;
// Remove all dialogs - Interfaces must be able to clean up their data
for
(
i
=
p_interaction
->
i_dialogs
-
1
;
i
>=
0
;
i
--
)
{
interaction_dialog_t
*
p_dialog
=
p_interaction
->
pp_dialogs
[
i
];
intf_Interaction
DialogDestroy
(
p_dialog
);
DialogDestroy
(
p_dialog
);
REMOVE_ELEM
(
p_interaction
->
pp_dialogs
,
p_interaction
->
i_dialogs
,
i
);
}
vlc_object_destroy
(
p_interaction
);
}
...
...
@@ -128,26 +82,21 @@ void intf_InteractionManage( playlist_t *p_playlist )
{
vlc_value_t
val
;
int
i_index
;
interaction_t
*
p_interaction
;
p_interaction
=
p_playlist
->
p_interaction
;
interaction_t
*
p_interaction
=
p_playlist
->
p_interaction
;
// Nothing to do
if
(
p_interaction
->
i_dialogs
==
0
)
return
;
vlc_mutex_lock
(
&
p_interaction
->
object_lock
);
intf_InteractionSearchInterface
(
p_interaction
);
InteractionSearchInterface
(
p_interaction
);
if
(
!
p_interaction
->
p_intf
)
{
// We mark all dialogs as answered with their "default" answer
for
(
i_index
=
0
;
i_index
<
p_interaction
->
i_dialogs
;
i_index
++
)
{
interaction_dialog_t
*
p_dialog
=
p_interaction
->
pp_dialogs
[
i_index
];
// Give default answer
p_dialog
->
i_return
=
DIALOG_DEFAULT
;
p_dialog
->
i_return
=
DIALOG_DEFAULT
;
// Give default answer
// Pretend we have hidden and destroyed it
if
(
p_dialog
->
i_status
==
HIDDEN_DIALOG
)
...
...
@@ -200,7 +149,7 @@ void intf_InteractionManage( playlist_t *p_playlist )
REMOVE_ELEM
(
p_interaction
->
pp_dialogs
,
p_interaction
->
i_dialogs
,
i_index
);
i_index
--
;
intf_Interaction
DialogDestroy
(
p_dialog
);
DialogDestroy
(
p_dialog
);
break
;
case
NEW_DIALOG
:
// This is truly a new dialog, send it.
...
...
@@ -221,55 +170,42 @@ void intf_InteractionManage( playlist_t *p_playlist )
vlc_mutex_unlock
(
&
p_playlist
->
p_interaction
->
object_lock
);
}
#define INTERACT_INIT( new ) \
new = (interaction_dialog_t*)malloc( \
sizeof( interaction_dialog_t ) ); \
new->psz_title = NULL; \
new->psz_description = NULL; \
new->psz_default_button = NULL; \
new->psz_alternate_button = NULL; \
new->psz_other_button = NULL; \
new->i_timeToGo = 0; \
new->b_cancelled = VLC_FALSE; \
new->p_private = NULL; \
new->i_id = 0; \
new->i_flags = 0; \
new->i_status = NEW_DIALOG;
#define INTERACT_FREE( new ) \
if( new->psz_title ) free( new->psz_title ); \
if( new->psz_description ) free( new->psz_description );
/** Helper function to send an error message, both in a blocking and non-blocking way
#define DIALOG_INIT( type ) \
DECMALLOC_ERR( p_new, interaction_dialog_t ); \
memset( p_new, 0, sizeof( interaction_dialog_t ) ); \
p_new->b_cancelled = VLC_FALSE; \
p_new->i_status = NEW_DIALOG; \
p_new->i_type = INTERACT_DIALOG_##type; \
p_new->psz_returned[0] = NULL; \
p_new->psz_returned[1] = NULL;
#define FORMAT_DESC \
va_start( args, psz_format ); \
vasprintf( &p_new->psz_description, psz_format, args ); \
va_end( args );
/** Send an error message, both in a blocking and non-blocking way
* \param p_this Parent vlc_object
* \param b_blocking Is this dialog blocking or not?
* \param psz_title Title for the dialog
* \param psz_format The message to display
* */
void
__intf_UserFatal
(
vlc_object_t
*
p_this
,
vlc_bool_t
b_blocking
,
int
__intf_UserFatal
(
vlc_object_t
*
p_this
,
vlc_bool_t
b_blocking
,
const
char
*
psz_title
,
const
char
*
psz_format
,
...
)
{
va_list
args
;
interaction_dialog_t
*
p_new
=
NULL
;
INTERACT_INIT
(
p_new
);
DIALOG_INIT
(
ONEWAY
);
p_new
->
psz_title
=
strdup
(
psz_title
);
p_new
->
i_type
=
INTERACT_DIALOG_ONEWAY
;
va_start
(
args
,
psz_format
);
vasprintf
(
&
p_new
->
psz_description
,
psz_format
,
args
);
va_end
(
args
);
FORMAT_DESC
;
if
(
b_blocking
)
p_new
->
i_flags
=
DIALOG_BLOCKING_ERROR
;
else
p_new
->
i_flags
=
DIALOG_NONBLOCKING_ERROR
;
intf_Interact
(
p_this
,
p_new
);
return
DialogSend
(
p_this
,
p_new
);
}
/** Helper function to send an warning, which is always shown non-blocking
...
...
@@ -277,25 +213,19 @@ void __intf_UserFatal( vlc_object_t *p_this,
* \param psz_title Title for the dialog
* \param psz_format The message to display
* */
void
__intf_UserWarn
(
vlc_object_t
*
p_this
,
const
char
*
psz_title
,
const
char
*
psz_format
,
...
)
int
__intf_UserWarn
(
vlc_object_t
*
p_this
,
const
char
*
psz_title
,
const
char
*
psz_format
,
...
)
{
va_list
args
;
interaction_dialog_t
*
p_new
=
NULL
;
INTERACT_INIT
(
p_new
);
DIALOG_INIT
(
ONEWAY
);
p_new
->
psz_title
=
strdup
(
psz_title
);
p_new
->
i_type
=
INTERACT_DIALOG_ONEWAY
;
va_start
(
args
,
psz_format
);
vasprintf
(
&
p_new
->
psz_description
,
psz_format
,
args
);
va_end
(
args
);
FORMAT_DESC
p_new
->
i_flags
=
DIALOG_WARNING
;
intf_Interact
(
p_this
,
p_new
);
return
DialogSend
(
p_this
,
p_new
);
}
/** Helper function to ask a yes-no-cancel question
...
...
@@ -314,12 +244,8 @@ int __intf_UserYesNo( vlc_object_t *p_this,
const
char
*
psz_alternate
,
const
char
*
psz_other
)
{
int
i_ret
;
interaction_dialog_t
*
p_new
=
NULL
;
INTERACT_INIT
(
p_new
);
DIALOG_INIT
(
TWOWAY
);
p_new
->
i_type
=
INTERACT_DIALOG_TWOWAY
;
p_new
->
psz_title
=
strdup
(
psz_title
);
p_new
->
psz_description
=
strdup
(
psz_description
);
p_new
->
i_flags
=
DIALOG_YES_NO_CANCEL
;
...
...
@@ -327,43 +253,35 @@ int __intf_UserYesNo( vlc_object_t *p_this,
p_new
->
psz_alternate_button
=
strdup
(
psz_alternate
);
if
(
psz_other
)
p_new
->
psz_other_button
=
strdup
(
psz_other
);
else
p_new
->
psz_other_button
=
NULL
;
i_ret
=
intf_Interact
(
p_this
,
p_new
);
return
i_ret
;
return
DialogSend
(
p_this
,
p_new
)
;
}
/** Helper function to create a dialogue showing a progress-bar with some info
* \param p_this Parent vlc_object
* \param psz_title Title for the dialog
* \param psz_title Title for the dialog
(NULL implies main intf )
* \param psz_status Current status
* \param f_position Current position (0.0->100.0)
* \param i_timeToGo Time (in sec) to go until process is finished
* \return Dialog id, to give to UserProgressUpdate
*/
int
__intf_UserProgress
(
vlc_object_t
*
p_this
,
const
char
*
psz_title
,
const
char
*
psz_status
,
float
f_pos
,
int
i_time
)
int
__intf_Progress
(
vlc_object_t
*
p_this
,
const
char
*
psz_title
,
const
char
*
psz_status
,
float
f_pos
,
int
i_time
)
{
int
i_ret
;
interaction_dialog_t
*
p_new
=
NULL
;
INTERACT_INIT
(
p_new
);
p_new
->
i_type
=
INTERACT_DIALOG_ONEWAY
;
p_new
->
psz_title
=
strdup
(
psz_title
);
DIALOG_INIT
(
ONEWAY
);
p_new
->
psz_description
=
strdup
(
psz_status
);
p_new
->
val
.
f_float
=
f_pos
;
p_new
->
i_timeToGo
=
i_time
;
p_new
->
i_flags
=
DIALOG_USER_PROGRESS
;
i_ret
=
intf_Interact
(
p_this
,
p_new
);
if
(
psz_title
)
{
p_new
->
psz_title
=
strdup
(
psz_title
);
p_new
->
i_flags
=
DIALOG_USER_PROGRESS
;
}
else
p_new
->
i_flags
=
DIALOG_INTF_PROGRESS
;
DialogSend
(
p_this
,
p_new
);
return
p_new
->
i_id
;
}
...
...
@@ -375,17 +293,16 @@ int __intf_UserProgress( vlc_object_t *p_this,
* \param i_timeToGo Time (in sec) to go until process is finished
* \return nothing
*/
void
__intf_UserProgressUpdate
(
vlc_object_t
*
p_this
,
int
i_id
,
const
char
*
psz_status
,
float
f_pos
,
int
i_time
)
void
__intf_ProgressUpdate
(
vlc_object_t
*
p_this
,
int
i_id
,
const
char
*
psz_status
,
float
f_pos
,
int
i_time
)
{
interaction_t
*
p_interaction
=
intf_
InteractionGet
(
p_this
);
interaction_t
*
p_interaction
=
InteractionGet
(
p_this
);
interaction_dialog_t
*
p_dialog
;
if
(
!
p_interaction
)
return
;
vlc_mutex_lock
(
&
p_interaction
->
object_lock
);
p_dialog
=
intf_InteractionGetById
(
p_this
,
i_id
);
p_dialog
=
DialogGetById
(
p_interaction
,
i_id
);
if
(
!
p_dialog
)
{
...
...
@@ -393,8 +310,7 @@ void __intf_UserProgressUpdate( vlc_object_t *p_this, int i_id,
return
;
}
if
(
p_dialog
->
psz_description
)
free
(
p_dialog
->
psz_description
);
FREE
(
p_dialog
->
psz_description
);
p_dialog
->
psz_description
=
strdup
(
psz_status
);
p_dialog
->
val
.
f_float
=
f_pos
;
...
...
@@ -404,29 +320,31 @@ void __intf_UserProgressUpdate( vlc_object_t *p_this, int i_id,
vlc_mutex_unlock
(
&
p_interaction
->
object_lock
)
;
}
/** Helper function to communicate dialogue cancellations between the intf-module and caller
/** Helper function to communicate dialogue cancellations between the
* interface module and the caller
* \param p_this Parent vlc_object
* \param i_id Identifier of the dialogue
* \return Either true or false
*/
vlc_bool_t
__intf_UserProgressIsCancelled
(
vlc_object_t
*
p_this
,
int
i_id
)
{
interaction_t
*
p_interaction
=
intf_
InteractionGet
(
p_this
);
interaction_t
*
p_interaction
=
InteractionGet
(
p_this
);
interaction_dialog_t
*
p_dialog
;
vlc_bool_t
b_cancel
;
if
(
!
p_interaction
)
return
VLC_TRUE
;
vlc_mutex_lock
(
&
p_interaction
->
object_lock
);
p_dialog
=
intf_InteractionGetById
(
p_this
,
i_id
);
p_dialog
=
DialogGetById
(
p_interaction
,
i_id
);
if
(
!
p_dialog
)
{
vlc_mutex_unlock
(
&
p_interaction
->
object_lock
)
;
return
VLC_TRUE
;
}
vlc_mutex_unlock
(
&
p_interaction
->
object_lock
)
;
return
p_dialog
->
b_cancelled
;
b_cancel
=
p_dialog
->
b_cancelled
;
vlc_mutex_unlock
(
&
p_interaction
->
object_lock
);
return
b_cancel
;
}
/** Helper function to make a login/password dialogue
...
...
@@ -443,22 +361,19 @@ int __intf_UserLoginPassword( vlc_object_t *p_this,
char
**
ppsz_login
,
char
**
ppsz_password
)
{
int
i_ret
;
interaction_dialog_t
*
p_new
=
NULL
;
INTERACT_INIT
(
p_new
);
DIALOG_INIT
(
TWOWAY
);
p_new
->
i_type
=
INTERACT_DIALOG_TWOWAY
;
p_new
->
psz_title
=
strdup
(
psz_title
);
p_new
->
psz_description
=
strdup
(
psz_description
);
p_new
->
i_flags
=
DIALOG_LOGIN_PW_OK_CANCEL
;
i_ret
=
intf_Interact
(
p_this
,
p_new
);
i_ret
=
DialogSend
(
p_this
,
p_new
);
if
(
i_ret
!=
DIALOG_CANCELLED
)
{
assert
(
p_new
->
psz_returned
[
0
]
&&
p_new
->
psz_returned
[
1
]
);
*
ppsz_login
=
strdup
(
p_new
->
psz_returned
[
0
]
);
*
ppsz_password
=
strdup
(
p_new
->
psz_returned
[
1
]
);
}
...
...
@@ -477,88 +392,23 @@ int __intf_UserStringInput( vlc_object_t *p_this,
const
char
*
psz_description
,
char
**
ppsz_usersString
)
{
int
i_ret
;
interaction_dialog_t
*
p_new
=
NULL
;
INTERACT_INIT
(
p_new
);
p_new
->
i_type
=
INTERACT_DIALOG_TWOWAY
;
DIALOG_INIT
(
TWOWAY
);
p_new
->
psz_title
=
strdup
(
psz_title
);
p_new
->
psz_description
=
strdup
(
psz_description
);
p_new
->
i_flags
=
DIALOG_PSZ_INPUT_OK_CANCEL
;
i_ret
=
intf_Interact
(
p_this
,
p_new
);
i_ret
=
DialogSend
(
p_this
,
p_new
);