]> git.sesse.net Git - vlc/blobdiff - src/libvlc-common.c
* Make it possible to give names to vlc objects (psz_object_name
[vlc] / src / libvlc-common.c
index c33e6a736641397e6f697ea3f37e281bcc727a4d..e2ba1cf66ea1b95d4b9f721da4a963faff5ba555 100644 (file)
@@ -101,8 +101,6 @@ static volatile unsigned int i_instances = 0;
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-void LocaleInit( vlc_object_t * );
-void LocaleDeinit( void );
 static void SetLanguage   ( char const * );
 static inline int LoadMessages (void);
 static int  GetFilenames  ( libvlc_int_t *, int, char *[] );
@@ -271,15 +269,12 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
     /*
      * Support for gettext
      */
-    SetLanguage( "" );
+#ifdef HAVE_LC_MESSAGES
+    setlocale( LC_MESSAGES, "" );
+#endif
+    setlocale( LC_CTYPE, "" );
     LoadMessages ();
 
-    /*
-     * Global iconv, must be done after setlocale()
-     * so that vlc_current_charset() works.
-     */
-    LocaleInit( (vlc_object_t *)p_libvlc );
-
     /* Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */
     msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") );
 
@@ -1049,9 +1044,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
     {
         /* System specific cleaning code */
         system_End( p_libvlc );
-
-       /* Destroy global iconv */
-        LocaleDeinit();
     }
     vlc_mutex_unlock( lockval.p_address );
     var_Destroy( p_libvlc_global, "libvlc" );
@@ -1128,6 +1120,7 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc,
     return VLC_SUCCESS;
 };
 
+#if defined (__APPLE__) || defined (WIN32)
 /*****************************************************************************
  * SetLanguage: set the interface language.
  *****************************************************************************
@@ -1135,43 +1128,27 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc,
  * as well as the LC_CTYPE category for string sorting and possible wide
  * character support.
  *****************************************************************************/
-static void SetLanguage ( char const *psz_lang )
+static void SetLanguage ( const char *psz_lang )
 {
-    if (psz_lang == NULL)
-        return;
-
-#if defined( ENABLE_NLS ) \
-     && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
-
-    if( !*psz_lang )
-    {
-#   if defined( HAVE_LC_MESSAGES )
-        setlocale( LC_MESSAGES, "" );
-#   endif
-        setlocale( LC_CTYPE, "" );
-    }
-    else
-    {
 #ifdef __APPLE__
-        /* I need that under Darwin, please check it doesn't disturb
-         * other platforms. --Meuuh */
-        setenv( "LANG", psz_lang, 1 );
-
-#elif defined( SYS_BEOS ) || defined( WIN32 )
-        /* We set LC_ALL manually because it is the only way to set
-         * the language at runtime under eg. Windows. Beware that this
-         * makes the environment unconsistent when libvlc is unloaded and
-         * should probably be moved to a safer place like vlc.c. */
-        static char psz_lcall[20];
-        snprintf( psz_lcall, 19, "LC_ALL=%s", psz_lang );
-        psz_lcall[19] = '\0';
-        putenv( psz_lcall );
-#endif
+    /* I need that under Darwin, please check it doesn't disturb
+     * other platforms. --Meuuh */
+    setenv( "LANG", psz_lang, 1 );
 
-        setlocale( LC_ALL, psz_lang );
-    }
+#else
+    /* We set LC_ALL manually because it is the only way to set
+     * the language at runtime under eg. Windows. Beware that this
+     * makes the environment unconsistent when libvlc is unloaded and
+     * should probably be moved to a safer place like vlc.c. */
+    static char psz_lcall[20];
+    snprintf( psz_lcall, 19, "LC_ALL=%s", psz_lang );
+    psz_lcall[19] = '\0';
+    putenv( psz_lcall );
 #endif
+
+    setlocale( LC_ALL, psz_lang );
 }
+#endif
 
 
 static inline int LoadMessages (void)
@@ -1231,7 +1208,6 @@ static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, char *ppsz_argv[] )
      * and their input options */
     for( i_opt = i_argc - 1; i_opt >= optind; i_opt-- )
     {
-        const char *psz_target;
         i_options = 0;
 
         /* Count the input options */
@@ -1244,27 +1220,10 @@ static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, char *ppsz_argv[] )
         /* TODO: write an internal function of this one, to avoid
          *       unnecessary lookups. */
 
-#ifdef WIN32
-        if( GetVersion() < 0x80000000 )
-        {
-            VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[i_opt],
-                       (char const **)( i_options ? &ppsz_argv[i_opt + 1] :
-                                        NULL ), i_options,
-                       PLAYLIST_INSERT, 0 );
-        }
-        else
-#endif
-        {
-            /* FIXME: it's too late to call FromLocale here. We should
-               convert ALL arguments to UTF8 before they get parsed */
-
-            psz_target = FromLocale( ppsz_argv[ i_opt ] );
-            VLC_AddTarget( p_vlc->i_object_id, psz_target,
+        VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[i_opt],
                        (char const **)( i_options ? &ppsz_argv[i_opt + 1] :
                                         NULL ), i_options,
                        PLAYLIST_INSERT, 0 );
-            LocaleFree( psz_target );
-        }
     }
 
     return VLC_SUCCESS;
@@ -1360,7 +1319,15 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
         if( psz_module_name && strcmp( psz_module_name,
                                        p_parser->psz_object_name ) )
         {
-            continue;
+            char **pp_shortcut = p_parser->pp_shortcuts;
+            while( *pp_shortcut )
+            {
+                if( !strcmp( psz_module_name, *pp_shortcut ) )
+                    break;
+                pp_shortcut ++;
+            }
+            if( !*pp_shortcut )
+                continue;
         }
 
         /* Ignore modules without config options */
@@ -1795,6 +1762,11 @@ static void InitDeviceValues( libvlc_int_t *p_vlc )
     p_connection = dbus_bus_get ( DBUS_BUS_SYSTEM, &error );
     if( dbus_error_is_set( &error ) )
     {
+#ifdef HAVE_HAL_1
+        libhal_ctx_shutdown( ctx, NULL );
+#else
+        hal_shutdown( ctx );
+#endif
         dbus_error_free( &error );
         return;
     }