gui: rewrite theme loading code
- Reduce code duplication for parsing of include files
- Fix crash when styles and templates from included files are referenced
- Fix bug with path concatenation if more than one file is included
Change-Id: I06cd720188df272180fb359097afd73a85952fa8
diff --git a/gui/pages.hpp b/gui/pages.hpp
index 927f3fc..4bfd5b0 100644
--- a/gui/pages.hpp
+++ b/gui/pages.hpp
@@ -88,16 +88,18 @@
bool ProcessNode(xml_node<>* page, std::vector<xml_node<>*> *templates, int depth);
};
+struct LoadingContext;
+
class PageSet
{
public:
- PageSet(const char* xmlFile);
+ PageSet();
virtual ~PageSet();
public:
+ int Load(LoadingContext& ctx, const std::string& filename);
int LoadLanguage(char* languageFile, ZipArchive* package);
- int Load(ZipArchive* package, char* xmlFile, char* languageFile, char* baseLanguageFile);
- int CheckInclude(ZipArchive* package, xml_document<> *parentDoc);
+ void MakeEmergencyConsoleIfNeeded();
Page* FindPage(std::string name);
int SetPage(std::string page);
@@ -117,17 +119,16 @@
int SetKeyBoardFocus(int inFocus);
int NotifyVarChange(std::string varName, std::string value);
- std::vector<xml_node<>*> styles;
void AddStringResource(std::string resource_source, std::string resource_name, std::string value);
protected:
- int LoadPages(xml_node<>* pages);
+ int LoadDetails(LoadingContext& ctx, xml_node<>* root);
+ int LoadPages(LoadingContext& ctx, xml_node<>* pages);
int LoadVariables(xml_node<>* vars);
protected:
ResourceManager* mResources;
std::vector<Page*> mPages;
- std::vector<xml_node<>*> templates;
Page* mCurrentPage;
std::vector<Page*> mOverlays; // Special case for popup dialogs and the lock screen
};
@@ -187,6 +188,7 @@
static HardwareKeyboard *mHardwareKeyboard;
static bool mReloadTheme;
static std::string mStartPage;
+ static LoadingContext* currentLoadingContext;
};
#endif // _PAGES_HEADER_HPP