From d3d5bb1dfc21ac30b77fc4484ff942d0a9100275 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 20 Mar 2014 21:16:59 +0100 Subject: Make setup files versioned and add fallback for old versions This commit makes setup files (setup.xml and referenced design setup xml file) versioned and adds checks for correct versions. If a newer versioned file is detected, warning is printed out in assumption that a stray cgg version is used. If the version information is missing or is lower than expected version, files are read in legacy mode. Some values are left on defaults and missing mandatory values are either read from renamed keys or made up to suit current requirements. This essentially brings back compatibility with old setup.xml files that are usually part of galleries. However, some values are hardcoded and should be kept in mind to update and test the legacy mode along with future enhancements. --- src/setup.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/setup.h') diff --git a/src/setup.h b/src/setup.h index 1fe6a53..7ce2cd1 100644 --- a/src/setup.h +++ b/src/setup.h @@ -28,6 +28,7 @@ G_BEGIN_DECLS #define TARGET_IMAGE_DIR_PREFIX "_" #define SETUP_XML "setup.xml" +#define SETUP_NATIVE_VERSION 200 /* 2.0 */ /* forward declaration */ @@ -46,6 +47,7 @@ typedef struct { gboolean override_nofullsize; gboolean strip_unused_tags; gchar *setup_xml_path; + gint version; TGalleryDesign *design; @@ -118,12 +120,16 @@ typedef struct { } TGalleryDesignTheme; struct TGalleryDesign { + gint version; GList *image_sizes; GList *themes; gchar **supplemental_files; }; +#define SETUP_IS_LEGACY(s) s->version < SETUP_NATIVE_VERSION +#define SETUP_IS_NATIVE(s) s->version == SETUP_NATIVE_VERSION +#define SETUP_IS_NEWER(s) s->version > SETUP_NATIVE_VERSION /* * find_setup_xml: try to find setup.xml in standard paths @@ -140,6 +146,11 @@ TGallerySetup * parse_setup_xml (const gchar *filename); */ TGalleryDesign * parse_design_setup_xml (const gchar *filename); +/* + * makeup_legacy_design: create design using legacy setup.xml file + */ +TGalleryDesign * makeup_legacy_design (const gchar *filename); + /* * validate_design_setup: validate design.xml file setup */ -- cgit v1.2.3