Commit 093de856 authored by Clément Stenac's avatar Clément Stenac

Interaction cleanup, remove some unused functions, factorize some code, ...

parent 7eee710f
......@@ -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 )
......
......@@ -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 ));
......
......@@ -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__ */
......
......@@ -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_IntfProgressUpdate( 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 ) )
......
......@@ -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,7 +215,7 @@ 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_UserProgressUpdate( p_sd, i_dialog_id, "Downloading",
intf_ProgressUpdate( p_sd, i_dialog_id, "Downloading",
f_pos, 0 );
}
vlc_object_release( p_input );
......
This diff is collapsed.
......@@ -78,7 +78,6 @@
#define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status.xml"
#define UPDATE_VLC_MIRRORS_URL "http://update.videolan.org/mirrors.xml"
#define FREE( a ) free(a);a=NULL;
#define STRDUP( a ) ( a ? strdup( a ) : NULL )
/*****************************************************************************
......@@ -167,7 +166,7 @@ void FreeMirrorsList( update_t *p_update )
free( p_update->p_mirrors[i].psz_type );
free( p_update->p_mirrors[i].psz_base_url );
}
FREE( p_update->p_mirrors );
FREENULL( p_update->p_mirrors );
p_update->i_mirrors = 0;
p_update->b_mirrors = VLC_FALSE;
}
......@@ -200,7 +199,7 @@ void FreeReleasesList( update_t *p_update )
free( p_release->psz_svn_revision );
free( p_release->p_files );
}
FREE( p_update->p_releases );
FREENULL( p_update->p_releases );
p_update->i_releases = 0;
p_update->b_releases = VLC_FALSE;
}
......@@ -308,8 +307,8 @@ void GetMirrorsList( update_t *p_update, vlc_bool_t b_force )
else if( !strcmp( psz_name, "base" ) )
tmp_mirror.psz_base_url = STRDUP( psz_value );
}
FREE( psz_name );
FREE( psz_value );
FREENULL( psz_name );
FREENULL( psz_value );
}
if( !strcmp( psz_eltname, "url" ) )
{
......@@ -325,7 +324,7 @@ void GetMirrorsList( update_t *p_update, vlc_bool_t b_force )
tmp_mirror.psz_type = NULL;
tmp_mirror.psz_base_url = NULL;
}
FREE( psz_eltname );
FREENULL( psz_eltname );
break;
case XML_READER_ENDELEM:
......@@ -339,16 +338,16 @@ void GetMirrorsList( update_t *p_update, vlc_bool_t b_force )
if( !strcmp( psz_eltname, "mirror" ) )
{
FREE( tmp_mirror.psz_name );
FREE( tmp_mirror.psz_location );
FREENULL( tmp_mirror.psz_name );
FREENULL( tmp_mirror.psz_location );
}
FREE( psz_eltname );
FREENULL( psz_eltname );
break;
/*case XML_READER_TEXT:
psz_eltvalue = xml_ReaderValue( p_xml_reader );
FREE( psz_eltvalue );
FREENULL( psz_eltvalue );
break;*/
}
}
......@@ -536,8 +535,8 @@ void GetFilesList( update_t *p_update, vlc_bool_t b_force )
{
b_arch = VLC_TRUE;
}
FREE( psz_name );
FREE( psz_value );
FREENULL( psz_name );
FREENULL( psz_value );
}
if( ( b_os && b_arch && strcmp( psz_eltname, "arch" ) ) )
{
......@@ -579,13 +578,13 @@ void GetFilesList( update_t *p_update, vlc_bool_t b_force )
}
else
{
FREE( tmp_release.psz_major );
FREE( tmp_release.psz_minor );
FREE( tmp_release.psz_revision );
FREE( tmp_release.psz_extra );
FREE( tmp_release.psz_svn_revision );
FREENULL( tmp_release.psz_major );
FREENULL( tmp_release.psz_minor );
FREENULL( tmp_release.psz_revision );
FREENULL( tmp_release.psz_extra );
FREENULL( tmp_release.psz_svn_revision );
tmp_release.i_type = UPDATE_RELEASE_TYPE_STABLE;
FREE( tmp_release.p_files );
FREENULL( tmp_release.p_files );
tmp_release.i_files = 0;
}
}
......@@ -607,7 +606,7 @@ void GetFilesList( update_t *p_update, vlc_bool_t b_force )
tmp_file.psz_description = NULL;
}
}
FREE( psz_eltname );
FREENULL( psz_eltname );
break;
case XML_READER_ENDELEM:
......@@ -623,7 +622,7 @@ void GetFilesList( update_t *p_update, vlc_bool_t b_force )
b_os = VLC_FALSE;
else if( !strcmp( psz_eltname, "arch" ) )
b_arch = VLC_FALSE;
FREE( psz_eltname );
FREENULL( psz_eltname );
break;
case XML_READER_TEXT:
......@@ -631,7 +630,7 @@ void GetFilesList( update_t *p_update, vlc_bool_t b_force )
if( p_release && p_release->i_files )
p_release->p_files[ p_release->i_files - 1 ]
.psz_description = STRDUP( psz_eltvalue );
FREE( psz_eltvalue );
FREENULL( psz_eltvalue );
break;
}
}
......@@ -1115,17 +1114,17 @@ void update_iterator_GetData( update_iterator_t *p_uit )
void update_iterator_ClearData( update_iterator_t *p_uit )
{
p_uit->file.i_type = UPDATE_FILE_TYPE_NONE;
FREE( p_uit->file.psz_md5 );
FREENULL( p_uit->file.psz_md5 );
p_uit->file.l_size = 0;
FREE( p_uit->file.psz_description );
FREE( p_uit->file.psz_url );
FREE( p_uit->release.psz_version );
FREE( p_uit->release.psz_svn_revision );
FREENULL( p_uit->file.psz_description );
FREENULL( p_uit->file.psz_url );
FREENULL( p_uit->release.psz_version );
FREENULL( p_uit->release.psz_svn_revision );
p_uit->release.i_type = UPDATE_RELEASE_TYPE_UNSTABLE;
p_uit->release.i_status = UPDATE_RELEASE_STATUS_NONE;
FREE( p_uit->mirror.psz_name );
FREE( p_uit->mirror.psz_location );
FREE( p_uit->mirror.psz_type );
FREENULL( p_uit->mirror.psz_name );
FREENULL( p_uit->mirror.psz_location );
FREENULL( p_uit->mirror.psz_type );
}
/**
......@@ -1308,7 +1307,7 @@ void update_download_for_real( download_thread_t *p_this )
p_this->psz_status, psz_s1, psz_s2, f_progress );
free( psz_s1 ); free( psz_s2 );
intf_UserProgressUpdate( p_vlc, i_progress,
intf_ProgressUpdate( p_vlc, i_progress,
psz_status, f_progress, 0 );
}
......@@ -1321,7 +1320,7 @@ void update_download_for_real( download_thread_t *p_this )
asprintf( &psz_status, "%s\nDone %s (100.00%%)",
p_this->psz_status, psz_s2 );
free( psz_s2 );
intf_UserProgressUpdate( p_vlc, i_progress, psz_status, 100.0, 0 );
intf_ProgressUpdate( p_vlc, i_progress, psz_status, 100.0, 0 );
free( psz_status );
}
}
......
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