]> git.sesse.net Git - vlc/commitdiff
configuration.[ch]: Handling of deprecated options in the command line. Add a new...
authorChristophe Mutricy <xtophe@videolan.org>
Sat, 21 May 2005 15:07:46 +0000 (15:07 +0000)
committerChristophe Mutricy <xtophe@videolan.org>
Sat, 21 May 2005 15:07:46 +0000 (15:07 +0000)
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

include/configuration.h
modules/gui/beos/PreferencesWindow.cpp
modules/gui/macosx/prefs_widgets.m
modules/gui/wxwindows/preferences_widgets.cpp
src/libvlc.h
src/misc/configuration.c

index ea45e72c1062c7f692cb1a4241b4abb9bcec7ad0..92bc61f328ae71a61b0929fc82c4d261cb6597d5 100644 (file)
@@ -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;
index 59f7e19a165b2cc9fe1e99d4cda4e00ace1f49bb..37c8b325bfcdf03c2282d5bba7e1a9086e867fbe 100644 (file)
@@ -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 )
     {
index 66f7adfdf2574e4939ce6b8f43efc0fe14652afd..514a82d34189620798d2fe2e843ac742d4648559 100644 (file)
@@ -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:
index eb26dc01d88ba3e8a180066416ba712ab17c9937..da04c43e9a10e52437f7eccec17c658da081eafb 100644 (file)
@@ -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:
index 3b6fca596da75fb6c88623181d439a9086bea675..48eff4bd3b568082adaedd47c889741a92b59f31 100644 (file)
@@ -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);
index e5e0f53278340328d402bf4e58eee30b2ad1df80..bb44c07271d0932bc08d76e2316cc5c25ac672c6 100644 (file)
@@ -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;