theme_loader.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * theme_loader.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: 52457d116ec1e6256b16b7a01dedde9ceaadedf6 $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
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 along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef THEME_LOADER_HPP
00026 #define THEME_LOADER_HPP
00027 
00028 #include "skin_common.hpp"
00029 #include <string>
00030 #if defined( HAVE_ZLIB_H )
00031 #   include "unzip.h"
00032 #endif
00033 
00034 class ThemeLoader: public SkinObject
00035 {
00036 public:
00037     ThemeLoader( intf_thread_t *pIntf ): SkinObject( pIntf ) { }
00038     virtual ~ThemeLoader() { }
00039 
00040     /// The expected fileName must be an UTF-8 string
00041     bool load( const string &fileName );
00042 
00043 private:
00044 #if defined( HAVE_ZLIB_H )
00045     /// Extract files from an archive (handles tar.gz and zip)
00046     /**
00047      * Expects a string from the current locale.
00048      */
00049     bool extract( const string &fileName );
00050 
00051     /// Extract files from a tar.gz archive
00052     /**
00053      * Expects strings from the current locale.
00054      */
00055     bool extractTarGz( const string &tarFile, const string &rootDir );
00056 
00057     /// Extract files from a .zip archive
00058     /**
00059      * Expects strings from the current locale.
00060      */
00061     bool extractZip( const string &zipFile, const string &rootDir );
00062 
00063     /// Extract the current file from a .zip archive
00064     /**
00065      * Expects a string from the current locale.
00066      */
00067     bool extractFileInZip( unzFile file, const string &rootDir );
00068 
00069     /// Clean up the temporary files created by the extraction
00070     /**
00071      * Expects a string from the current locale.
00072      */
00073     void deleteTempFiles( const string &path );
00074 #endif
00075 
00076     /// Parse the XML file given as a parameter and build the skin
00077     /**
00078      * Expects UTF8 strings
00079      */
00080     bool parse( const string &path, const string &xmlFile );
00081 
00082     /// Recursively look for the XML file from rootDir.
00083     /**
00084      * The first corresponding file found will be chosen and themeFilePath
00085      * will be updated accordingly.
00086      * The method returns true if a theme file was found, false otherwise.
00087      * rootDir and rFilename must both be strings in the current locale,
00088      * whereas themeFilePath will be in UTF8.
00089      */
00090     bool findFile( const string &rootDir, const string &rFileName,
00091                    string &themeFilePath );
00092 
00093     /// Get the base path of a file
00094     string getFilePath( const string &rFullPath );
00095 
00096     /// Replace '/' separators by the actual separator of the OS
00097     string fixDirSeparators( const string &rPath );
00098 };
00099 
00100 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6