bool ThemeLoader::load( const string &fileName ) { string path = getFilePath( fileName ); //Before all, let's see if the file is present struct stat p_stat; if( vlc_stat( fileName.c_str(), &p_stat ) ) return false; // First, we try to un-targz the file, and if it fails we hope it's a XML // file... #if defined( HAVE_ZLIB_H ) if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) ) return false; #else if( ! parse( path, fileName ) ) return false; #endif Theme *pNewTheme = getIntf()->p_sys->p_theme; if( !pNewTheme ) return false; // Restore the theme configuration getIntf()->p_sys->p_theme->loadConfig(); // Retain new loaded skins in config config_PutPsz( getIntf(), "skins2-last", fileName.c_str() ); return true; }
bool ThemeLoader::load( const string &fileName ) { string path = getFilePath( fileName ); //Before all, let's see if the file is present struct stat p_stat; if( vlc_stat( path.c_str(), &p_stat ) ) return false; // First, we try to un-targz the file, and if it fails we hope it's a XML // file... #if defined( HAVE_ZLIB_H ) if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) ) return false; #else if( ! parse( path, fileName ) ) return false; #endif Theme *pNewTheme = getIntf()->p_sys->p_theme; if( !pNewTheme ) { return false; } // Check if the skin to load is in the config file, to load its config char *skin_last = config_GetPsz( getIntf(), "skins2-last" ); if( skin_last != NULL && fileName == (string)skin_last ) { // Restore the theme configuration getIntf()->p_sys->p_theme->loadConfig(); // Used to anchor the windows at the beginning pNewTheme->getWindowManager().stopMove(); } else { config_PutPsz( getIntf(), "skins2-last", fileName.c_str() ); // Show the windows pNewTheme->getWindowManager().showAll( true ); } free( skin_last ); return true; }
bool ThemeLoader::load( const string &fileName ) { // First, we try to un-targz the file, and if it fails we hope it's a XML // file... string path = getFilePath( fileName ); #if defined( HAVE_ZLIB_H ) if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) ) return false; #else if( ! parse( path, fileName ) ) return false; #endif Theme *pNewTheme = getIntf()->p_sys->p_theme; if( !pNewTheme ) { return false; } // Check if the skin to load is in the config file, to load its config char *skin_last = config_GetPsz( getIntf(), "skins2-last" ); if( skin_last != NULL && fileName == (string)skin_last ) { // Restore the theme configuration getIntf()->p_sys->p_theme->loadConfig(); // Used to anchor the windows at the beginning pNewTheme->getWindowManager().stopMove(); } else { config_PutPsz( getIntf(), "skins2-last", fileName.c_str() ); // Show the windows pNewTheme->getWindowManager().showAll( true ); } if( skin_last ) free( skin_last ); // The new theme cannot embed a video output yet VlcProc::instance( getIntf() )->dropVout(); return true; }
bool ThemeLoader::extract( const string &fileName ) { bool result = true; char *tmpdir = tempnam( NULL, "vlt" ); string tempPath = tmpdir; free( tmpdir ); // Extract the file in a temporary directory if( ! extractTarGz( fileName, tempPath ) && ! extractZip( fileName, tempPath ) ) { deleteTempFiles( tempPath ); return false; } string path; string xmlFile; OSFactory *pOsFactory = OSFactory::instance( getIntf() ); // Find the XML file in the theme if( findFile( tempPath, DEFAULT_XML_FILE, xmlFile ) ) { path = getFilePath( xmlFile ); } else { // No XML file, check if it is a winamp2 skin string mainBmp; if( findFile( tempPath, "main.bmp", mainBmp ) ) { msg_Dbg( getIntf(), "trying to load a winamp2 skin" ); path = getFilePath( mainBmp ); // Look for winamp2.xml in the resource path list<string> resPath = pOsFactory->getResourcePath(); list<string>::const_iterator it; for( it = resPath.begin(); it != resPath.end(); it++ ) { if( findFile( sToLocale( *it ), WINAMP2_XML_FILE, xmlFile ) ) break; } } } if( !xmlFile.empty() ) { // Parse the XML file if (! parse( path, xmlFile ) ) { msg_Err( getIntf(), "error while parsing %s", xmlFile.c_str() ); result = false; } } else { msg_Err( getIntf(), "no XML found in theme %s", fileName.c_str() ); result = false; } // Clean-up deleteTempFiles( tempPath ); return result; }