diff options
author | svntobi <svntobi@cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f> | 2007-08-11 13:12:06 +0000 |
---|---|---|
committer | svntobi <svntobi@cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f> | 2007-08-11 13:12:06 +0000 |
commit | c99ef16f6109264bb008fefaa4b261ad55d113f9 (patch) | |
tree | 69cfe34180ca5d7710ca25cde19da5fca334cf03 | |
parent | 000eb87a300d20db27456cb67f23b2c5481b5204 (diff) | |
download | vdr-plugin-menuorg-c99ef16f6109264bb008fefaa4b261ad55d113f9.tar.gz vdr-plugin-menuorg-c99ef16f6109264bb008fefaa4b261ad55d113f9.tar.bz2 |
got rid of the load error state forwarding
git-svn-id: file:///home/tobias/sandbox/vdr/--/vdr-pkg/vdr-pkg/submenu/trunk@5674 cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/menuorg.cpp | 22 | ||||
-rw-r--r-- | src/submenuprovider.cpp | 22 | ||||
-rw-r--r-- | src/submenuprovider.h | 7 | ||||
-rw-r--r-- | src/xmlmenu.cpp | 32 | ||||
-rw-r--r-- | src/xmlmenu.h | 9 |
6 files changed, 38 insertions, 56 deletions
@@ -72,7 +72,7 @@ BUILD_DEPFILE = .dependencies $(BUILD_DEPFILE): Makefile @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(SRCS) $(SRCS_TESTABLE) \ - | sed "s/.*: \([^ ]*\/\).*/\1\0/" > $@ + | tee dependencies.sik | sed "s/.*: \([^ ]*\/\).*/\1\0/" > $@ $(TESTS_DEPFILE): Makefile $(SRCS_TESTPARTS) @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(SRCS_TESTABLE) $(SRCS_TESTONLY) \ diff --git a/src/menuorg.cpp b/src/menuorg.cpp index 57d424a..2dee9c6 100644 --- a/src/menuorg.cpp +++ b/src/menuorg.cpp @@ -41,14 +41,16 @@ const char* MenuOrgPlugin::Description(void) const char* MenuOrgPlugin::MainMenuEntry(void) { - if(_subMenuProvider->getSomeError()) + if (!_subMenuProvider) { return tr("Failed to load config file"); } else + { return NULL; + } } - + const char *MenuOrgPlugin::CommandLineHelp(void) { // Return a string that describes all known command line options. @@ -63,8 +65,20 @@ bool MenuOrgPlugin::ProcessArgs(int argc, char *argv[]) bool MenuOrgPlugin::Initialize(void) { - _subMenuProvider = new SubMenuProvider(); + XmlMenu xmlMenu; + + MenuNode* menu = xmlMenu.LoadXmlMenu(); + if (menu) + { + _subMenuProvider = new SubMenuProvider(menu); + } + else + { + _subMenuProvider = NULL; + } + RegisterI18n(Phrases); + return true; } @@ -118,7 +132,7 @@ bool MenuOrgPlugin::SetupParse(const char *Name, const char *Value) bool MenuOrgPlugin::Service(const char *Id, void *Data) { - if (strcmp(Id, "SubMenuPatch-v0.1::SubMenuProvider") == 0 && _subMenuProvider->getSomeError() == false) + if (strcmp(Id, "SubMenuPatch-v0.1::SubMenuProvider") == 0 && _subMenuProvider) { ISubMenuProvider** ptr = (ISubMenuProvider**)Data; *ptr = _subMenuProvider; diff --git a/src/submenuprovider.cpp b/src/submenuprovider.cpp index 9844abc..7ed8caa 100644 --- a/src/submenuprovider.cpp +++ b/src/submenuprovider.cpp @@ -4,20 +4,11 @@ #include "pluginmenuitem.h" #include <vdr/plugin.h> -SubMenuProvider::SubMenuProvider() +SubMenuProvider::SubMenuProvider(MenuNode* rootMenu) { - //CreateTestMenus(); - _oXmlMenu.LoadXmlMenu(); - if(_oXmlMenu.getErrorStatus() == false) - { - _currentMenu = _oXmlMenu.GetMenuTree(); - _someError=false; - } - else - { - _someError=true; - } + _currentMenu = _rootMenu = rootMenu; } + MainMenuItemsList* SubMenuProvider::MainMenuItems() { ResetMainMenuItemsList(); @@ -44,7 +35,7 @@ void SubMenuProvider::ResetMainMenuItemsList() void SubMenuProvider::EnterRootMenu() { - _currentMenu = _oXmlMenu.GetMenuTree(); + _currentMenu = _rootMenu; } void SubMenuProvider::EnterSubMenu(cOsdItem* item) @@ -72,8 +63,3 @@ bool SubMenuProvider::LeaveSubMenu() return false; } } - -bool SubMenuProvider::getSomeError() -{ - return _someError; -} diff --git a/src/submenuprovider.h b/src/submenuprovider.h index 2a798df..7505c7c 100644 --- a/src/submenuprovider.h +++ b/src/submenuprovider.h @@ -10,22 +10,19 @@ using namespace SubMenuPatch; class SubMenuProvider: public ISubMenuProvider { private: - bool _someError; - XmlMenu _oXmlMenu; + MenuNode* _rootMenu; MenuNode* _currentMenu; MainMenuItemsList _currentMainMenuItems; public: - SubMenuProvider(); + SubMenuProvider(MenuNode* rootMenu); virtual MainMenuItemsList* MainMenuItems(); virtual void EnterRootMenu(); virtual void EnterSubMenu(cOsdItem* item); virtual bool LeaveSubMenu(); - bool getSomeError(); private: void ResetMainMenuItemsList(); - void CreateTestMenus(); }; #endif diff --git a/src/xmlmenu.cpp b/src/xmlmenu.cpp index 6893038..b3dea53 100644 --- a/src/xmlmenu.cpp +++ b/src/xmlmenu.cpp @@ -10,12 +10,14 @@ using namespace xmlpp; using namespace std; -void XmlMenu::LoadXmlMenu() +MenuNode* XmlMenu::LoadXmlMenu() { // TODO: show how vdr handels the path vars (developer doc) // and change code for dynamic path vars const char *File = "/var/lib/vdr/plugins/vdr-menu.xml"; + MenuNode* menuRoot = new MenuNode(); + try { DomParser parser; @@ -24,28 +26,23 @@ void XmlMenu::LoadXmlMenu() //parser.set_validate(); parser.set_substitute_entities(); //We just want the text to be resolved/unescaped automatically. parser.parse_file(File); - if(parser) - { - //Walk the tree: - MenuCount=0; - const Element* rootElement = parser.get_document()->get_root_node(); //deleted by DomParser. - ParseElement(rootElement, &_rootMenuNode); - _xmlLoadError=false; - } + + + const Element* rootElement = parser.get_document()->get_root_node(); + ParseElement(rootElement, menuRoot); } catch(const std::exception& ex) { + delete menuRoot; + menuRoot = NULL; + //TODO: print output to syslog (isyslog or dsyslog?) cout << "Exception caught: " << ex.what() << endl; isyslog("Exception caught: %s", ex.what()); //TODO: display message on osd - _xmlLoadError=true; } -} - -MenuNode* XmlMenu::GetMenuTree() -{ - return &_rootMenuNode; + + return menuRoot; } void XmlMenu::ParseElement(const Element* element, MenuNode* menuNode) @@ -152,8 +149,3 @@ bool XmlMenu::FindPluginByName(string name, const char** mainMenuEntry, int& plu } return false; } - -bool XmlMenu::getErrorStatus() -{ - return _xmlLoadError; -} diff --git a/src/xmlmenu.h b/src/xmlmenu.h index 84abc8b..4342d3d 100644 --- a/src/xmlmenu.h +++ b/src/xmlmenu.h @@ -9,15 +9,8 @@ namespace xmlpp { class Element; } class XmlMenu { - private: - bool _xmlLoadError; - int MenuCount; - MenuNode _rootMenuNode; - public: - MenuNode* GetMenuTree(); - void LoadXmlMenu(); - bool getErrorStatus(); + MenuNode* LoadXmlMenu(); private: void ParseElement(const xmlpp::Element* a_node, MenuNode* menuNode); |