Commit b252ac5c authored by Christophe Mutricy's avatar Christophe Mutricy

configuration.[ch]: Handling of deprecated options in the command line. Add a...

configuration.[ch]: Handling of deprecated options in the command line. Add a new configuration helper add_deprecated( name, b_strict).
gui/*: Don't show deprecated option in the preferences
libvlc.h: add the deprecated options from NEWS. Is there others ?
Could the Mac and BeOS dev, check for their gui, please.
Closes #112

parent f19fc089
......@@ -146,6 +146,9 @@ struct module_config_t
char **ppsz_action_text; /* Friendly names for actions */
int i_action; /* actions list size */
/* Deprecated */
char *psz_current; /* Good option name */
vlc_bool_t b_strict; /* Transitionnal or strict */
/* Misc */
vlc_mutex_t *p_lock; /* Lock to use when modifying the config */
vlc_bool_t b_dirty; /* Dirty flag to indicate a config change */
......@@ -340,6 +343,17 @@ int config_AutoSaveConfigFile( vlc_object_t * );
(i_config+11) * sizeof(module_config_t)); \
{ static module_config_t tmp = { CONFIG_ITEM_BOOL, NULL, name, '\0', text, longtext, NULL, b_value }; p_config[ i_config ] = tmp; p_config[ i_config ].pf_callback = p_callback; p_config[i_config].b_advanced = advc; }
#define add_deprecated( name, strict ) \
i_config++; \
if(!(i_config%10)) p_config = (module_config_t* )realloc(p_config, \
(i_config+11) * sizeof(module_config_t)); \
{ static module_config_t tmp={}; \
p_config[ i_config ] = tmp; \
p_config[ i_config ].i_type = p_config[ i_config -1 ].i_type; \
p_config[ i_config ].psz_name = name; \
p_config[i_config].b_strict = strict; \
p_config[ i_config ].psz_current = p_config[ i_config-1].psz_current?p_config[ i_config-1 ].psz_current:p_config[ i_config-1 ].psz_name; }
/* Modifier macros for the config options (used for fine tuning) */
#define change_short( ch ) \
p_config[i_config].i_short = ch;
......
......@@ -636,6 +636,11 @@ ConfigWidget::ConfigWidget( intf_thread_t * _p_intf, BRect rect,
BRect r;
BMenuItem * menuItem;
/* Skip deprecated options */
if( p_item->psz_current )
{
return;
}
switch( p_item->i_type )
{
......
......@@ -816,6 +816,12 @@ if( MACOS_VERSION >= 10.3 ) \
withView: (NSView *)o_parent_view
{
VLCConfigControl *p_control = NULL;
/* Skip depracated options */
if( _p_item->psz_current )
{
return NULL;
}
switch( _p_item->i_type )
{
case CONFIG_ITEM_STRING:
......
......@@ -48,6 +48,12 @@ ConfigControl *CreateConfigControl( vlc_object_t *p_this,
{
ConfigControl *p_control = NULL;
/*Skip deprecated options */
if( p_item->psz_current )
{
return NULL;
}
switch( p_item->i_type )
{
case CONFIG_ITEM_MODULE:
......
......@@ -983,7 +983,7 @@ vlc_module_begin();
set_subcategory( SUBCAT_VIDEO_VFILTER );
add_module_list_cat( "vout-filter", SUBCAT_VIDEO_VFILTER, NULL, NULL,
FILTER_TEXT, FILTER_LONGTEXT, VLC_FALSE );
add_deprecated( "filter", VLC_FALSE ); /*deprecated since 0.8.2 */
#if 0
add_string( "pixel-ratio", "1", NULL, PIXEL_RATIO_TEXT, PIXEL_RATIO_TEXT );
#endif
......@@ -1010,7 +1010,7 @@ vlc_module_begin();
SUB_PATH_TEXT, SUB_PATH_LONGTEXT, VLC_TRUE );
add_integer( "sub-margin", -1, NULL, SUB_MARGIN_TEXT,
SUB_MARGIN_LONGTEXT, VLC_TRUE );
add_deprecated( "spu-margin", VLC_FALSE ); /*Deprecated since 0.8.2 */
set_section( N_( "Overlays" ) , NULL );
add_module_list_cat( "sub-filter", SUBCAT_VIDEO_SUBPIC, NULL, NULL,
SUB_FILTER_TEXT, SUB_FILTER_LONGTEXT, VLC_TRUE );
......@@ -1042,12 +1042,16 @@ vlc_module_begin();
INPUT_PROGRAMS_TEXT, INPUT_PROGRAMS_LONGTEXT, VLC_FALSE );
add_integer( "audio-track", -1, NULL,
INPUT_AUDIOTRACK_TEXT, INPUT_AUDIOTRACK_LONGTEXT, VLC_FALSE );
add_deprecated( "audio-channel", VLC_FALSE ); /*deprecated since 0.8.2 */
add_integer( "sub-track", -1, NULL,
INPUT_SUBTRACK_TEXT, INPUT_SUBTRACK_LONGTEXT, VLC_FALSE );
add_deprecated("spu-channel",VLC_FALSE); /*deprecated since 0.8.2*/
add_string( "audio-language", "", NULL,
INPUT_AUDIOTRACK_LANG_TEXT, INPUT_AUDIOTRACK_LANG_LONGTEXT, VLC_FALSE );
INPUT_AUDIOTRACK_LANG_TEXT, INPUT_AUDIOTRACK_LANG_LONGTEXT,
VLC_FALSE );
add_string( "sub-language", "", NULL,
INPUT_SUBTRACK_LANG_TEXT, INPUT_SUBTRACK_LANG_LONGTEXT, VLC_FALSE );
INPUT_SUBTRACK_LANG_TEXT, INPUT_SUBTRACK_LANG_LONGTEXT,
VLC_FALSE );
set_section( N_( "Playback control" ) , NULL);
......
......@@ -527,6 +527,8 @@ void config_Duplicate( module_t *p_module, module_config_t *p_orig )
strdup( p_orig[i].psz_type ) : NULL;
p_module->p_config[i].psz_name = p_orig[i].psz_name ?
strdup( p_orig[i].psz_name ) : NULL;
p_module->p_config[i].psz_current = p_orig[i].psz_current?
strdup( p_orig[i].psz_current ) : NULL;
p_module->p_config[i].psz_text = p_orig[i].psz_text ?
strdup( _(p_orig[i].psz_text) ) : NULL;
p_module->p_config[i].psz_longtext = p_orig[i].psz_longtext ?
......@@ -625,6 +627,9 @@ void config_Free( module_t *p_module )
if( p_item->psz_name )
free( p_item->psz_name );
if( p_item->psz_current )
free( p_item->psz_current );
if( p_item->psz_text )
free( p_item->psz_text );
......@@ -1199,7 +1204,9 @@ int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
if( p_item->i_type & CONFIG_HINT )
/* ignore hints */
continue;
/* Ignore deprecated options */
if( p_item->psz_current )
continue;
if( b_autosave && !p_item->b_autosave )
{
i_value = p_item->i_value_saved;
......@@ -1539,40 +1546,69 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
/* Store the configuration option */
p_conf = config_FindConfig( p_this, psz_name );
if( p_conf )
{
/* Check if the option is derecated */
if( p_conf->psz_current )
{
if( !b_ignore_errors )
{
if( p_conf->b_strict )
{
fprintf( stderr,
"Error: option --%s is deprecated. "
"Use --%s instead.\n",
p_conf->psz_name, p_conf->psz_current);
/*free */
for( i_index = 0; p_longopts[i_index].name; i_index++ )
free( (char *)p_longopts[i_index].name );
free( p_longopts );
free( psz_shortopts );
return -1;
}
fprintf(stderr,
"Warning: option --%s is deprecated. "
"You should use --%s instead.\n",
p_conf->psz_name, p_conf->psz_current);
}
psz_name=p_conf->psz_current;
p_conf = config_FindConfig( p_this, psz_name );
}
if( p_conf ) switch( p_conf->i_type )
switch( p_conf->i_type )
{
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_MODULE_LIST:
case CONFIG_ITEM_MODULE_LIST_CAT:
case CONFIG_ITEM_MODULE_CAT:
config_PutPsz( p_this, psz_name, optarg );
break;
case CONFIG_ITEM_INTEGER:
config_PutInt( p_this, psz_name, strtol(optarg, 0, 0));
break;
case CONFIG_ITEM_FLOAT:
config_PutFloat( p_this, psz_name, (float)atof(optarg) );
break;
case CONFIG_ITEM_KEY:
config_PutInt( p_this, psz_name, ConfigStringToKey( optarg ) );
break;
case CONFIG_ITEM_BOOL:
config_PutInt( p_this, psz_name, !flag );
break;
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_MODULE_LIST:
case CONFIG_ITEM_MODULE_LIST_CAT:
case CONFIG_ITEM_MODULE_CAT:
config_PutPsz( p_this, psz_name, optarg );
break;
case CONFIG_ITEM_INTEGER:
config_PutInt( p_this, psz_name, strtol(optarg, 0, 0));
break;
case CONFIG_ITEM_FLOAT:
config_PutFloat( p_this, psz_name, (float)atof(optarg) );
break;
case CONFIG_ITEM_KEY:
config_PutInt( p_this, psz_name, ConfigStringToKey( optarg ) );
break;
case CONFIG_ITEM_BOOL:
config_PutInt( p_this, psz_name, !flag );
break;
}
continue;
}
/* A short option has been recognized */
if( pp_shortopts[i_cmd] != NULL )
}
/* A short option has been recognized */
if( pp_shortopts[i_cmd] != NULL )
{
switch( pp_shortopts[i_cmd]->i_type )
{
switch( pp_shortopts[i_cmd]->i_type )
{
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY:
......@@ -1638,6 +1674,8 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc, char *ppsz_argv[],
fprintf( stderr, "Try `%s --help' for more information.\n",
p_this->p_vlc->psz_object_name );
for( i_index = 0; p_longopts[i_index].name; i_index++ )
free( (char *)p_longopts[i_index].name );
free( p_longopts );
free( psz_shortopts );
return -1;
......
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