Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

darwin_specific.m

00001 /*****************************************************************************
00002  * darwin_specific.m: Darwin specific features
00003  *****************************************************************************
00004  * Copyright (C) 2001-2004 the VideoLAN team
00005  * $Id: darwin_specific.m 13240 2005-11-14 17:45:51Z fkuehne $
00006  *
00007  * Authors: Sam Hocevar <[email protected]>
00008  *          Christophe Massiot <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 #include <string.h>                                              /* strdup() */
00025 #include <stdlib.h>                                                /* free() */
00026 
00027 #include <vlc/vlc.h>
00028 
00029 #include <Cocoa/Cocoa.h>
00030 #include <CoreFoundation/CFString.h>
00031 
00032 #ifdef HAVE_LOCALE_H
00033 #   include <locale.h>
00034 #endif
00035 
00036 /*****************************************************************************
00037  * system_Init: fill in program path & retrieve language
00038  *****************************************************************************/
00039 static int FindLanguage( const char * psz_lang )
00040 {
00041     const char ** ppsz_parser;
00042     const char * ppsz_all[] =
00043     {
00044         "Catalan", "ca",
00045         "Danish", "da",
00046         "German", "de",
00047         "British", "en_GB",
00048         "English", "en",
00049         "Spanish", "es",
00050         "French", "fr",
00051         "Galician", "gl",
00052         "Italian", "it",
00053         "Japanese", "ja",
00054         "Korean", "ko",
00055         "Dutch", "nl",
00056         "Brazillian Portuguese", "pt_BR",
00057         "Romanian", "ro",
00058         "Russian", "ru",
00059         "Turkish", "tr",
00060         "Simplified Chinese", "zh_CN", 
00061         "Chinese Traditional", "zh_TW",
00062         NULL
00063     };
00064 
00065     for( ppsz_parser = ppsz_all ; ppsz_parser[0] ; ppsz_parser += 2 )
00066     {
00067         if( !strcmp( psz_lang, ppsz_parser[0] )
00068              || !strcmp( psz_lang, ppsz_parser[1] ) )
00069         {
00070             setenv( "LANG", ppsz_parser[1], 1 );
00071             return 1;
00072         }
00073     }
00074 
00075     return 0;
00076 }
00077 
00078 void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
00079 {
00080     char i_dummy;
00081     char *p_char, *p_oldchar = &i_dummy;
00082 
00083     /* Get the full program path and name */
00084     p_char = p_this->p_libvlc->psz_vlcpath = strdup( ppsz_argv[ 0 ] );
00085 
00086     /* Remove trailing program name */
00087     for( ; *p_char ; )
00088     {
00089         if( *p_char == '/' )
00090         {
00091             *p_oldchar = '/';
00092             *p_char = '\0';
00093             p_oldchar = p_char;
00094         }
00095 
00096         p_char++;
00097     }
00098 
00099     /* Check if $LANG is set. */
00100     if ( (p_char = getenv("LANG")) == NULL )
00101     {
00102         NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
00103 
00104         /* Retrieve user's preferences. */
00105         NSUserDefaults * o_defs = [NSUserDefaults standardUserDefaults];
00106         NSArray * o_languages = [o_defs objectForKey:@"AppleLanguages"];
00107         NSEnumerator * o_enumerator = [o_languages objectEnumerator];
00108         NSString * o_lang;
00109 
00110         while ( (o_lang = [o_enumerator nextObject]) )
00111         {
00112             const char * psz_string = [o_lang lossyCString];
00113             if ( FindLanguage( psz_string ) )
00114             {
00115                 break;
00116             }
00117         }
00118 
00119         [o_pool release];
00120     }
00121 
00122     vlc_mutex_init( p_this, &p_this->p_libvlc->iconv_lock );
00123     p_this->p_libvlc->iconv_macosx = vlc_iconv_open( "UTF-8", "UTF-8-MAC" );
00124 }
00125 
00126 /*****************************************************************************
00127  * system_Configure: check for system specific configuration options.
00128  *****************************************************************************/
00129 void system_Configure( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
00130 {
00131 
00132 }
00133 
00134 /*****************************************************************************
00135  * system_End: free the program path.
00136  *****************************************************************************/
00137 void system_End( vlc_t *p_this )
00138 {
00139     free( p_this->p_libvlc->psz_vlcpath );
00140 
00141     if ( p_this->p_libvlc->iconv_macosx != (vlc_iconv_t)-1 )
00142         vlc_iconv_close( p_this->p_libvlc->iconv_macosx );
00143     vlc_mutex_destroy( &p_this->p_libvlc->iconv_lock );
00144 }
00145 

Generated on Tue Dec 20 10:15:00 2005 for vlc-0.8.4a by  doxygen 1.4.2