Commit 4809df7d authored by ipkiss's avatar ipkiss
Browse files

* skins2: fixed several encoding issues. In particular, it should now be

   possible to load a skin on Windows when logged with an account containing
   non-english characters.
parent 93ca90e6
......@@ -1061,7 +1061,7 @@ GenericFont *Builder::getFont( const string &fontId )
string Builder::getFilePath( const string &rFileName ) const
{
OSFactory *pFactory = OSFactory::instance( getIntf() );
return m_path + pFactory->getDirSeparator() + rFileName;
return m_path + pFactory->getDirSeparator() + sFromLocale( rFileName );
}
......
......@@ -66,6 +66,26 @@ class ThemeRepository;
}
/// Wrapper around FromLocale, to avoid the need to call LocaleFree()
static inline string sFromLocale( const string &rLocale )
{
char *s = FromLocale( rLocale.c_str() );
string res = s;
LocaleFree( s );
return res;
}
/// Wrapper around ToLocale, to avoid the need to call LocaleFree()
static inline string sToLocale( const string &rUTF8 )
{
char *s = ToLocale( rUTF8.c_str() );
string res = s;
LocaleFree( s );
return res;
}
//---------------------------------------------------------------------------
// intf_sys_t: description and status of skin interface
//---------------------------------------------------------------------------
......
......@@ -77,7 +77,7 @@ bool ThemeLoader::load( const string &fileName )
// file...
string path = getFilePath( fileName );
#if defined( HAVE_ZLIB_H )
if( ! extract( fileName ) && ! parse( path, fileName ) )
if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) )
return false;
#else
if( ! parse( path, fileName ) )
......@@ -311,7 +311,7 @@ bool ThemeLoader::extract( const string &fileName )
list<string>::const_iterator it;
for( it = resPath.begin(); it != resPath.end(); it++ )
{
if( findFile( *it, WINAMP2_XML_FILE, xmlFile ) )
if( findFile( sToLocale( *it ), WINAMP2_XML_FILE, xmlFile ) )
break;
}
}
......@@ -456,7 +456,7 @@ bool ThemeLoader::findFile( const string &rootDir, const string &rFileName,
// Found the theme file?
if( rFileName == string( pDirContent->d_name ) )
{
themeFilePath = newURI;
themeFilePath = sFromLocale( newURI );
closedir( pCurrDir );
return true;
}
......
......@@ -37,33 +37,59 @@ class ThemeLoader: public SkinObject
ThemeLoader( intf_thread_t *pIntf ): SkinObject( pIntf ) {}
virtual ~ThemeLoader() {}
/**
* The expected fileName must be an UTF-8 string (usually the result of
* a call to FromLocale())
*/
bool load( const string &fileName );
private:
#if defined( HAVE_ZLIB_H )
/// Extract files from an archive (handles tar.gz and zip)
/**
* Expects a string from the current locale.
*/
bool extract( const string &fileName );
/// Extract files from a tar.gz archive
/**
* Expects strings from the current locale.
*/
bool extractTarGz( const string &tarFile, const string &rootDir );
/// Extract files from a .zip archive
/**
* Expects strings from the current locale.
*/
bool extractZip( const string &zipFile, const string &rootDir );
/// Extract the current file from a .zip archive
/**
* Expects a string from the current locale.
*/
bool extractFileInZip( unzFile file, const string &rootDir );
/// Clean up the temporary files created by the extraction
/**
* Expects a string from the current locale.
*/
void deleteTempFiles( const string &path );
#endif
/// Parse the XML file given as a parameter and build the skin
/**
* Expects UTF8 strings
*/
bool parse( const string &path, const string &xmlFile );
/// Recursively look for the XML file from rootDir.
/// The first corresponding file found will be chosen and themeFilePath
/// will be updated accordingly.
/// The method returns true if a theme file was found, false otherwise
/**
* The first corresponding file found will be chosen and themeFilePath
* will be updated accordingly.
* The method returns true if a theme file was found, false otherwise.
* rootDir and rFilename must both be strings in the current locale,
* whereas themeFilePath will be in UTF8.
*/
bool findFile( const string &rootDir, const string &rFileName,
string &themeFilePath );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment