* skin_parser.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
- * $Id: skin_parser.cpp,v 1.5 2004/03/02 21:45:15 ipkiss Exp $
+ * $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
*****************************************************************************/
#include "skin_parser.hpp"
+#include "../src/os_factory.hpp"
#include <math.h>
+#include <libxml/catalog.h>
+#include <sys/stat.h>
// Current DTD version
-#define SKINS_DTD_VERSION "1.99"
+#define SKINS_DTD_VERSION "2.0"
+// Static variable to avoid initializing catalogs twice
+bool SkinParser::m_initialized = false;
-SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName ):
- XMLParser( pIntf, rFileName ), m_xOffset( 0 ), m_yOffset( 0 )
+
+SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName,
+ const string &rPath ):
+ XMLParser( pIntf, rFileName ), m_xOffset( 0 ), m_yOffset( 0 ),
+ m_path( rPath )
{
+ // Avoid duplicate initialization (mutex needed ?)
+ if( !m_initialized )
+ {
+ // Initialize XML catalog support
+ xmlInitializeCatalog();
+
+ // Get the resource path and look for the DTD
+ OSFactory *pOSFactory = OSFactory::instance( getIntf() );
+ const list<string> &resPath = pOSFactory->getResourcePath();
+ const string &sep = pOSFactory->getDirSeparator();
+ list<string>::const_iterator it;
+ struct stat statBuf;
+ for( it = resPath.begin(); it != resPath.end(); it++ )
+ {
+ string path = (*it) + sep + "skin.dtd";
+ if( !stat( path.c_str(), &statBuf ) )
+ {
+ // DTD found
+ msg_Dbg( getIntf(), "Using DTD %s", path.c_str() );
+ // Add an entry in the default catalog
+ xmlCatalogAdd( (xmlChar*)"public",
+ (xmlChar*)("-//VideoLAN//DTD VLC Skins V"
+ SKINS_DTD_VERSION "//EN"),
+ (xmlChar*)path.c_str() );
+ break;
+ }
+ }
+ if( it == resPath.end() )
+ {
+ msg_Err( getIntf(), "Cannot find the skins DTD !");
+ }
+ m_initialized = true;
+ }
}
{
const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset,
atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ),
- atoi( attr["priority"] ), attr["points"], m_curWindowId );
+ atoi( attr["priority"] ), attr["points"], m_curLayoutId );
m_data.m_listAnchor.push_back( anchor );
}
else if( rName == "Bitmap" )
{
- const BuilderData::Bitmap bitmap( attr["id"] , attr["file"],
+ const BuilderData::Bitmap bitmap( attr["id"] ,
+ ConvertFileName( attr["file"] ),
ConvertColor( attr["alphacolor"] ) );
m_data.m_listBitmap.push_back( bitmap );
}
+ else if( rName == "BitmapFont" )
+ {
+ const BuilderData::BitmapFont font( attr["id"],
+ ConvertFileName( attr["file"] ),
+ attr["type"] );
+ m_data.m_listBitmapFont.push_back( font );
+ }
+
else if( rName == "Button" )
{
const BuilderData::Button button( uniqueId( attr["id"] ), atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
- attr["rightbottom"], attr["up"], attr["down"], attr["over"],
- attr["action"], attr["tooltiptext"], attr["help"], m_curLayer,
- m_curWindowId, m_curLayoutId );
+ attr["rightbottom"], attr["visible"], attr["up"], attr["down"],
+ attr["over"], attr["action"], attr["tooltiptext"], attr["help"],
+ m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
m_data.m_listButton.push_back( button );
}
- else if( rName == "CheckBox" )
+ else if( rName == "Checkbox" )
{
const BuilderData::Checkbox checkbox( uniqueId( attr["id"] ), atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
- attr["rightbottom"], attr["up1"], attr["down1"], attr["over1"],
+ attr["rightbottom"], attr["visible"], attr["up1"], attr["down1"], attr["over1"],
attr["up2"], attr["down2"], attr["over2"], attr["state"],
attr["action1"], attr["action2"], attr["tooltiptext1"],
attr["tooltiptext2"], attr["help"], m_curLayer, m_curWindowId,
else if( rName == "Font" )
{
- const BuilderData::Font fontData( attr["id"], attr["font"],
+ const BuilderData::Font fontData( attr["id"],
+ ConvertFileName( attr["file"] ),
atoi( attr["size"] ) );
m_data.m_listFont.push_back( fontData );
}
{
const BuilderData::Image imageData( uniqueId( attr["id"] ), atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
- attr["rightbottom"], ConvertBoolean( attr["visible"] ),
- attr["image"], attr["onclick"], attr["help"], m_curLayer,
+ attr["rightbottom"], attr["visible"],
+ attr["image"], attr["action"], attr["help"], m_curLayer,
m_curWindowId, m_curLayoutId );
m_curLayer++;
m_data.m_listImage.push_back( imageData );
{
m_curListId = uniqueId( attr["id"] );
const BuilderData::List listData( m_curListId, atoi( attr["x"] ) +
- m_xOffset, atoi( attr["y"] ) + m_yOffset, atoi( attr["width"]),
- atoi( attr["height"] ), attr["lefttop"], attr["rightbottom"],
+ m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"],
+ atoi( attr["width"]), atoi( attr["height"] ),
+ attr["lefttop"], attr["rightbottom"],
attr["font"], attr["var"], ConvertColor( attr["fgcolor"] ),
ConvertColor( attr["playcolor"] ),
ConvertColor( attr["bgcolor1"] ),
else if( rName == "RadialSlider" )
{
- const BuilderData::RadialSlider radial( uniqueId( attr["id"] ), attr["visible"],
+ const BuilderData::RadialSlider radial( uniqueId( attr["id"] ),
+ attr["visible"],
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], attr["rightbottom"], attr["sequence"],
atoi( attr["nbImages"] ), atof( attr["minAngle"] ) * M_PI / 180,
// Slider associated to a list
newValue = "playlist.slider";
}
- const BuilderData::Slider slider( uniqueId( attr["id"] ), attr["visible"],
+ const BuilderData::Slider slider( uniqueId( attr["id"] ),
+ attr["visible"],
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], attr["rightbottom"], attr["up"], attr["down"],
attr["over"], attr["points"], atoi( attr["thickness"] ),
else if( rName == "Text" )
{
- const BuilderData::Text textData( uniqueId( attr["id"] ), atoi( attr["x"] ) +
- m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["font"],
+ const BuilderData::Text textData( uniqueId( attr["id"] ),
+ atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
+ attr["visible"], attr["font"],
attr["text"], atoi( attr["width"] ),
ConvertColor( attr["color"] ), attr["help"], m_curLayer,
m_curWindowId, m_curLayoutId );
m_errors = true;
return;
}
- const BuilderData::Theme theme( atoi( attr["magnet"] ),
- atoi( attr["alpha"] ), atoi( attr["movealpha"] ),
- atoi( attr["fadetime"] ) );
+ const BuilderData::Theme theme( attr["tooltipfont"],
+ atoi( attr["magnet"] ), atoi( attr["alpha"] ),
+ atoi( attr["movealpha"] ), atoi( attr["fadetime"] ) );
m_data.m_listTheme.push_back( theme );
}
attr["author"] );
}
+ else if( rName == "Video" )
+ {
+ const BuilderData::Video videoData( uniqueId( attr["id"] ),
+ atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
+ atoi( attr["width"] ), atoi( attr["height" ]),
+ attr["lefttop"], attr["rightbottom"],
+ attr["visible"], attr["help"], m_curLayer,
+ m_curWindowId, m_curLayoutId );
+ m_curLayer++;
+ m_data.m_listVideo.push_back( videoData );
+ }
+
else if( rName == "Window" )
{
m_curWindowId = uniqueId( attr["id"] );
return ( iRed << 16 | iGreen << 8 | iBlue );
}
+string SkinParser::ConvertFileName( const char *fileName ) const
+{
+ return m_path + string( fileName );
+}
+
const string SkinParser::generateId() const
{
static int i = 1;