Commit 6d51bbdc authored by Gildas Bazin's avatar Gildas Bazin

* ALL: New XML module type.

* include/vlc_xml.h, src/misc/xml.c: core wrapper for XML modules.
* modules/misc/xml/xtag.c: trivial XML parser module.
* modules/misc/xml/libxml.c: XML parser module using libxml2.
* modules/gui/skins2/parser/*: removed dependancy on libxml2 and use an XML module.
parent f90d9508
......@@ -116,6 +116,7 @@ HEADERS_include = \
include/vlc_video.h \
include/vlc_vlm.h \
include/vlc_vod.h \
include/vlc_xml.h \
include/vout_synchro.h \
include/win32_specific.h \
$(NULL)
......@@ -376,6 +377,7 @@ SOURCES_libvlc_common = \
src/misc/error.c \
src/misc/net.c \
src/misc/vlm.c \
src/misc/xml.c \
src/extras/libc.c \
$(NULL)
......
......@@ -444,7 +444,7 @@ AM_CONDITIONAL(BUILD_GETOPT, ${need_getopt})
if test "${SYS}" != "mingw32"; then
AC_TYPE_SIGNAL
AC_CHECK_LIB(m,cos,[
VLC_ADD_LDFLAGS([adjust distort a52tofloat32 dtstofloat32 x264],[-lm])
VLC_ADD_LDFLAGS([adjust distort a52tofloat32 dtstofloat32 x264 goom],[-lm])
])
AC_CHECK_LIB(m,pow,[
VLC_ADD_LDFLAGS([ffmpeg ffmpegaltivec stream_out_transrate i420_rgb faad toolame equalizer vlc],[-lm])
......@@ -954,7 +954,7 @@ VLC_ADD_PLUGINS([trivial_channel_mixer simple_channel_mixer headphone_channel_mi
VLC_ADD_PLUGINS([trivial_mixer spdif_mixer float32_mixer])
VLC_ADD_PLUGINS([aout_file equalizer])
VLC_ADD_PLUGINS([i420_rgb i420_yuy2 i422_yuy2 i420_ymga])
VLC_ADD_PLUGINS([id3 playlist export sgimb m3u])
VLC_ADD_PLUGINS([id3 playlist export sgimb m3u xtag])
VLC_ADD_PLUGINS([rawvideo blend scale time marq])
VLC_ADD_PLUGINS([wav araw subtitle vobsub adpcm a52sys dtssys au])
VLC_ADD_PLUGINS([access_file access_udp access_tcp access_http ipv4 access_mms])
......@@ -2857,6 +2857,39 @@ from http://www.freetype.org/, or configure with --disable-freetype. Have a nice
fi
fi
dnl
dnl libxml2 module
dnl
AC_ARG_ENABLE(libxml2,
[ --enable-libxml2 libxml2 support (default enabled)])
if test "${enable_libxml2}" != "no"
then
XML2_PATH="${PATH}"
AC_ARG_WITH(xml2-config-path,
[ --with-xml2-config-path=PATH xml2-config path (default search in \$PATH)],
[ if test "${with_xml2_config_path}" != "no"; then
XML2_PATH="${with_xml2_config_path}:${PATH}"
fi ])
AC_PATH_PROG(XML2_CONFIG, xml2-config, no, ${XML2_PATH})
if test "${XML2_CONFIG}" != "no"; then
VLC_ADD_CPPFLAGS([xml],[`${XML2_CONFIG} --cflags`])
VLC_ADD_LDFLAGS([xml],[`${XML2_CONFIG} --libs`])
dnl depends on the xmlTextReader extension
LDFLAGS="${LDFLAGS_save} ${LDFLAGS_xml}"
AC_CHECK_LIB(xml2,xmlTextReaderConstName,[
VLC_ADD_PLUGINS([xml]) ],[
AC_MSG_WARN([libxml2 missing the xmlTextReader extension, you should update your version])
if test "${enable_xml2}" = "yes"; then
AC_MSG_ERROR([libxml2 missing the xmlTextReader extension])
fi])
LDFLAGS="${LDFLAGS_save}"
else
if test "${enable_xml2}" = "yes"; then
AC_MSG_ERROR([Could not find libxml2])
fi
fi
fi
dnl
dnl SVG module
dnl
......@@ -3278,33 +3311,6 @@ if test "${enable_skins2}" = "yes" || (test "${SYS}" != "darwin" && test "${SYS}
fi
fi
dnl libxml2
XML2_PATH="${PATH}"
AC_ARG_WITH(xml2-config-path,
[ --with-xml2-config-path=PATH xml2-config path (default search in \$PATH)],
[ if test "${with_xml2_config_path}" != "no"; then
XML2_PATH="${with_xml2_config_path}:${PATH}"
fi ])
AC_PATH_PROG(XML2_CONFIG, xml2-config, no, ${XML2_PATH})
if test "${XML2_CONFIG}" != "no"; then
VLC_ADD_CPPFLAGS([skins2],[`${XML2_CONFIG} --cflags`])
VLC_ADD_LDFLAGS([skins2],[`${XML2_CONFIG} --libs`])
dnl skins2 depends on the xmlTextReader extension
LDFLAGS="${LDFLAGS_save} ${LDFLAGS_skins2}"
AC_CHECK_LIB(xml2,xmlTextReaderConstName,[],[
skins2_missing_lib="yes"
AC_MSG_WARN([libxml2 missing the xmlTextReader extension, you should update your version; maybe you are missing libpng.])
if test "${enable_skins2}" = "yes"; then
AC_MSG_ERROR([libxml2 missing the xmlTextReader extension (required for skins2)])
fi])
LDFLAGS="${LDFLAGS_save}"
else
skins2_missing_lib="yes"
if test "${enable_skins2}" = "yes"; then
AC_MSG_ERROR([Could not find libxml2 (required for skins2)])
fi
fi
if test "${skins2_missing_lib}" = "no" && (test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"); then
VLC_ADD_PLUGINS([skins2])
ALIASES="${ALIASES} svlc"
......@@ -3736,12 +3742,14 @@ then
fi
else
AC_CHECK_HEADERS(goom/goom.h, [
LDFLAGS="${LDFLAGS_save} ${LDFLAGS_goom}"
AC_CHECK_LIB(goom2, goom_init, [
VLC_ADD_PLUGINS([goom])
VLC_ADD_LDFLAGS([goom],[-lgoom2])
],[
AC_MSG_ERROR([Could not find goom on your system: you may get it from http://www.ios-software.com/.])
])
LDFLAGS="${LDFLAGS_save}"
])
fi
fi
......@@ -4225,6 +4233,7 @@ AC_CONFIG_FILES([
modules/misc/network/Makefile
modules/misc/testsuite/Makefile
modules/misc/playlist/Makefile
modules/misc/xml/Makefile
modules/mux/Makefile
modules/mux/mpeg/Makefile
modules/packetizer/Makefile
......
......@@ -370,6 +370,12 @@ typedef struct tls_t tls_t;
typedef struct tls_server_t tls_server_t;
typedef struct tls_session_t tls_session_t;
/* XML */
typedef struct xml_t xml_t;
typedef struct xml_sys_t xml_sys_t;
typedef struct xml_reader_t xml_reader_t;
typedef struct xml_reader_sys_t xml_reader_sys_t;
/* vod server */
typedef struct vod_t vod_t;
typedef struct vod_sys_t vod_sys_t;
......
......@@ -58,6 +58,7 @@
#define VLC_OBJECT_SPU (-24)
#define VLC_OBJECT_TLS (-25)
#define VLC_OBJECT_SD (-26)
#define VLC_OBJECT_XML (-27)
#define VLC_OBJECT_GENERIC (-666)
......
/*****************************************************************************
* xml.h
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Author: Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef _VLC_XML_H
#define _VLC_XML_H
struct xml_t
{
VLC_COMMON_MEMBERS
/* Module properties */
module_t *p_module;
xml_sys_t *p_sys;
xml_reader_t * (*pf_reader_create) ( xml_t *, const char * );
void (*pf_reader_delete) ( xml_reader_t * );
void (*pf_catalog_load) ( xml_t *, const char * );
void (*pf_catalog_add) ( xml_t *, const char *, const char *,
const char * );
};
#define xml_Create( a ) __xml_Create( VLC_OBJECT(a) )
VLC_EXPORT( xml_t *, __xml_Create, ( vlc_object_t * ) );
VLC_EXPORT( void, xml_Delete, ( xml_t * ) );
#define xml_ReaderCreate( a, b ) a->pf_reader_create( a, b )
#define xml_ReaderDelete( a, b ) a->pf_reader_delete( b )
#define xml_CatalogLoad( a, b ) a->pf_catalog_load( a, b )
#define xml_CatalogAdd( a, b, c, d ) a->pf_catalog_add( a, b, c, d )
struct xml_reader_t
{
xml_t *p_xml;
xml_reader_sys_t *p_sys;
int (*pf_read) ( xml_reader_t * );
int (*pf_node_type) ( xml_reader_t * );
char * (*pf_name) ( xml_reader_t * );
char * (*pf_value) ( xml_reader_t * );
int (*pf_next_attr) ( xml_reader_t * );
};
#define xml_ReaderRead( a ) a->pf_read( a )
#define xml_ReaderNodeType( a ) a->pf_node_type( a )
#define xml_ReaderName( a ) a->pf_name( a )
#define xml_ReaderValue( a ) a->pf_value( a )
#define xml_ReaderNextAttr( a ) a->pf_next_attr( a )
#define XML_READER_NONE 0
#define XML_READER_STARTELEM 1
#define XML_READER_ENDELEM 2
#define XML_READER_TEXT 3
#endif
......@@ -22,80 +22,36 @@
*****************************************************************************/
#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 )
{
// 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;
// Try to load the catalog first (needed at least on win32 where
// we don't have a default catalog)
for( it = resPath.begin(); it != resPath.end(); it++ )
{
string catalog_path = (*it) + sep + "skin.catalog";
if( !stat( catalog_path.c_str(), &statBuf ) )
{
msg_Dbg( getIntf(), "Using catalog %s", catalog_path.c_str() );
xmlLoadCatalog( catalog_path.c_str() );
break;
}
}
if( it == resPath.end() )
{
// Ok, try the default one
xmlInitializeCatalog();
}
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;
}
}
void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
{
#define CheckDefault( a, b ) \
if( attr.find(a) == attr.end() ) attr[a] = strdup(b);
#define RequireDefault( a ) \
if( attr.find(a) == attr.end() ) \
{ \
msg_Err( getIntf(), "Bad theme (element: %s, missing attribute: %s)", \
rName.c_str(), a ); \
m_errors = true; return; \
}
if( rName == "Anchor" )
{
RequireDefault( "priority" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "points", "(0,0)" );
CheckDefault( "range", "10" );
const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset,
atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ),
atoi( attr["priority"] ), attr["points"], m_curLayoutId );
......@@ -104,6 +60,10 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Bitmap" )
{
RequireDefault( "id" );
RequireDefault( "file" );
RequireDefault( "alphacolor" );
const BuilderData::Bitmap bitmap( uniqueId( attr["id"] ),
convertFileName( attr["file"] ),
convertColor( attr["alphacolor"] ) );
......@@ -112,6 +72,10 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "BitmapFont" )
{
RequireDefault( "id" );
RequireDefault( "file" );
CheckDefault( "type", "digits" );
const BuilderData::BitmapFont font( uniqueId( attr["id"] ),
convertFileName( attr["file"] ),
attr["type"] );
......@@ -120,10 +84,24 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
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["visible"], attr["up"], attr["down"],
attr["over"], attr["action"], attr["tooltiptext"], attr["help"],
RequireDefault( "up" );
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "down", "none" );
CheckDefault( "over", "none" );
CheckDefault( "action", "none" );
CheckDefault( "tooltiptext", "" );
CheckDefault( "help", "" );
const BuilderData::Button button( uniqueId( attr["id"] ),
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], 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 );
......@@ -131,9 +109,29 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
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["visible"], attr["up1"], attr["down1"], attr["over1"],
RequireDefault( "up1" );
RequireDefault( "up2" );
RequireDefault( "state" );
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "down1", "none" );
CheckDefault( "over1", "none" );
CheckDefault( "down2", "none" );
CheckDefault( "over2", "none" );
CheckDefault( "action1", "none" );
CheckDefault( "action2", "none" );
CheckDefault( "tooltiptext1", "" );
CheckDefault( "tooltiptext2", "" );
CheckDefault( "help", "" );
const BuilderData::Checkbox checkbox( uniqueId( attr["id"] ),
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], 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,
......@@ -144,6 +142,10 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Font" )
{
RequireDefault( "id" );
RequireDefault( "file" );
CheckDefault( "size", "12" );
const BuilderData::Font fontData( uniqueId( attr["id"] ),
convertFileName( attr["file"] ),
atoi( attr["size"] ) );
......@@ -152,6 +154,9 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Group" )
{
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
m_xOffset += atoi( attr["x"] );
m_yOffset += atoi( attr["y"] );
m_xOffsetList.push_back( atoi( attr["x"] ) );
......@@ -160,9 +165,19 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Image" )
{
const BuilderData::Image imageData( uniqueId( attr["id"] ), atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
attr["rightbottom"], attr["visible"],
RequireDefault( "image" );
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "action", "none" );
CheckDefault( "help", "" );
const BuilderData::Image imageData( uniqueId( attr["id"] ),
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], attr["rightbottom"], attr["visible"],
attr["image"], attr["action"], attr["help"], m_curLayer,
m_curWindowId, m_curLayoutId );
m_curLayer++;
......@@ -171,6 +186,14 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Layout" )
{
RequireDefault( "width" );
RequireDefault( "height" );
CheckDefault( "id", "none" );
CheckDefault( "minwidth", "-1" );
CheckDefault( "maxwidth", "-1" );
CheckDefault( "minheight", "-1" );
CheckDefault( "maxheight", "-1" );
m_curLayoutId = uniqueId( attr["id"] );
const BuilderData::Layout layout( m_curLayoutId, atoi( attr["width"] ),
atoi( attr["height"] ), atoi( attr["minwidth"] ),
......@@ -182,6 +205,22 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Playlist" )
{
RequireDefault( "id" );
RequireDefault( "font" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "width", "0" );
CheckDefault( "height", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "fgcolor", "#000000" );
CheckDefault( "playcolor", "#FF0000" );
CheckDefault( "bgcolor1", "#FFFFFF" );
CheckDefault( "bgcolor2", "#FFFFFF" );
CheckDefault( "selcolor", "#0000FF" );
CheckDefault( "help", "" );
m_curListId = uniqueId( attr["id"] );
const BuilderData::List listData( m_curListId, atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"],
......@@ -199,11 +238,25 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "RadialSlider" )
{
RequireDefault( "sequence" );
RequireDefault( "nbimages" );
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "minangle", "0" );
CheckDefault( "maxangle", "360" );
CheckDefault( "value", "none" );
CheckDefault( "tooltiptext", "" );
CheckDefault( "help", "" );
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,
atoi( attr["nbImages"] ), atof( attr["minAngle"] ) * M_PI /180,
atof( attr["maxAngle"] ) * M_PI / 180, attr["value"],
attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId,
m_curLayoutId );
......@@ -213,6 +266,23 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Slider" )
{
RequireDefault( "up" );
RequireDefault( "points" );
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "width", "0" );
CheckDefault( "height", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "down", "none" );
CheckDefault( "over", "none" );
CheckDefault( "thickness", "10" );
CheckDefault( "value", "none" );
CheckDefault( "tooltiptext", "" );
CheckDefault( "help", "" );
string newValue = attr["value"];
if( m_curListId != "" )
{
......@@ -232,6 +302,16 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Text" )
{
RequireDefault( "font" );
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "text", "" );
CheckDefault( "color", "#000000" );
CheckDefault( "width", "0" );
CheckDefault( "help", "" );
const BuilderData::Text textData( uniqueId( attr["id"] ),
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["visible"], attr["font"],
......@@ -244,6 +324,12 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Theme" )
{
RequireDefault( "version" );
CheckDefault( "tooltipfont", "defaultfont" );
CheckDefault( "magnet", "15" );
CheckDefault( "alpha", "255" );
CheckDefault( "movealpha", "255" );
// Check the version
if( strcmp( attr["version"], SKINS_DTD_VERSION ) )
{
......@@ -267,6 +353,16 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Video" )
{
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "width", "0" );
CheckDefault( "height", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
CheckDefault( "help", "" );
const BuilderData::Video videoData( uniqueId( attr["id"] ),
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
atoi( attr["width"] ), atoi( attr["height" ]),
......@@ -279,6 +375,13 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
else if( rName == "Window" )
{
CheckDefault( "id", "none" );
CheckDefault( "visible", "true" );
CheckDefault( "x", "0" );
CheckDefault( "y", "0" );
CheckDefault( "dragdrop", "true" );
CheckDefault( "playondrop", "true" );
m_curWindowId = uniqueId( attr["id"] );
const BuilderData::Window window( m_curWindowId,
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
......@@ -391,4 +494,3 @@ const string SkinParser::uniqueId( const string &id )
return newId;
}
......@@ -40,8 +40,6 @@ 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
......
......@@ -22,110 +22,157 @@
*****************************************************************************/
#include "xmlparser.hpp"
#include "../src/os_factory.hpp"
#include <sys/stat.h>
// Static variable to avoid initializing catalogs twice
static bool m_initialized = false;
XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName ):
SkinObject( pIntf )
{
m_pReader = xmlNewTextReaderFilename( rFileName.c_str() );
m_pXML = xml_Create( pIntf );
if( !m_pXML )
{
msg_Err( getIntf(), "Failed to open XML parser" );
m_pReader = NULL;
return;
}
// Avoid duplicate initialization (mutex needed ?)
if( !m_initialized )
{
LoadCatalog();
m_initialized = true;
}