]> git.sesse.net Git - vlc/commitdiff
* all: the DTD lookup for skins2 themes now use XML catalogs:
authorCyril Deguet <asmax@videolan.org>
Mon, 12 Apr 2004 17:08:58 +0000 (17:08 +0000)
committerCyril Deguet <asmax@videolan.org>
Mon, 12 Apr 2004 17:08:58 +0000 (17:08 +0000)
    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.

modules/gui/skins2/parser/skin_parser.cpp
modules/gui/skins2/parser/skin_parser.hpp
modules/gui/skins2/parser/xmlparser.cpp
share/skins2/default/theme.xml
share/skins2/skin.dtd [moved from share/skins2/default/skin.dtd with 100% similarity]

index c76e365f302e85cee856379013b4110e85a333b1..368d535ac1dc93bb956b51f15e226373a56a1797 100644 (file)
  *****************************************************************************/
 
 #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;
+    }
 }
 
 
index 20d93c3eb4978437fa59b4fc177741cccba9db02..24a0d2ceefb6fcec886c75989d940635dcf68ae2 100644 (file)
@@ -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
index 037fd12f10f2dd2a5d3dc8547cfd3a652bd8a81e..a1dee471108d0e5481a2e9f245d96efa6018304a 100644 (file)
@@ -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>
  *
index 7d61a9298be2b3699331f47cf470fac77ec6b469..a5e6cf4f222ac163e94406b4dfe93b3c35368f7a 100644 (file)
@@ -1,4 +1,4 @@
-<!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"