Commit f812f2cb authored by Cyril Deguet's avatar Cyril Deguet

* all: the DTD lookup for skins2 themes now use XML catalogs:

    The XML file must begin with:
    <!DOCTYPE Theme PUBLIC "-//VideoLAN//DTD VLC Skins V2.0//EN" "skin.dtd">
    (the "skin.dtd" is ignored but should be an URL on the website)
    and the DTD is looked up at runtime in the directories of the resource
    path (see previous commit), e.g /usr/local/share/vlc/skins2/skin.dtd
    -> the DTD doesn't need any more to be shipped with the themes.
parent 9d191f1d
......@@ -22,17 +22,56 @@
*****************************************************************************/
#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 "2.0"
// Static variable to avoid initializing catalogs twice
bool SkinParser::m_initialized = false;
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;
}
}
......
......@@ -40,6 +40,8 @@ class SkinParser: public XMLParser
const BuilderData &getData() const { return m_data; }
private:
// Static variable to avoid initializing catalogs twice
static bool m_initialized;
/// Container for mapping data from the XML
BuilderData m_data;
/// Current IDs
......
......@@ -2,7 +2,7 @@
* xmlparser.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: xmlparser.cpp,v 1.5 2004/02/01 14:44:11 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
......
<!DOCTYPE Theme SYSTEM "skin.dtd">
<!DOCTYPE Theme PUBLIC "-//VideoLAN//DTD VLC Skins V2.0//EN" "skin.dtd">
<Theme version="2.0" magnet="20" alpha="255" movealpha="192" fadetime="500">
<ThemeInfo name="VLC OSX Interface" author="BigBen"
......
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