From 54a81935b17db6a192e51ccbb0c0521dc58ee282 Mon Sep 17 00:00:00 2001 From: svntobi Date: Sun, 9 Sep 2007 23:51:48 +0000 Subject: Changed a lot !!! git-svn-id: file:///home/tobias/sandbox/vdr/--/vdr-pkg/vdr-pkg/menuorg/trunk@6139 cd0d6b48-d4f9-0310-940f-ab8c4eb44d3f --- src/ChildLock.cpp | 70 +++++++++ src/ChildLock.h | 42 ++++++ src/CommandMenuNode.cpp | 107 ++++++++++++++ src/CommandMenuNode.h | 54 +++++++ src/FlatMenuSetup.cpp | 149 +++++++++++++++++++ src/FlatMenuSetup.h | 48 ++++++ src/IChildLockService.h | 56 +++++++ src/IMenuNodeProcessor.h | 43 ++++++ src/MainMenuItemsProvider.cpp | 133 +++++++++++++++++ src/MainMenuItemsProvider.h | 62 ++++++++ src/MenuConfigurationRepository.cpp | 192 ++++++++++++++++++++++++ src/MenuConfigurationRepository.h | 57 ++++++++ src/MenuEditMenusFactory.cpp | 76 ++++++++++ src/MenuEditMenusFactory.h | 56 +++++++ src/MenuItemDefinitionFactory.cpp | 66 +++++++++ src/MenuItemDefinitionFactory.h | 55 +++++++ src/MenuItemSetup.cpp | 101 +++++++++++++ src/MenuItemSetup.h | 48 ++++++ src/MenuNode.cpp | 50 +++++++ src/MenuNode.h | 54 +++++++ src/MenuOrgPlugin.cpp | 158 ++++++++++++++++++++ src/MenuOrgPlugin.h | 58 ++++++++ src/MenuSetupItemsFactory.cpp | 75 ++++++++++ src/MenuSetupItemsFactory.h | 52 +++++++ src/OsdItemDefinition.cpp | 53 +++++++ src/OsdItemDefinition.h | 42 ++++++ src/OsdLineItem.cpp | 29 ++++ src/OsdLineItem.h | 34 +++++ src/OsdXmlItem.cpp | 126 ++++++++++++++++ src/OsdXmlItem.h | 72 +++++++++ src/PluginConfiguration.cpp | 87 +++++++++++ src/PluginConfiguration.h | 58 ++++++++ src/PluginCreator.cpp | 29 ++++ src/PluginItemDefinition.cpp | 56 +++++++ src/PluginItemDefinition.h | 44 ++++++ src/PluginMenuNode.cpp | 106 ++++++++++++++ src/PluginMenuNode.h | 57 ++++++++ src/PluginSetup.cpp | 98 +++++++++++++ src/PluginSetup.h | 52 +++++++ src/RecursiveMenuSetup.cpp | 284 +++++++++++++----------------------- src/RecursiveMenuSetup.h | 44 +++--- src/SeparatorMenuNode.cpp | 58 ++++++++ src/SeparatorMenuNode.h | 46 ++++++ src/SubMenuNode.cpp | 78 ++++++++++ src/SubMenuNode.h | 50 +++++++ src/SystemMenuNode.cpp | 71 +++++++++ src/SystemMenuNode.h | 51 +++++++ src/VdrState.cpp | 68 +++++++++ src/VdrState.h | 47 ++++++ src/XmlConfigurationFactory.cpp | 92 ++++++++++++ src/XmlConfigurationFactory.h | 55 +++++++ src/childlock.cpp | 70 --------- src/childlock.h | 42 ------ src/childlockservice.h | 56 ------- src/commandmenunode.cpp | 104 ------------- src/commandmenunode.h | 53 ------- src/imenunodeprocessor.h | 43 ------ src/linemenunode.cpp | 42 ------ src/linemenunode.h | 43 ------ src/mainmenuitemsprovider.cpp | 149 ------------------- src/mainmenuitemsprovider.h | 64 -------- src/menuconfiguration.cpp | 261 --------------------------------- src/menuconfiguration.h | 63 -------- src/menuitemsetup.cpp | 101 ------------- src/menuitemsetup.h | 48 ------ src/menunode.cpp | 74 ---------- src/menunode.h | 56 ------- src/menuorg.cpp | 160 -------------------- src/menuorg.h | 58 -------- src/menusetup.cpp | 148 ------------------- src/menusetup.h | 48 ------ src/osditemdefinition.cpp | 53 ------- src/osditemdefinition.h | 42 ------ src/osdlineitem.cpp | 29 ---- src/osdlineitem.h | 34 ----- src/osdxmlitem.cpp | 126 ---------------- src/osdxmlitem.h | 72 --------- src/pluginconfiguration.cpp | 87 ----------- src/pluginconfiguration.h | 58 -------- src/plugincreator.cpp | 29 ---- src/pluginitemdefinition.cpp | 54 ------- src/pluginitemdefinition.h | 43 ------ src/pluginmenunode.cpp | 66 --------- src/pluginmenunode.h | 53 ------- src/pluginsetup.cpp | 98 ------------- src/pluginsetup.h | 52 ------- src/submenunode.cpp | 54 ------- src/submenunode.h | 46 ------ src/systemmenunode.cpp | 55 ------- src/systemmenunode.h | 49 ------- 90 files changed, 3543 insertions(+), 2989 deletions(-) create mode 100644 src/ChildLock.cpp create mode 100644 src/ChildLock.h create mode 100644 src/CommandMenuNode.cpp create mode 100644 src/CommandMenuNode.h create mode 100644 src/FlatMenuSetup.cpp create mode 100644 src/FlatMenuSetup.h create mode 100644 src/IChildLockService.h create mode 100644 src/IMenuNodeProcessor.h create mode 100644 src/MainMenuItemsProvider.cpp create mode 100644 src/MainMenuItemsProvider.h create mode 100644 src/MenuConfigurationRepository.cpp create mode 100644 src/MenuConfigurationRepository.h create mode 100644 src/MenuEditMenusFactory.cpp create mode 100644 src/MenuEditMenusFactory.h create mode 100644 src/MenuItemDefinitionFactory.cpp create mode 100644 src/MenuItemDefinitionFactory.h create mode 100644 src/MenuItemSetup.cpp create mode 100644 src/MenuItemSetup.h create mode 100644 src/MenuNode.cpp create mode 100644 src/MenuNode.h create mode 100644 src/MenuOrgPlugin.cpp create mode 100644 src/MenuOrgPlugin.h create mode 100644 src/MenuSetupItemsFactory.cpp create mode 100644 src/MenuSetupItemsFactory.h create mode 100644 src/OsdItemDefinition.cpp create mode 100644 src/OsdItemDefinition.h create mode 100644 src/OsdLineItem.cpp create mode 100644 src/OsdLineItem.h create mode 100644 src/OsdXmlItem.cpp create mode 100644 src/OsdXmlItem.h create mode 100644 src/PluginConfiguration.cpp create mode 100644 src/PluginConfiguration.h create mode 100644 src/PluginCreator.cpp create mode 100644 src/PluginItemDefinition.cpp create mode 100644 src/PluginItemDefinition.h create mode 100644 src/PluginMenuNode.cpp create mode 100644 src/PluginMenuNode.h create mode 100644 src/PluginSetup.cpp create mode 100644 src/PluginSetup.h create mode 100644 src/SeparatorMenuNode.cpp create mode 100644 src/SeparatorMenuNode.h create mode 100644 src/SubMenuNode.cpp create mode 100644 src/SubMenuNode.h create mode 100644 src/SystemMenuNode.cpp create mode 100644 src/SystemMenuNode.h create mode 100644 src/VdrState.cpp create mode 100644 src/VdrState.h create mode 100644 src/XmlConfigurationFactory.cpp create mode 100644 src/XmlConfigurationFactory.h delete mode 100644 src/childlock.cpp delete mode 100644 src/childlock.h delete mode 100644 src/childlockservice.h delete mode 100644 src/commandmenunode.cpp delete mode 100644 src/commandmenunode.h delete mode 100644 src/imenunodeprocessor.h delete mode 100644 src/linemenunode.cpp delete mode 100644 src/linemenunode.h delete mode 100644 src/mainmenuitemsprovider.cpp delete mode 100644 src/mainmenuitemsprovider.h delete mode 100644 src/menuconfiguration.cpp delete mode 100644 src/menuconfiguration.h delete mode 100644 src/menuitemsetup.cpp delete mode 100644 src/menuitemsetup.h delete mode 100644 src/menunode.cpp delete mode 100644 src/menunode.h delete mode 100644 src/menuorg.cpp delete mode 100644 src/menuorg.h delete mode 100644 src/menusetup.cpp delete mode 100644 src/menusetup.h delete mode 100644 src/osditemdefinition.cpp delete mode 100644 src/osditemdefinition.h delete mode 100644 src/osdlineitem.cpp delete mode 100644 src/osdlineitem.h delete mode 100644 src/osdxmlitem.cpp delete mode 100644 src/osdxmlitem.h delete mode 100644 src/pluginconfiguration.cpp delete mode 100644 src/pluginconfiguration.h delete mode 100644 src/plugincreator.cpp delete mode 100644 src/pluginitemdefinition.cpp delete mode 100644 src/pluginitemdefinition.h delete mode 100644 src/pluginmenunode.cpp delete mode 100644 src/pluginmenunode.h delete mode 100644 src/pluginsetup.cpp delete mode 100644 src/pluginsetup.h delete mode 100644 src/submenunode.cpp delete mode 100644 src/submenunode.h delete mode 100644 src/systemmenunode.cpp delete mode 100644 src/systemmenunode.h (limited to 'src') diff --git a/src/ChildLock.cpp b/src/ChildLock.cpp new file mode 100644 index 0000000..35a8496 --- /dev/null +++ b/src/ChildLock.cpp @@ -0,0 +1,70 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "ChildLock.h" +#include +#include "IChildLockService.h" + +IChildLockService* ChildLock::_childLockService = NULL; + +bool ChildLock::IsMenuHidden(const char* MenuName) +{ + if (IChildLockService* childLockService = ChildLockService()) + { + return childLockService->IsMenuHidden(MenuName); + } + else + { + return false; + } +} + +bool ChildLock::IsPluginHidden(cPlugin* Plugin) +{ + if (IChildLockService* childLockService = ChildLockService()) + { + return childLockService->IsPluginHidden(Plugin); + } + else + { + return false; + } +} + +IChildLockService* ChildLock::ChildLockService() +{ + if (!_childLockService) + { + IChildLockService* childLockService; + + if (cPluginManager::CallFirstService(IChildLockService::ServiceId, &childLockService)) + { + _childLockService = childLockService; + } + else + { + _childLockService = NULL; + } + } + + return _childLockService; +} diff --git a/src/ChildLock.h b/src/ChildLock.h new file mode 100644 index 0000000..f129b67 --- /dev/null +++ b/src/ChildLock.h @@ -0,0 +1,42 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___CHILDLOCK_H +#define ___CHILDLOCK_H + +class IChildLockService; +class cPlugin; + +class ChildLock +{ + private: + static IChildLockService* _childLockService; + + public: + static bool IsMenuHidden(const char* MenuName); + static bool IsPluginHidden(cPlugin* Plugin); + + private: + static IChildLockService* ChildLockService(); +}; + +#endif diff --git a/src/CommandMenuNode.cpp b/src/CommandMenuNode.cpp new file mode 100644 index 0000000..217c6c3 --- /dev/null +++ b/src/CommandMenuNode.cpp @@ -0,0 +1,107 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id: submenunode.cpp 5835 2007-08-19 21:45:51Z svntcreutz $ + * + */ + +#include "CommandMenuNode.h" +#include +#include +#include "ChildLock.h" +#include "IMenuNodeProcessor.h" + +using namespace std; + +CommandMenuNode::CommandMenuNode(string text, string command, bool confirm) +{ + _text = text; + _command = command; + _confirm = confirm; +} + +CommandMenuNode* CommandMenuNode::Clone() +{ + return new CommandMenuNode(*this); +} + +cOsdMenu* CommandMenuNode::Execute() +{ + bool confirmed = true; + if (_confirm) + { + confirmed = Interface->Confirm((_text + '?').c_str()); + } + if (confirmed) + { + Skins.Message(mtStatus, (_text + "...").c_str()); + string result = ExecuteCommand(); + Skins.Message(mtStatus, NULL); + if (!result.empty()) + { + return new cMenuText(_text.c_str(), result.c_str(), fontFix); + } + } + return NULL; +} + +string CommandMenuNode::ExecuteCommand() +{ + string result; + dsyslog("executing command '%s'", _command.c_str()); + cPipe pipe; + if (pipe.Open(_command.c_str(), "r")) + { + int c; + while ((c = fgetc(pipe)) != EOF) + { + result += (char) c; + } + pipe.Close(); + } + else + { + esyslog("ERROR: can't open pipe for command '%s'", _command.c_str()); + } + return result; +} + +bool CommandMenuNode::IsHidden() +{ + return ChildLock::IsMenuHidden(_text.c_str()); +} + +void CommandMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) +{ + menuNodeProcessor->ProcessCommandMenuNode(this); +} + +string CommandMenuNode::Command() +{ + return _command; +} + +bool CommandMenuNode::ShouldConfirm() +{ + return _confirm; +} + +string CommandMenuNode::Text() +{ + return _text; +} diff --git a/src/CommandMenuNode.h b/src/CommandMenuNode.h new file mode 100644 index 0000000..2607337 --- /dev/null +++ b/src/CommandMenuNode.h @@ -0,0 +1,54 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___COMMANDMENUNODE_H +#define ___COMMANDMENUNODE_H + +#include "MenuNode.h" +#include + +class IMenuNodeProcessor; + +class CommandMenuNode: public MenuNode +{ + private: + std::string _text; + std::string _command; + bool _confirm; + + public: + CommandMenuNode(std::string text, std::string _command, bool confirm); + std::string Text(); + std::string Command(); + bool ShouldConfirm(); + + // MenuNode + virtual void Process(IMenuNodeProcessor* menuNodeProcessor); + bool IsHidden(); + cOsdMenu* Execute(); + CommandMenuNode* Clone(); + + private: + std::string ExecuteCommand(); +}; + +#endif diff --git a/src/FlatMenuSetup.cpp b/src/FlatMenuSetup.cpp new file mode 100644 index 0000000..fdeda81 --- /dev/null +++ b/src/FlatMenuSetup.cpp @@ -0,0 +1,149 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "FlatMenuSetup.h" +#include "MenuConfigurationRepository.h" +#include "MenuItemSetup.h" +#include "OsdXmlItem.h" +#include +#include +#include +#include + +using namespace xmlpp; +using namespace std; + +cMenuOrgSetup::cMenuOrgSetup(MenuConfigurationRepository& menuConfiguration, bool flatMenuSetup) +:cOsdMenu(tr("Menu Setup")),_menuConfiguration(menuConfiguration) +{ + _flatMenuSetup = flatMenuSetup; + // todo + //CreateMenuItems(_menuConfiguration.Configuration(), 0); +} + +void cMenuOrgSetup::CreateMenuItems(const Element* menuRoot, int iCount) +{ + int cur=Current(); + + if(iCount == 0) + Clear(); + + Node::NodeList children = menuRoot->get_children(); + for (Node::NodeList::iterator i = children.begin(); i != children.end(); i++) + { + const Element* childElement = dynamic_cast(*i); + + if (childElement) + { + const Attribute* nameAttribute = childElement->get_attribute("name"); + + string type = childElement->get_name(); + string name = nameAttribute->get_value(); + + for (int i=0; i <= iCount ;i++) + name = " " + name; + + if ( type == "menu" && _flatMenuSetup) + { + name = "+" + name; + Add(new cOsdXmlItem(name.c_str(), childElement, osUnknown)); + CreateMenuItems(childElement, iCount+1); + } + else + { + if(iCount > 0) + name = " " + name; + + Add(new cOsdXmlItem(name.c_str(), childElement, osUnknown)); + } + } + } + if(iCount == 0) + { + SetCurrent(Get(cur)); + Display(); + DrawButton(); + } +} + +eOSState cMenuOrgSetup::ProcessKey(eKeys Key) +{ + eOSState state = cOsdMenu::ProcessKey(Key); + + if(HasSubMenu()) + { + return state; + } + if(state == osUnknown) + { + switch(Key) + { + case kRed: + DrawButton(); + break; + + case kGreen: + { + cOsdXmlItem *item = (cOsdXmlItem*) Get(Current()); + state = AddSubMenu(new cMenuItemSetup(item)); + } + break; + + case kYellow: + DrawButton(); + break; + + case kBlue: + DrawButton(); + break; + + case kUp: + case kDown: + case kLeft: + DrawButton(); + break; + + case kOk: + if (Interface->Confirm(tr("Apply Changes?"))) + { + // Save it! + } + return osEnd; + break; + + case kBack : + return osBack; + break; + + default: + DrawButton(); + break; + } + } + return state; +} + +void cMenuOrgSetup::DrawButton(void) +{ + SetHelp(tr("Create"),tr("Edit"),tr("Delete"),tr("Move")); + Display(); +} diff --git a/src/FlatMenuSetup.h b/src/FlatMenuSetup.h new file mode 100644 index 0000000..be991f3 --- /dev/null +++ b/src/FlatMenuSetup.h @@ -0,0 +1,48 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MENUSETUP_H +#define ___MENUSETUP_H + +#include +#include + +namespace xmlpp { class Element; } + +class MenuConfigurationRepository; + +class cMenuOrgSetup : public cOsdMenu +{ + private: + MenuConfigurationRepository& _menuConfiguration; + bool _flatMenuSetup; + + public: + cMenuOrgSetup(MenuConfigurationRepository& menuConfiguration, bool flatMenuSetup); + virtual eOSState ProcessKey(eKeys Key); + + private: + void DrawButton(void); + void CreateMenuItems(const xmlpp::Element* menuRoot, int iCount); +}; + +#endif diff --git a/src/IChildLockService.h b/src/IChildLockService.h new file mode 100644 index 0000000..f677f72 --- /dev/null +++ b/src/IChildLockService.h @@ -0,0 +1,56 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___CHILDLOCKSERVICE_H +#define ___CHILDLOCKSERVICE_H + +#include + +class cChannel; +class cRecording; +class cPlugin; +class cTimer; +class cEvent; +class cOsdObject; + +class IChildLockService +{ + public: + static const char* ServiceId; + + public: + virtual ~IChildLockService() {}; + virtual bool IsUnlocked() = 0; + + virtual bool IsMenuProtected(const char* MenuName) = 0; + virtual bool IsChannelProtected(const cChannel* Channel) = 0; + virtual bool IsRecordingProtected(const cRecording* Recording, const char* Name, const char* Base, bool isDirectory) = 0; + virtual bool IsPluginProtected(cPlugin* Plugin) = 0; + + virtual bool IsMenuHidden(const char* MenuName) = 0; + virtual bool IsPluginHidden(cPlugin* Plugin) = 0; + virtual bool IsRecordingHidden(const cRecording* Recording, const char* Name, const char* Base, bool isDirectory) = 0; +}; + +const char* IChildLockService::ServiceId = "ChildLockService-v0.1::ChildLockService"; + +#endif diff --git a/src/IMenuNodeProcessor.h b/src/IMenuNodeProcessor.h new file mode 100644 index 0000000..e0ddab8 --- /dev/null +++ b/src/IMenuNodeProcessor.h @@ -0,0 +1,43 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___IMENUNODEPROCESSOR_H_ +#define ___IMENUNODEPROCESSOR_H_ + +class SystemMenuNode; +class PluginMenuNode; +class SubMenuNode; +class CommandMenuNode; +class SeparatorMenuNode; + +class IMenuNodeProcessor +{ + public: + virtual ~IMenuNodeProcessor() {}; + virtual void ProcessSystemMenuNode(SystemMenuNode* node) = 0; + virtual void ProcessPluginMenuNode(PluginMenuNode* node) = 0; + virtual void ProcessSubMenuNode(SubMenuNode* node) = 0; + virtual void ProcessCommandMenuNode(CommandMenuNode* node) = 0; + virtual void ProcessSeparatorMenuNode(SeparatorMenuNode* node) = 0; +}; + +#endif diff --git a/src/MainMenuItemsProvider.cpp b/src/MainMenuItemsProvider.cpp new file mode 100644 index 0000000..13fab09 --- /dev/null +++ b/src/MainMenuItemsProvider.cpp @@ -0,0 +1,133 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "MainMenuItemsProvider.h" +#include "SubMenuNode.h" +#include "MenuConfigurationRepository.h" +#include "MenuItemDefinitionFactory.h" + +MainMenuItemsProvider::MainMenuItemsProvider(MenuConfigurationRepository& menuConfigurationRepository) + :_menuConfigurationRepository(menuConfigurationRepository) +{ + EnterRootMenu(); +} + +MainMenuItemsProvider::~MainMenuItemsProvider() +{ + ResetMainMenuItemsList(); +} + +MenuItemDefinitions* MainMenuItemsProvider::MainMenuItems() +{ + ResetMainMenuItemsList(); + + for (MenuNodeList::iterator i = _currentMenu->Childs()->begin(); + i != _currentMenu->Childs()->end(); i++) + { + if (!(*i)->IsHidden()) + { + _currentMainMenuItems.push_back(MenuItemDefinitionFactory::CreateFromMenuNode(*i)); + } + } + + return &_currentMainMenuItems; +} + +void MainMenuItemsProvider::ResetMainMenuItemsList() +{ + for( MenuItemDefinitions::iterator i = _currentMainMenuItems.begin(); + i != _currentMainMenuItems.end(); i++) + { + delete *i; + } + _currentMainMenuItems.clear(); +} + +void MainMenuItemsProvider::EnterRootMenu() +{ + _currentMenu = _menuConfigurationRepository.Load(); + // TODO; Handling of unloadable config file should not be done here +} + +void MainMenuItemsProvider::EnterSubMenu(cOsdItem* item) +{ + if (MenuNode* menuNode = MenuNodeMatchingOsdItem(item)) + { + menuNode->Process(this); + } +} + +bool MainMenuItemsProvider::LeaveSubMenu() +{ + if (_currentMenu->Parent()) + { + _currentMenu = _currentMenu->Parent(); + return true; + } + else + { + return false; + } +} + +cOsdMenu* MainMenuItemsProvider::Execute(cOsdItem* item) +{ + if (MenuNode* menuNode = MenuNodeMatchingOsdItem(item)) + { + return menuNode->Execute(); + } + return NULL; +} + +MenuNode* MainMenuItemsProvider::MenuNodeMatchingOsdItem(cOsdItem* item) +{ + for(unsigned int itemIndex=0; itemIndex < _currentMainMenuItems.size(); itemIndex++) + { + IMenuItemDefinition* menuItem = _currentMainMenuItems.at(itemIndex); + if (menuItem->IsCustomOsdItem() && (menuItem->CustomOsdItem() == item)) + { + return _currentMenu->Childs()->at(itemIndex); + } + } + return NULL; +} + +void MainMenuItemsProvider::ProcessCommandMenuNode(CommandMenuNode* node) +{ +} + +void MainMenuItemsProvider::ProcessPluginMenuNode(PluginMenuNode* node) +{ +} + +void MainMenuItemsProvider::ProcessSubMenuNode(SubMenuNode* node) +{ + _currentMenu = node; +} + +void MainMenuItemsProvider::ProcessSystemMenuNode(SystemMenuNode* node) +{ +} + +void MainMenuItemsProvider::ProcessSeparatorMenuNode(SeparatorMenuNode* node) +{ +} diff --git a/src/MainMenuItemsProvider.h b/src/MainMenuItemsProvider.h new file mode 100644 index 0000000..91845be --- /dev/null +++ b/src/MainMenuItemsProvider.h @@ -0,0 +1,62 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MAINMENUITEMSPROVIDER_H +#define ___MAINMENUITEMSPROVIDER_H + +#include +#include "IMenuNodeProcessor.h" + +class MenuNode; +class MenuConfigurationRepository; + +class MainMenuItemsProvider: public IMainMenuItemsProvider, public IMenuNodeProcessor +{ + private: + SubMenuNode* _currentMenu; + MenuItemDefinitions _currentMainMenuItems; + MenuConfigurationRepository& _menuConfigurationRepository; + + public: + MainMenuItemsProvider(MenuConfigurationRepository& menuConfigurationRepository); + ~MainMenuItemsProvider(); + + // IMenuNodeProcessor + MenuItemDefinitions* MainMenuItems(); + void EnterRootMenu(); + void EnterSubMenu(cOsdItem* item); + bool LeaveSubMenu(); + cOsdMenu* Execute(cOsdItem* item); + + // IMenuNodeProcessor + void ProcessSystemMenuNode(SystemMenuNode* node); + void ProcessPluginMenuNode(PluginMenuNode* node); + void ProcessSubMenuNode(SubMenuNode* node); + void ProcessCommandMenuNode(CommandMenuNode* node); + void ProcessSeparatorMenuNode(SeparatorMenuNode* node); + + private: + void ResetMainMenuItemsList(); + MenuNode* MenuNodeMatchingOsdItem(cOsdItem* item); +}; + +#endif diff --git a/src/MenuConfigurationRepository.cpp b/src/MenuConfigurationRepository.cpp new file mode 100644 index 0000000..647bc88 --- /dev/null +++ b/src/MenuConfigurationRepository.cpp @@ -0,0 +1,192 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "MenuConfigurationRepository.h" +#include +#include +#include +#include +#include +#include +#include "SystemMenuNode.h" +#include "SubMenuNode.h" +#include "PluginMenuNode.h" +#include "CommandMenuNode.h" +#include "SeparatorMenuNode.h" +#include "XmlConfigurationFactory.h" + +using namespace xmlpp; +using namespace std; + +const string MenuConfigurationRepository::_dtd = + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" + "\n" + "\n"; + +MenuConfigurationRepository::MenuConfigurationRepository(string menuFileName) +{ + _configurationFileName = menuFileName; + _cachedMenuConfiguration = NULL; + _lastConfigFileModificationTime = 0; +} + +MenuConfigurationRepository::~MenuConfigurationRepository() +{ + delete _cachedMenuConfiguration; +} + +SubMenuNode* MenuConfigurationRepository::Load() +{ + if (ConfigFileHasBeenChange()) + { + try + { + dsyslog("loading menuorg config file from %s", _configurationFileName.c_str()); + + DomParser _parser; + + _parser.set_substitute_entities(); + _parser.parse_file(_configurationFileName); + + DtdValidator validator; + validator.parse_memory(_dtd); + + Document *document = _parser.get_document(); + validator.validate( document ); + + if (document) + { + _lastConfigFileModificationTime = CurrentConfigFileModificationTime(); + delete _cachedMenuConfiguration; + _cachedMenuConfiguration = new SubMenuNode("root"); + CreateMenuTree(document->get_root_node(), _cachedMenuConfiguration); + } + + } + catch(const std::exception& ex) + { + cerr << "menuorg: Exception caught when parsing xml configuration: " << ex.what(); + esyslog("Exception caught when parsing xml configuration. See stderr output for details."); + } + } + return _cachedMenuConfiguration; +} + +void MenuConfigurationRepository::Save(SubMenuNode& menuConfiguration) +{ + Document* doc = XmlConfigurationFactory::CreateXmlConfig(&menuConfiguration); + doc->write_to_file_formatted(_configurationFileName); +} + +bool MenuConfigurationRepository::ConfigFileHasBeenChange() +{ + return (CurrentConfigFileModificationTime() != _lastConfigFileModificationTime); +} + +time_t MenuConfigurationRepository::CurrentConfigFileModificationTime() +{ + struct stat fileState; + if (stat(_configurationFileName.c_str(), &fileState) == 0) + { + return fileState.st_mtim.tv_sec; + } + return 0; +} + +void MenuConfigurationRepository::CreateMenuTree(const Element* menuRoot, SubMenuNode* menuNode) +{ + Node::NodeList children = menuRoot->get_children(); + for (Node::NodeList::iterator i = children.begin(); i != children.end(); i++) + { + const Element* childElement = dynamic_cast(*i); + + if (childElement) + { + string type = childElement->get_name(); + string name = GetAttributeValue(childElement, "name", ""); + + if ( type == "menu") + { + SubMenuNode* subMenu = new SubMenuNode(name); + subMenu->AddToParent(menuNode); + CreateMenuTree(childElement, subMenu); + } + else if (type == "system") + { + menuNode->AddChild(new SystemMenuNode(VdrState::ByName(name), GetTitle(childElement, ""))); + } + else if (type == "plugin") + { + menuNode->AddChild(new PluginMenuNode(name, GetTitle(childElement, ""))); + } + else if (type == "command") + { + string execute = childElement->get_attribute("execute")->get_value(); + bool confirm = GetAttributeValue(childElement, "confirm", "false") == "yes"; + menuNode->AddChild(new CommandMenuNode(name, execute, confirm)); + } + else if (type == "separator") + { + menuNode->AddChild(new SeparatorMenuNode(GetTitle(childElement, ""))); + } + } + } +} + +string MenuConfigurationRepository::UnicodeToLocaleOrIso8859(Glib::ustring unicodeString) +{ + try + { + return Glib::locale_from_utf8(unicodeString); + } + catch (Glib::ConvertError) + { + return Glib::convert_with_fallback(unicodeString, "ISO8859-15", "UTF-8"); + } +} + +string MenuConfigurationRepository::GetTitle(const Element* node, string defaultValue) +{ + return GetAttributeValue(node, "title", defaultValue); +} + +string MenuConfigurationRepository::GetAttributeValue(const Element* node, string name, string defaultValue) +{ + const Attribute* attribute = node->get_attribute(name); + return attribute ? (string) UnicodeToLocaleOrIso8859(attribute->get_value()) : defaultValue; +} diff --git a/src/MenuConfigurationRepository.h b/src/MenuConfigurationRepository.h new file mode 100644 index 0000000..0e6f4f5 --- /dev/null +++ b/src/MenuConfigurationRepository.h @@ -0,0 +1,57 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MENUCONFIGURARION_H +#define ___MENUCONFIGURATION_H + +#include +#include +#include + +namespace xmlpp { class Element; } +class MenuNode; +class SubMenuNode; + +class MenuConfigurationRepository +{ + private: + static const std::string _dtd; + std::string _configurationFileName; + time_t _lastConfigFileModificationTime; + SubMenuNode* _cachedMenuConfiguration; + + public: + MenuConfigurationRepository(std::string menuFileName); + ~MenuConfigurationRepository(); + SubMenuNode* Load(); + void Save(SubMenuNode& menuConfiguration); + + private: + bool ConfigFileHasBeenChange(); + time_t CurrentConfigFileModificationTime(); + void CreateMenuTree(const xmlpp::Element* menuRoot, SubMenuNode* menuNode); + std::string UnicodeToLocaleOrIso8859(Glib::ustring unicodeString); + std::string GetTitle(const xmlpp::Element* node, std::string defaultValue); + std::string GetAttributeValue(const xmlpp::Element* node, std::string name, std::string defaultValue); +}; + +#endif diff --git a/src/MenuEditMenusFactory.cpp b/src/MenuEditMenusFactory.cpp new file mode 100644 index 0000000..745b56f --- /dev/null +++ b/src/MenuEditMenusFactory.cpp @@ -0,0 +1,76 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id: childlock.cpp 5951 2007-08-24 05:45:20Z svntcreutz $ + * + */ + +#include "MenuEditMenusFactory.h" +#include "CommandMenuNode.h" +#include "PluginMenuNode.h" +#include "SystemMenuNode.h" +#include "SubMenuNode.h" +#include "SeparatorMenuNode.h" +#include +#include "RecursiveMenuSetup.h" + +cOsdMenu* MenuEditMenusFactory::Create(MenuNode& menuNode, bool openSubmenuInsteadOfEditing) +{ + cOsdMenu* menu = NULL; + MenuEditMenusFactory editMenusFactory(menu, openSubmenuInsteadOfEditing); + menuNode.Process(&editMenusFactory); + return menu; +} + +void MenuEditMenusFactory::ProcessSystemMenuNode(SystemMenuNode* node) +{ + _menu = new cOsdMenu("Edit System Menu Node"); +} + +void MenuEditMenusFactory::ProcessPluginMenuNode(PluginMenuNode* node) +{ + _menu = new cOsdMenu("Edit Plugin Menu Node"); +} + +void MenuEditMenusFactory::ProcessSubMenuNode(SubMenuNode* node) +{ + if (_openSubmenuInsteadOfEditing) + { + _menu = new RecursiveMenuSetup(NULL, node); + } + else + { + _menu = new cOsdMenu("Edit Sub Menu Node"); + } +} + +void MenuEditMenusFactory::ProcessCommandMenuNode(CommandMenuNode* node) +{ + _menu = new cOsdMenu("Edit Command Menu Node"); +} + +void MenuEditMenusFactory::ProcessSeparatorMenuNode(SeparatorMenuNode* nod) +{ + _menu = new cOsdMenu("Edit Separator Menu Node"); +} + +MenuEditMenusFactory::MenuEditMenusFactory(cOsdMenu*& menu, bool openSubmenuInsteadOfEditing) + :_menu(menu) +{ + _openSubmenuInsteadOfEditing = openSubmenuInsteadOfEditing; +} diff --git a/src/MenuEditMenusFactory.h b/src/MenuEditMenusFactory.h new file mode 100644 index 0000000..4188162 --- /dev/null +++ b/src/MenuEditMenusFactory.h @@ -0,0 +1,56 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MENUEDITMENUSFACTORY_H_ +#define ___MENUEDITMENUSFACTORY_H_ + +#include "IMenuNodeProcessor.h" + +class SubMenuNode; +class SystemMenuNode; +class PluginMenuNode; +class CommandMenuNode; +class SeparatorMenuNode; +class MenuNode; +class cOsdMenu; + +class MenuEditMenusFactory: IMenuNodeProcessor +{ + private: + cOsdMenu*& _menu; + bool _openSubmenuInsteadOfEditing; + + public: + static cOsdMenu* Create(MenuNode& menuNode, bool openSubmenuInsteadOfEditing); + + // IMenuNodeProcessor + void ProcessSystemMenuNode(SystemMenuNode* node); + void ProcessPluginMenuNode(PluginMenuNode* node); + void ProcessSubMenuNode(SubMenuNode* node); + void ProcessCommandMenuNode(CommandMenuNode* node); + void ProcessSeparatorMenuNode(SeparatorMenuNode* node); + + private: + MenuEditMenusFactory(cOsdMenu*& menu, bool openSubmenuInsteadOfEditing); +}; + +#endif diff --git a/src/MenuItemDefinitionFactory.cpp b/src/MenuItemDefinitionFactory.cpp new file mode 100644 index 0000000..d7667de --- /dev/null +++ b/src/MenuItemDefinitionFactory.cpp @@ -0,0 +1,66 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id: mainmenuitemsprovider.cpp 6133 2007-09-05 00:00:12Z svntobi $ + * + */ + +#include "MenuItemDefinitionFactory.h" +#include "SubMenuNode.h" +#include "SystemMenuNode.h" +#include "PluginMenuNode.h" +#include "CommandMenuNode.h" +#include "SeparatorMenuNode.h" +#include "OsdItemDefinition.h" +#include "PluginItemDefinition.h" +#include "OsdLineItem.h" +#include + +using namespace std; + +IMenuItemDefinition* MenuItemDefinitionFactory::CreateFromMenuNode(MenuNode* menuNode) +{ + MenuItemDefinitionFactory* factory = new MenuItemDefinitionFactory(); + menuNode->Process(factory); + return factory->_createdMenuItemDefinition; +} + +void MenuItemDefinitionFactory::ProcessSystemMenuNode(SystemMenuNode* node) +{ + _createdMenuItemDefinition = new OsdItemDefinition(new cOsdItem(node->DisplayText().c_str(), node->State().OSState())); +} + +void MenuItemDefinitionFactory::ProcessPluginMenuNode(PluginMenuNode* node) +{ + _createdMenuItemDefinition = new PluginItemDefinition(node->DisplayText(), node->PluginIndex()); +} + +void MenuItemDefinitionFactory::ProcessSubMenuNode(SubMenuNode* node) +{ + _createdMenuItemDefinition = new OsdItemDefinition(new cOsdItem(node->Text().c_str(), osUser1)); +} + +void MenuItemDefinitionFactory::ProcessCommandMenuNode(CommandMenuNode* node) +{ + _createdMenuItemDefinition = new OsdItemDefinition(new cOsdItem(node->Text().c_str(), osUser2)); +} + +void MenuItemDefinitionFactory::ProcessSeparatorMenuNode(SeparatorMenuNode* node) +{ + _createdMenuItemDefinition = new OsdItemDefinition(new cOsdSeparatorItem(node->DisplayText().c_str())); +} diff --git a/src/MenuItemDefinitionFactory.h b/src/MenuItemDefinitionFactory.h new file mode 100644 index 0000000..1e0ad5f --- /dev/null +++ b/src/MenuItemDefinitionFactory.h @@ -0,0 +1,55 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef MENUITEMDEFINITIONFACTORY_H_ +#define MENUITEMDEFINITIONFACTORY_H_ + +#include +#include "IMenuNodeProcessor.h" + +class MenuNode; +class SystemMenuNode; +class PluginMenuNode; +class SubMenuNode; +class CommandMenuNode; +class SeparatorMenuNode; + +class MenuItemDefinitionFactory: IMenuNodeProcessor +{ + private: + IMenuItemDefinition* _createdMenuItemDefinition; + + public: + static IMenuItemDefinition* CreateFromMenuNode(MenuNode* menuNode); + + // IMenuNodeProcessor + void ProcessSystemMenuNode(SystemMenuNode* node); + void ProcessPluginMenuNode(PluginMenuNode* node); + void ProcessSubMenuNode(SubMenuNode* node); + void ProcessCommandMenuNode(CommandMenuNode* node); + void ProcessSeparatorMenuNode(SeparatorMenuNode* node); + + private: + MenuItemDefinitionFactory(){}; +}; + +#endif diff --git a/src/MenuItemSetup.cpp b/src/MenuItemSetup.cpp new file mode 100644 index 0000000..6059a47 --- /dev/null +++ b/src/MenuItemSetup.cpp @@ -0,0 +1,101 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include +#include "MenuItemSetup.h" +#include "OsdXmlItem.h" + +cMenuItemSetup::cMenuItemSetup(cOsdXmlItem* osdXmlItem) +:cOsdMenu(tr("Item Setup")) +{ + itemTypeText[0] = "System"; + itemTypeText[1] = "Plugin"; + itemTypeText[2] = "Submenu"; + itemTypeText[3] = "Command"; + + _osdXmlItem = osdXmlItem; + _newItemType = _osdXmlItem->getItemType(); + //_newName = _osdXmlItem->getNameAttribute().c_str(); + //_newTitle = _osdXmlItem->getTitleAttribute().c_str(); + asprintf(&_newTitle, "%s", _osdXmlItem->getTitleAttribute().c_str()); + //_newCommand = _osdXmlItem->getCommandAttribute().c_str(); + CreateMenuItems(); +} + +cMenuItemSetup::~cMenuItemSetup() +{ + _osdXmlItem->setNameAttribute(_newName); + _osdXmlItem->setTitleAttribute(_newTitle); + _osdXmlItem->setCommandAttribute(_newCommand); + free(_newName); + free(_newTitle); + free(_newCommand); +} + +// TODO: When exit check if the type was menu and now is changed -> bring a warning on the osd that the subitems will be deleted + +void cMenuItemSetup::CreateMenuItems(void) +{ + esyslog("menuorg: _newItemType=%d", _newItemType); + esyslog("menuorg: _newTitle=%s", _newTitle); + + Clear(); + + Add(new cMenuEditStraItem(tr("Item Type"), (int*) &_newItemType, 4, itemTypeText)); + + switch(_newItemType) + { + case 0: + // Add listItem of valid System Items + //Add(new cMenuEditStraItem(tr("available System Items"),)) + // Add textItem for title attribute + Add(new cMenuEditStrItem(tr("title"), _newTitle, 64, NULL)); + break; + + case 1: + // Add listItem of unused plugins or a submenu with the items + //Add(new cMenuEditStraItem(tr("available Plugins Items"),)) + // Add textItem for title attribute + //Add(new cMenuEditStrItem(tr("title"), VAR, 64, NULL)) + break; + + case 2: + // Add textItem for name attribute + //Add(new cMenuEditStrItem(tr("name"), VAR, 64, NULL)) + break; + + case 3: + // Add textItem for name attribute + //Add(new cMenuEditStrItem(tr("name"), VAR, 64, NULL)) + // Add textItem for command attribute + //Add(new cMenuEditStrItem(tr("command"), VAR, 64, NULL)) + // Add boolItem for confirm attribute + //Add(new cMenuEditBoolItem(tr("confirm"), &_confirm)); + break; + } +} + +eOSState cMenuItemSetup::ProcessKey(eKeys Key) +{ + eOSState state = cOsdMenu::ProcessKey(Key); + return state; +} diff --git a/src/MenuItemSetup.h b/src/MenuItemSetup.h new file mode 100644 index 0000000..b58b33b --- /dev/null +++ b/src/MenuItemSetup.h @@ -0,0 +1,48 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MENUITEMSETUP_H +#define ___MENUITEMSETUP_H + +#include +#include "OsdXmlItem.h" + +class cMenuItemSetup : public cOsdMenu +{ + private: + cOsdXmlItem* _osdXmlItem; + cOsdXmlItem::sItemType _newItemType; + const char* itemTypeText[4]; + char* _newName; + char* _newTitle; + char* _newCommand; + + public: + cMenuItemSetup(cOsdXmlItem* osdXmlItem); + ~cMenuItemSetup(void); + virtual eOSState ProcessKey(eKeys Key); + + private: + void CreateMenuItems(void); +}; + +#endif diff --git a/src/MenuNode.cpp b/src/MenuNode.cpp new file mode 100644 index 0000000..e0b8e1c --- /dev/null +++ b/src/MenuNode.cpp @@ -0,0 +1,50 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "MenuNode.h" +#include "SubMenuNode.h" + +MenuNode::MenuNode() +{ + _parent = NULL; +} + +SubMenuNode* MenuNode::Parent() +{ + return _parent; +} + +void MenuNode::AddToParent(SubMenuNode* parent) +{ + parent->Childs()->push_back(this); + _parent = parent; +} + +cOsdMenu* MenuNode::Execute() +{ + return NULL; +} + +bool MenuNode::IsHidden() +{ + return false; +} diff --git a/src/MenuNode.h b/src/MenuNode.h new file mode 100644 index 0000000..727c5bb --- /dev/null +++ b/src/MenuNode.h @@ -0,0 +1,54 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MENUNODE_H +#define ___MENUNODE_H + +#include + +class IMenuItemDefinition; +class MenuNode; +class cOsdMenu; +class IMenuNodeProcessor; +class SubMenuNode; + +typedef std::vector MenuNodeList; + +class SubMenuNode; + +class MenuNode +{ + private: + SubMenuNode* _parent; + + public: + MenuNode(); + virtual ~MenuNode() {}; + virtual MenuNode* Clone() = 0; + SubMenuNode* Parent(); + virtual void AddToParent(SubMenuNode* parent); + virtual void Process(IMenuNodeProcessor* menuNodeProcessor) = 0; + virtual cOsdMenu* Execute(); + virtual bool IsHidden(); +}; + +#endif diff --git a/src/MenuOrgPlugin.cpp b/src/MenuOrgPlugin.cpp new file mode 100644 index 0000000..038fe4e --- /dev/null +++ b/src/MenuOrgPlugin.cpp @@ -0,0 +1,158 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "version.h" +#include "MenuOrgPlugin.h" +#include "FlatMenuSetup.h" +#include "MenuConfigurationRepository.h" +#include "MainMenuItemsProvider.h" +#include "i18n.h" +#include "PluginSetup.h" + +using namespace std; + +MenuOrgPlugin::MenuOrgPlugin(void) +{ + // Initialize any member variables here. + // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL + // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! + + _subMenuProvider = NULL; +} + +MenuOrgPlugin::~MenuOrgPlugin() +{ + delete _subMenuProvider; + delete _menuConfigurationRepository; +} + +const char* MenuOrgPlugin::Version(void) +{ + return VERSION; +} + +const char* MenuOrgPlugin::Description(void) +{ + return tr("reorganize main menu"); +} + +const char* MenuOrgPlugin::MainMenuEntry(void) +{ + if(_pluginConfiguration.MainMenuEntryHidden()) + return NULL; + else + return tr("Menu-Organizer"); +} + +const char *MenuOrgPlugin::CommandLineHelp(void) +{ + return " -c FILE --config=FILE loads the specified xml file\n" + " (default: ConfigDir/plugins/menuorg.xml)\n"; +} + +bool MenuOrgPlugin::ProcessArgs(int argc, char *argv[]) +{ + static struct option longOptions[] = + { + { "config", required_argument, NULL, 'c'}, + { NULL} + }; + + optind = 0; + opterr = 0; + + int optionChar; + int optionIndex = 0; + while ((optionChar = getopt_long(argc, argv, "c:", longOptions, &optionIndex)) != -1) + { + switch (optionChar) + { + case 'c': + _configFile = optarg; + break; + + default: + cerr << argv[0] << ": " << "invalid option " << argv[optind-1] << endl; + return false; + } + } + return true; +} + +bool MenuOrgPlugin::Initialize(void) +{ + RegisterI18n(Phrases); + + if (_configFile.empty()) + { + _configFile = (string) ConfigDirectory() + "/menuorg.xml"; + } + + _menuConfigurationRepository = new MenuConfigurationRepository(_configFile); + + _subMenuProvider = new MainMenuItemsProvider(*_menuConfigurationRepository); + + return true; +} + +cOsdObject *MenuOrgPlugin::MainMenuAction(void) +{ + return new cMenuOrgSetup(*_menuConfigurationRepository, _pluginConfiguration.MenuSetupStyle()); +} + +cMenuSetupPage *MenuOrgPlugin::SetupMenu(void) +{ + return new PluginSetup(_pluginConfiguration, *_menuConfigurationRepository); +} + +bool MenuOrgPlugin::SetupParse(const char *Name, const char *Value) +{ + return _pluginConfiguration.SetConfigurationOptionByName(Name, Value); +} + +bool MenuOrgPlugin::Service(const char *Id, void *Data) +{ + if (strcmp(Id, MENU_ITEMS_PROVIDER_SERVICE_ID) == 0 && _pluginConfiguration.CustomMenuActive()) + { + if (_subMenuProvider) + { + IMainMenuItemsProvider** ptr = (IMainMenuItemsProvider**)Data; + *ptr = _subMenuProvider; + + return true; + } + else + { + Skins.Message(mtError, tr("Failed to load MenuOrg's config file!")); + } + } + + return false; +} diff --git a/src/MenuOrgPlugin.h b/src/MenuOrgPlugin.h new file mode 100644 index 0000000..6418e10 --- /dev/null +++ b/src/MenuOrgPlugin.h @@ -0,0 +1,58 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MENUORGPLUGIN_H +#define ___MENUORGPLUGIN_H + +#include +#include +#include "PluginConfiguration.h" + +class MainMenuItemsProvider; +class MenuConfigurationRepository; + +class MenuOrgPlugin : public cPlugin +{ + private: + MainMenuItemsProvider* _subMenuProvider; + std::string _configFile; + PluginConfiguration _pluginConfiguration; + MenuConfigurationRepository* _menuConfigurationRepository; + + public: + MenuOrgPlugin(void); + virtual ~MenuOrgPlugin(); + virtual const char* Version(void); + virtual const char* Description(void); + virtual const char* CommandLineHelp(void); + virtual bool ProcessArgs(int argc, char* argv[]); + virtual bool Initialize(void); + virtual const char* MainMenuEntry(void); + virtual cOsdObject* MainMenuAction(void); + virtual cMenuSetupPage *SetupMenu(void); + virtual bool SetupParse(const char* Name, const char* Value); + virtual bool Service(const char* Id, void* Data = NULL); +}; + +extern "C" void* VDRPluginCreator(); + +#endif diff --git a/src/MenuSetupItemsFactory.cpp b/src/MenuSetupItemsFactory.cpp new file mode 100644 index 0000000..6d608f7 --- /dev/null +++ b/src/MenuSetupItemsFactory.cpp @@ -0,0 +1,75 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id: childlock.cpp 5951 2007-08-24 05:45:20Z svntcreutz $ + * + */ + +#include "MenuSetupItemsFactory.h" +#include "SubMenuNode.h" +#include "SystemMenuNode.h" +#include "PluginMenuNode.h" +#include "CommandMenuNode.h" +#include "SeparatorMenuNode.h" +#include +#include + +using namespace std; + +MenuSetupItemsFactory::MenuSetupItemsFactory(cOsdMenu* osdMenu) +{ + _osdMenu = osdMenu; +} + +void MenuSetupItemsFactory::SetupItems(SubMenuNode& rootMenu) +{ + for (MenuNodeList::iterator i = rootMenu.Childs()->begin(); i != rootMenu.Childs()->end(); i++) + { + (*i)->Process(this); + } +} + +void MenuSetupItemsFactory::ProcessSystemMenuNode(SystemMenuNode* node) +{ + string text = "(S) " + node->State().Name(); + _osdMenu->Add(new cOsdItem(text.c_str())); +} + +void MenuSetupItemsFactory::ProcessPluginMenuNode(PluginMenuNode* node) +{ + string text = "(P) " + node->PluginName(); + _osdMenu->Add(new cOsdItem(text.c_str())); +} + +void MenuSetupItemsFactory::ProcessSubMenuNode(SubMenuNode* node) +{ + string text = "(M) " + node->Text(); + _osdMenu->Add(new cOsdItem(text.c_str())); +} + +void MenuSetupItemsFactory::ProcessCommandMenuNode(CommandMenuNode* node) +{ + string text = "(C) " + node->Text(); + _osdMenu->Add(new cOsdItem(text.c_str())); +} + +void MenuSetupItemsFactory::ProcessSeparatorMenuNode(SeparatorMenuNode* node) +{ + string text = (string) "(-) " + node->DisplayText(); + _osdMenu->Add(new cOsdItem(text.c_str())); +} diff --git a/src/MenuSetupItemsFactory.h b/src/MenuSetupItemsFactory.h new file mode 100644 index 0000000..c4f36a8 --- /dev/null +++ b/src/MenuSetupItemsFactory.h @@ -0,0 +1,52 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___MENUSETUPITEMSFACTORY_H_ +#define ___MENUSETUPITEMSFACTORY_H_ + +#include "IMenuNodeProcessor.h" + +class SubMenuNode; +class SystemMenuNode; +class PluginMenuNode; +class CommandMenuNode; +class SeparatorMenuNode; +class cOsdMenu; + +class MenuSetupItemsFactory: IMenuNodeProcessor +{ + private: + cOsdMenu* _osdMenu; + + public: + MenuSetupItemsFactory(cOsdMenu* osdMenu); + void SetupItems(SubMenuNode& rootMenu); + + // IMenuNodeProcessor + void ProcessSystemMenuNode(SystemMenuNode* node); + void ProcessPluginMenuNode(PluginMenuNode* node); + void ProcessSubMenuNode(SubMenuNode* node); + void ProcessCommandMenuNode(CommandMenuNode* node); + void ProcessSeparatorMenuNode(SeparatorMenuNode* node); +}; + +#endif diff --git a/src/OsdItemDefinition.cpp b/src/OsdItemDefinition.cpp new file mode 100644 index 0000000..9be51ee --- /dev/null +++ b/src/OsdItemDefinition.cpp @@ -0,0 +1,53 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "OsdItemDefinition.h" + +OsdItemDefinition::OsdItemDefinition(cOsdItem* osdItem) +{ + _osdItem = osdItem; +} + +bool OsdItemDefinition::IsCustomOsdItem() +{ + return true; +} + +bool OsdItemDefinition::IsPluginItem() +{ + return false; +} + +cOsdItem* OsdItemDefinition::CustomOsdItem() +{ + return _osdItem; +} + +const char* OsdItemDefinition::PluginMenuEntry() +{ + return NULL; +} + +int OsdItemDefinition::PluginIndex() +{ + return 0; +} diff --git a/src/OsdItemDefinition.h b/src/OsdItemDefinition.h new file mode 100644 index 0000000..0c4bad7 --- /dev/null +++ b/src/OsdItemDefinition.h @@ -0,0 +1,42 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___OSDITEMDEFINITION_H +#define ___OSDITEMDEFINITION_H + +#include + +class OsdItemDefinition: public IMenuItemDefinition +{ + private: + cOsdItem* _osdItem; + + public: + OsdItemDefinition(cOsdItem* osdItem); + virtual bool IsCustomOsdItem(); + virtual bool IsPluginItem(); + virtual cOsdItem* CustomOsdItem(); + virtual const char* PluginMenuEntry(); + virtual int PluginIndex(); +}; + +#endif diff --git a/src/OsdLineItem.cpp b/src/OsdLineItem.cpp new file mode 100644 index 0000000..f0600df --- /dev/null +++ b/src/OsdLineItem.cpp @@ -0,0 +1,29 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "OsdLineItem.h" + +cOsdSeparatorItem::cOsdSeparatorItem(const char *Text) +{ + SetSelectable(false); + SetText(Text); +} diff --git a/src/OsdLineItem.h b/src/OsdLineItem.h new file mode 100644 index 0000000..85ce6bf --- /dev/null +++ b/src/OsdLineItem.h @@ -0,0 +1,34 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___OSDLINEITEM_H +#define ___OSDLINEITEM_H + +#include + +class cOsdSeparatorItem : public cOsdItem +{ + public: + cOsdSeparatorItem(const char *Text); +}; + +#endif diff --git a/src/OsdXmlItem.cpp b/src/OsdXmlItem.cpp new file mode 100644 index 0000000..1606ec3 --- /dev/null +++ b/src/OsdXmlItem.cpp @@ -0,0 +1,126 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include +#include +#include +#include "OsdXmlItem.h" + +using namespace std; +using namespace xmlpp; + +cOsdXmlItem::cOsdXmlItem(const char* Text, const xmlpp::Element* xmlElement, eOSState State=osUnknown) +: cOsdItem(Text, State) +{ + _xmlElement = xmlElement; + parseXmlElement(); +} + +void cOsdXmlItem::parseXmlElement(void) +{ + const Attribute* nameAttribute = _xmlElement->get_attribute("name"); + + string type = _xmlElement->get_name(); + string name = nameAttribute->get_value(); + + setNameAttribute(name); + + if (type == "system") + { + setItemType(SYSTEM); + const Attribute* titleAttribute = _xmlElement->get_attribute("title"); + string title = titleAttribute ? (string) titleAttribute->get_value() : ""; + setTitleAttribute(title); + } + else if (type == "plugin") + { + setItemType(PLUGIN); + const Attribute* titleAttribute = _xmlElement->get_attribute("title"); + string title = titleAttribute ? (string) titleAttribute->get_value() : ""; + setTitleAttribute(title); + } + else if ( type == "menu") + { + setItemType(MENU); + } + else if (type == "command") + { + setItemType(COMMAND); + + string execute = _xmlElement->get_attribute("execute")->get_value(); + setCommandAttribute(execute); + + const Attribute* confirmAttribute = _xmlElement->get_attribute("confirm"); + if (confirmAttribute) + setConfirmAttribute(confirmAttribute->get_value()); + } +} + +cOsdXmlItem::sItemType cOsdXmlItem::getItemType(void) +{ + return _ItemType; +} + +string cOsdXmlItem::getNameAttribute(void) +{ + return _nameAttribute; +} + +string cOsdXmlItem::getTitleAttribute(void) +{ + return _titleAttribute; +} + +string cOsdXmlItem::getCommandAttribute(void) +{ + return _commandAttribute; +} + +string cOsdXmlItem::getConfirmAttribute(void) +{ + return _confirmAttribute; +} + +void cOsdXmlItem::setItemType(sItemType type) +{ + _ItemType = type; +} + +void cOsdXmlItem::setNameAttribute(string name) +{ + _nameAttribute = name; +} + +void cOsdXmlItem::setTitleAttribute(string title) +{ + _titleAttribute = title; +} + +void cOsdXmlItem::setCommandAttribute(string command) +{ + _commandAttribute = command; +} + +void cOsdXmlItem::setConfirmAttribute(string confirm) +{ + _confirmAttribute = confirm; +} diff --git a/src/OsdXmlItem.h b/src/OsdXmlItem.h new file mode 100644 index 0000000..1167f3d --- /dev/null +++ b/src/OsdXmlItem.h @@ -0,0 +1,72 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___OSDXMLITEM_H +#define ___OSDXMLITEM_H + +#include +#include +#include + +using namespace std; +namespace xmlpp { class Element; } + +class cOsdXmlItem: public cOsdItem +{ + public: + const xmlpp::Element* _xmlElement; + + enum sItemType + { + SYSTEM = 0, + PLUGIN = 1, + MENU = 2, + COMMAND = 3 + }; + + private: + sItemType _ItemType; + string _nameAttribute; + string _titleAttribute; + string _commandAttribute; + string _confirmAttribute; + + public: + cOsdXmlItem(const char* Text, const xmlpp::Element* xmlElement, eOSState State); + + sItemType getItemType(void); + string getNameAttribute(void); + string getTitleAttribute(void); + string getCommandAttribute(void); + string getConfirmAttribute(void); + + void setItemType(sItemType type); + void setNameAttribute(string name); + void setTitleAttribute(string title); + void setCommandAttribute(string command); + void setConfirmAttribute(string confirm); + + private: + void parseXmlElement(void); // parse the xml element and set the private attributes +}; + +#endif diff --git a/src/PluginConfiguration.cpp b/src/PluginConfiguration.cpp new file mode 100644 index 0000000..14f33d6 --- /dev/null +++ b/src/PluginConfiguration.cpp @@ -0,0 +1,87 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id: pluginsetup.h 6098 2007-08-28 12:20:45Z svntcreutz $ + * + */ + +#include "PluginConfiguration.h" +#include +#include + +const char* PluginConfiguration::SetupName::CustomMenuActive = "customMenuActive"; +const char* PluginConfiguration::SetupName::UnconfiguredPluginsIncluded = "unconfiguredPluginsIncluded"; +const char* PluginConfiguration::SetupName::HideMainMenuEntry = "hideMainMenuEntry"; +const char* PluginConfiguration::SetupName::MenuSetupStyle = "menuSetupStyle"; + +PluginConfiguration::PluginConfiguration() +{ + SetDefaults(); +} + +bool PluginConfiguration::CustomMenuActive() +{ + return _customMenuActive; +} + +bool PluginConfiguration::UnconfiguredPluginsInluded() +{ + return _unconfiguredPluginsIncluded; +} + +bool PluginConfiguration::MainMenuEntryHidden() +{ + return _hideMainMenuEntry; +} + +int PluginConfiguration::MenuSetupStyle() +{ + return _menuSetupStyle; +} + +void PluginConfiguration::SetDefaults() +{ + _customMenuActive = true; + _hideMainMenuEntry = true; + _menuSetupStyle = 0; + _unconfiguredPluginsIncluded = true; +} + +bool PluginConfiguration::SetConfigurationOptionByName(const char* Name, const char* Value) +{ + if (!strcasecmp(Name, SetupName::CustomMenuActive)) + { + _customMenuActive = (atoi(Value) != 0); + } + else if(!strcasecmp(Name, SetupName::UnconfiguredPluginsIncluded)) + { + _unconfiguredPluginsIncluded = (atoi(Value) != 0); + } + else if(!strcasecmp(Name, SetupName::HideMainMenuEntry)) + { + _hideMainMenuEntry = (atoi(Value) != 0); + } + else if(!strcasecmp(Name, SetupName::MenuSetupStyle)) + { + _menuSetupStyle = (atoi(Value) != 0); + } + else + return false; + + return true; +} diff --git a/src/PluginConfiguration.h b/src/PluginConfiguration.h new file mode 100644 index 0000000..b90d6b0 --- /dev/null +++ b/src/PluginConfiguration.h @@ -0,0 +1,58 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___PLUGINCONFIGURATION_H_ +#define ___PLUGINCONFIGURATION_H_ + +class PluginConfiguration +{ + friend class PluginSetup; + + private: + struct SetupName + { + static const char* CustomMenuActive; + static const char* UnconfiguredPluginsIncluded; + static const char* HideMainMenuEntry; + static const char* MenuSetupStyle; + }; + + private: + bool _customMenuActive; + bool _unconfiguredPluginsIncluded; + bool _hideMainMenuEntry; + int _menuSetupStyle; + + public: + PluginConfiguration(); + bool SetConfigurationOptionByName(const char* Name, const char* Value); + bool CustomMenuActive(); + bool UnconfiguredPluginsInluded(); + bool MainMenuEntryHidden(); + int MenuSetupStyle(); + + private: + void SetDefaults(); +}; + +#endif + diff --git a/src/PluginCreator.cpp b/src/PluginCreator.cpp new file mode 100644 index 0000000..e845f56 --- /dev/null +++ b/src/PluginCreator.cpp @@ -0,0 +1,29 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "MenuOrgPlugin.h" + +extern "C" void *VDRPluginCreator() +{ + MenuOrgPlugin* plugin = new MenuOrgPlugin(); + return plugin; +} diff --git a/src/PluginItemDefinition.cpp b/src/PluginItemDefinition.cpp new file mode 100644 index 0000000..baf09bd --- /dev/null +++ b/src/PluginItemDefinition.cpp @@ -0,0 +1,56 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "PluginItemDefinition.h" + +using namespace std; + +PluginItemDefinition::PluginItemDefinition(string mainMenuEntry, int pluginIndex) +{ + _mainMenuEntry = mainMenuEntry; + _pluginIndex = pluginIndex; +} + +bool PluginItemDefinition::IsCustomOsdItem() +{ + return false; +} + +bool PluginItemDefinition::IsPluginItem() +{ + return true; +} + +cOsdItem* PluginItemDefinition::CustomOsdItem() +{ + return NULL; +} + +const char* PluginItemDefinition::PluginMenuEntry() +{ + return _mainMenuEntry.c_str(); +} + +int PluginItemDefinition::PluginIndex() +{ + return _pluginIndex; +} diff --git a/src/PluginItemDefinition.h b/src/PluginItemDefinition.h new file mode 100644 index 0000000..8a4be57 --- /dev/null +++ b/src/PluginItemDefinition.h @@ -0,0 +1,44 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___PLUGINITEMDEFINITION_H +#define ___PLUGINITEMDEFINITION_H + +#include +#include + +class PluginItemDefinition: public IMenuItemDefinition +{ + private: + std::string _mainMenuEntry; + int _pluginIndex; + + public: + PluginItemDefinition(std::string mainMenuEntry, int pluginIndex); + virtual bool IsCustomOsdItem(); + virtual bool IsPluginItem(); + virtual cOsdItem* CustomOsdItem(); + virtual const char* PluginMenuEntry(); + virtual int PluginIndex(); +}; + +#endif diff --git a/src/PluginMenuNode.cpp b/src/PluginMenuNode.cpp new file mode 100644 index 0000000..26f01c2 --- /dev/null +++ b/src/PluginMenuNode.cpp @@ -0,0 +1,106 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "PluginMenuNode.h" +#include +#include "ChildLock.h" +#include "IMenuNodeProcessor.h" + +using namespace std; + +PluginMenuNode::PluginMenuNode(string pluginName, string customTitle) +{ + _customTitle = customTitle; + _pluginName = pluginName; + + if (!FindPluginByName(pluginName, _plugin, _pluginIndex)) + { + _plugin = NULL; + _pluginIndex = -1; + } + +} + +PluginMenuNode* PluginMenuNode::Clone() +{ + return new PluginMenuNode(*this); +} + +string PluginMenuNode::CustomTitle() +{ + return _customTitle; +} + +string PluginMenuNode::PluginName() +{ + return _pluginName; +} + +bool PluginMenuNode::IsHidden() +{ + return (!HasMainMenuEntry()) || ChildLock::IsPluginHidden(_plugin); +} + +bool PluginMenuNode::HasMainMenuEntry() +{ + return (_plugin && _plugin->MainMenuEntry()); +} + +void PluginMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) +{ + menuNodeProcessor->ProcessPluginMenuNode(this); +} + +int PluginMenuNode::PluginIndex() +{ + return _pluginIndex; +} + +bool PluginMenuNode::FindPluginByName(string name, cPlugin*& plugin, int& pluginIndex) +{ + int i = 0; + + while (cPlugin *currentPlugin = cPluginManager::GetPlugin(i)) + { + if (name == currentPlugin->Name()) + { + plugin = currentPlugin; + pluginIndex = i; + return true; + } + i++; + } + + return false; +} + +string PluginMenuNode::DisplayText() +{ + if (_customTitle.empty() && HasMainMenuEntry()) + { + return _plugin->MainMenuEntry(); + } + else + { + return _customTitle; + } +} diff --git a/src/PluginMenuNode.h b/src/PluginMenuNode.h new file mode 100644 index 0000000..0f7effd --- /dev/null +++ b/src/PluginMenuNode.h @@ -0,0 +1,57 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___PLUGINMENUNODE_H +#define ___PLUGINMENUNODE_H + +#include +#include "MenuNode.h" + +class cPlugin; +class IMenuNodeProcessor; + +class PluginMenuNode: public MenuNode +{ + private: + cPlugin* _plugin; + int _pluginIndex; + std::string _customTitle; + std::string _pluginName; + + public: + PluginMenuNode(std::string pluginName, std::string customTitle = ""); + std::string CustomTitle(); + std::string PluginName(); + int PluginIndex(); + std::string DisplayText(); + + // MenuNode + void Process(IMenuNodeProcessor* menuNodeProcessor); + bool IsHidden(); + PluginMenuNode* Clone(); + + private: + bool HasMainMenuEntry(); + bool FindPluginByName(std::string name, cPlugin*& plugin, int& pluginIndex); +}; + +#endif diff --git a/src/PluginSetup.cpp b/src/PluginSetup.cpp new file mode 100644 index 0000000..a82a3c1 --- /dev/null +++ b/src/PluginSetup.cpp @@ -0,0 +1,98 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include +#include +#include "MenuOrgPlugin.h" +#include "PluginSetup.h" +#include "FlatMenuSetup.h" +#include "RecursiveMenuSetup.h" +#include "MenuConfigurationRepository.h" + +PluginSetup::PluginSetup(PluginConfiguration& pluginConfiguration, MenuConfigurationRepository& menuConfiguration) + :_pluginConfiguration(pluginConfiguration), _menuConfiguration(menuConfiguration) +{ + CreateMenuItems(); +} + +void PluginSetup::Store(void) +{ + SetupStore(PluginConfiguration::SetupName::CustomMenuActive, + _pluginConfiguration._customMenuActive = _newCustomMenuActive); + SetupStore(PluginConfiguration::SetupName::UnconfiguredPluginsIncluded, + _pluginConfiguration._unconfiguredPluginsIncluded = _newUnconfiguredPluginsIncluded); + SetupStore(PluginConfiguration::SetupName::HideMainMenuEntry, + _pluginConfiguration._hideMainMenuEntry = _newHideMainMenuEntry); + SetupStore(PluginConfiguration::SetupName::MenuSetupStyle, + _pluginConfiguration._menuSetupStyle = _newMenuSetupStyle); +} + +eOSState PluginSetup::ProcessKey(eKeys Key) +{ + eOSState state = cOsdMenu::ProcessKey(Key); + + if (HasSubMenu()) + { + return state; + } + switch(state) + { + case osUser1: + if (_pluginConfiguration.MenuSetupStyle() == 0 ) + { + return AddSubMenu(new cMenuOrgSetup(_menuConfiguration, _pluginConfiguration._menuSetupStyle)); + } + else + { + return AddSubMenu(new RecursiveMenuSetup(&_menuConfiguration)); + } + + case osContinue: + if(NORMALKEY(Key)==kUp || NORMALKEY(Key)==kDown) + { + cOsdItem *item=Get(Current()); + if(item) item->ProcessKey(kNone); + } + break; + + case osUnknown: + if(Key==kOk) + { + Store(); + state=osBack; + } + break; + + default: + break; + } + return state; +} + +void PluginSetup::CreateMenuItems() +{ + Add(new cMenuEditBoolItem(tr("Enable custom menu"), &_newCustomMenuActive)); + Add(new cMenuEditBoolItem(tr("Include unconfigured plugins"), &_newUnconfiguredPluginsIncluded)); + Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &_newHideMainMenuEntry)); + Add(new cMenuEditBoolItem(tr("Menu setup style"), &_newMenuSetupStyle, tr("MenuBased"), tr("Flat"))); + Add(new cOsdItem(tr("Configure menu"), osUser1)); +} diff --git a/src/PluginSetup.h b/src/PluginSetup.h new file mode 100644 index 0000000..6b97d94 --- /dev/null +++ b/src/PluginSetup.h @@ -0,0 +1,52 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___PLUGINSETUP_H +#define ___PLUGINSETUP_H + +#include + +class PluginConfiguration; +class MenuConfigurationRepository; + +class PluginSetup : public cMenuSetupPage +{ + private: + int _newCustomMenuActive; + int _newUnconfiguredPluginsIncluded; + int _newHideMainMenuEntry; + int _newMenuSetupStyle; + PluginConfiguration& _pluginConfiguration; + MenuConfigurationRepository& _menuConfiguration; + + public: + PluginSetup(PluginConfiguration& pluginConfiguration, MenuConfigurationRepository& menuConfiguration); + virtual eOSState ProcessKey(eKeys Key); + + protected: + virtual void Store(void); + + private: + void CreateMenuItems(); +}; + +#endif diff --git a/src/RecursiveMenuSetup.cpp b/src/RecursiveMenuSetup.cpp index 02d5a7e..b31d2d8 100644 --- a/src/RecursiveMenuSetup.cpp +++ b/src/RecursiveMenuSetup.cpp @@ -21,250 +21,164 @@ */ #include "RecursiveMenuSetup.h" -#include "menunode.h" -#include -#include "commandmenunode.h" -#include "pluginmenunode.h" -#include "systemmenunode.h" -#include "submenunode.h" -#include "linemenunode.h" -#include +#include "SubMenuNode.h" +#include "MenuConfigurationRepository.h" +#include "MenuSetupItemsFactory.h" +#include "MenuEditMenusFactory.h" -using namespace std; - -class MenuSetupItemsFactory: IMenuNodeProcessor +RecursiveMenuSetup::RecursiveMenuSetup(MenuConfigurationRepository* menuConfigurationRepository, SubMenuNode* rootMenuNode) + :cOsdMenu(tr("Menu Configuration")), _menuConfigurationRepository(menuConfigurationRepository) { -private: - cOsdMenu* _osdMenu; - -public: - MenuSetupItemsFactory(cOsdMenu* osdMenu) - { - _osdMenu = osdMenu; - } - - void SetupItems(MenuNode& rootMenu) - { - for (MenuNodeList::iterator i = rootMenu.Childs()->begin(); i != rootMenu.Childs()->end(); i++) - { - (*i)->Process(this); - } - } - - // IMenuNodeProcessor - void ProcessSystemMenuNode(SystemMenuNode* node) - { - string text = "(C) " + node->Text(); - _osdMenu->Add(new cOsdItem(text.c_str())); - } - - void ProcessPluginMenuNode(PluginMenuNode* node) - { - string text = "(P) " + node->Title(); - _osdMenu->Add(new cOsdItem(text.c_str())); - } - - void ProcessSubMenuNode(SubMenuNode* node) + _moving = false; + if (rootMenuNode) { - string text = "(M) " + node->Text(); - _osdMenu->Add(new cOsdItem(text.c_str())); + _currentRootMenuNode = rootMenuNode; + _menuConfiguration = NULL; } - - void ProcessCommandMenuNode(CommandMenuNode* node) + else { - string text = "(S) " + node->Text(); - _osdMenu->Add(new cOsdItem(text.c_str())); + _currentRootMenuNode = _menuConfiguration = menuConfigurationRepository->Load()->Clone(); } - - void ProcessLineMenuNode(LineMenuNode* node) - { - string text = (string) "(L) " + "------------------"; - _osdMenu->Add(new cOsdItem(text.c_str())); - } -}; - -class MenuEditMenusFactory: IMenuNodeProcessor -{ -private: - cOsdMenu*& _menu; - -public: - static cOsdMenu* Create(MenuNode& menuNode) - { - cOsdMenu* menu = NULL; - MenuEditMenusFactory editMenusFactory(menu); - menuNode.Process(&editMenusFactory); - return menu; - } - - // IMenuNodeProcessor - void ProcessSystemMenuNode(SystemMenuNode* node) - { - _menu = new cOsdMenu("Edit System Menu Node"); - } - - void ProcessPluginMenuNode(PluginMenuNode* node) - { - _menu = new cOsdMenu("Edit Plugin Menu Node"); - } - - void ProcessSubMenuNode(SubMenuNode* node) - { - _menu = new cOsdMenu("Edit Sub Menu Node"); - } - - void ProcessCommandMenuNode(CommandMenuNode* node) - { - _menu = new cOsdMenu("Edit Command Menu Node"); - } - - void ProcessLineMenuNode(LineMenuNode* nod) - { - _menu = NULL; - } - -private: - MenuEditMenusFactory(cOsdMenu*& menu) - :_menu(menu) - { - } -}; - -RecursiveMenuSetup::RecursiveMenuSetup(MenuNode& rootMenu) - :cOsdMenu(tr("Menu Configuration")), _rootMenu(rootMenu) -{ - _moving = false; - CreateMenuItems(); - ShowHelp(); + CreateMenuItems(); + ShowHelp(); } RecursiveMenuSetup::~RecursiveMenuSetup() { + delete _menuConfiguration; } void RecursiveMenuSetup::CreateMenuItems() { - MenuSetupItemsFactory menuItemSetupFactory(this); - menuItemSetupFactory.SetupItems(_rootMenu); + MenuSetupItemsFactory menuItemSetupFactory(this); + menuItemSetupFactory.SetupItems(*_currentRootMenuNode); } eOSState RecursiveMenuSetup::ProcessKey(eKeys Key) { - - if (_moving && ((Key == kUp) || (Key == kDown))) - { - return MoveCurrentItem(Key == kUp); + // Catch keys that should not be processed by the base class + if (_moving) + { + if ((Key == kUp) || (Key == kDown)) + { + return MoveCurrentItem(Key == kUp); + } } - eOSState state = cOsdMenu::ProcessKey(Key); + // Process keys in base class + eOSState state = cOsdMenu::ProcessKey(Key); if(HasSubMenu()) { + return state; } + if ((state == osBack) || (state == osEnd)) + { + if (!_currentRootMenuNode->Parent()) + { + _menuConfigurationRepository->Save(*_currentRootMenuNode); + } + } + + // Process unprocessed keys if ((state == osUnknown) && SelectedItem()) { - switch(Key) + if (_moving) { - case kOk: - if (_moving) - { - StopMoving(); - return osContinue; - } - else - { - return ShowSubOrEditMenuForSelectedItem(); - } - break; - case kRed: - if (!_moving) StartMoving(); - break; - case kBlue: - return ShowEditMenuForSelectedItem(); - default: - break; + switch(Key) + { + case kOk: + StopMoving(); + return osContinue; + default: + break; + } + } + else + { + switch(Key) + { + case kOk: + return ShowEditMenuForSelectedItem(true); + case kRed: + StartMoving(); + break; + case kBlue: + return ShowEditMenuForSelectedItem(false); + default: + break; + } } } + return state; } void RecursiveMenuSetup::StartMoving() { - _moving = true; - SetStatus("Move with Up/Down and confirm with OK"); - SetHelp(NULL); + _moving = true; + SetStatus("Move with Up/Down and confirm with OK"); + SetHelp(NULL); } void RecursiveMenuSetup::StopMoving() { - _moving = false; - SetStatus(NULL); - ShowHelp(); + _moving = false; + SetStatus(NULL); + ShowHelp(); } eOSState RecursiveMenuSetup::MoveCurrentItem(bool moveUp) { - int oldPos = Current(); - int newPos = Current(); + int oldPos = Current(); + int newPos = Current(); - MenuNode* node = _rootMenu.Childs()->at(oldPos); + MenuNode* node = _currentRootMenuNode->Childs()->at(oldPos); - if ((oldPos > 0) && (oldPos < Count())) - { - if (moveUp) - { - newPos = oldPos - 1; - } - else - { - newPos = oldPos + 1; - } + if ((oldPos > 0) && moveUp) + { + newPos = oldPos - 1; + } + else if ((oldPos < Count() - 1) && !moveUp) + { + newPos = oldPos + 1; + } - _rootMenu.Childs()->erase(_rootMenu.Childs()->begin() + oldPos); - _rootMenu.Childs()->insert(_rootMenu.Childs()->begin() + newPos, node); + if (oldPos != newPos) + { + _currentRootMenuNode->Childs()->erase(_currentRootMenuNode->Childs()->begin() + oldPos); + _currentRootMenuNode->Childs()->insert(_currentRootMenuNode->Childs()->begin() + newPos, node); - Clear(); - CreateMenuItems(); - SetCurrent(Get(newPos)); - Display(); + Clear(); + CreateMenuItems(); + SetCurrent(Get(newPos)); + Display(); } - return osContinue; + return osContinue; } void RecursiveMenuSetup::ShowHelp() { - SetHelp("Move", "Delete", "New", "Edit"); + SetHelp("Move", "Delete", "New", "Edit"); } -eOSState RecursiveMenuSetup::ShowEditMenuForSelectedItem() +eOSState RecursiveMenuSetup::ShowEditMenuForSelectedItem(bool openSubmenuInsteadOfEditing) { - cOsdMenu* editMenu = MenuEditMenusFactory::Create(*SelectedItem()); - if (editMenu) - { - return AddSubMenu(editMenu); - } - else - { - return osContinue; - } + cOsdMenu* editMenu = MenuEditMenusFactory::Create(*SelectedItem(), openSubmenuInsteadOfEditing); + if (editMenu) + { + return AddSubMenu(editMenu); + } + else + { + return osContinue; + } } MenuNode* RecursiveMenuSetup::SelectedItem() { - return _rootMenu.Childs()->at(Current()); -} - -eOSState RecursiveMenuSetup::ShowSubOrEditMenuForSelectedItem() -{ - if (!SelectedItem()->IsLeaf()) - { - return AddSubMenu(new RecursiveMenuSetup(*SelectedItem())); - } - else - { - return ShowEditMenuForSelectedItem(); - } + return _currentRootMenuNode->Childs()->at(Current()); } diff --git a/src/RecursiveMenuSetup.h b/src/RecursiveMenuSetup.h index b09d6e2..8817ed4 100644 --- a/src/RecursiveMenuSetup.h +++ b/src/RecursiveMenuSetup.h @@ -24,32 +24,34 @@ #define ___RECURSIVEMENUSETUP_H_ #include -#include "imenunodeprocessor.h" +#include "IMenuNodeProcessor.h" +class MenuConfigurationRepository; class MenuNode; class RecursiveMenuSetup: public cOsdMenu { - private: - MenuNode& _rootMenu; - bool _moving; - - public: - RecursiveMenuSetup(MenuNode& rootMenu); - ~RecursiveMenuSetup(); - - // cOsdMenu - eOSState ProcessKey(eKeys Key); - - private: - void CreateMenuItems(); - void ShowHelp(); - void StartMoving(); - void StopMoving(); - eOSState MoveCurrentItem(bool moveUp); - eOSState ShowEditMenuForSelectedItem(); - eOSState ShowSubOrEditMenuForSelectedItem(); - MenuNode* SelectedItem(); + private: + MenuConfigurationRepository* _menuConfigurationRepository; + SubMenuNode* _menuConfiguration; + SubMenuNode* _currentRootMenuNode; + bool _moving; + + public: + RecursiveMenuSetup(MenuConfigurationRepository* menuConfigurationRepository, SubMenuNode* rootMenuNode = NULL); + ~RecursiveMenuSetup(); + + // cOsdMenu + eOSState ProcessKey(eKeys Key); + + private: + void CreateMenuItems(); + void ShowHelp(); + void StartMoving(); + void StopMoving(); + eOSState MoveCurrentItem(bool moveUp); + eOSState ShowEditMenuForSelectedItem(bool openSubmenuInsteadOfEditing); + MenuNode* SelectedItem(); }; #endif diff --git a/src/SeparatorMenuNode.cpp b/src/SeparatorMenuNode.cpp new file mode 100644 index 0000000..da881d9 --- /dev/null +++ b/src/SeparatorMenuNode.cpp @@ -0,0 +1,58 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "SeparatorMenuNode.h" +#include "IMenuNodeProcessor.h" + +using namespace std; + +SeparatorMenuNode::SeparatorMenuNode(string customTitle) +{ + _customTitle = customTitle; +} + +SeparatorMenuNode* SeparatorMenuNode::Clone() +{ + return new SeparatorMenuNode(*this); +} + +void SeparatorMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) +{ + menuNodeProcessor->ProcessSeparatorMenuNode(this); +} + +string SeparatorMenuNode::CustomTitle() +{ + return _customTitle; +} + +string SeparatorMenuNode::DisplayText() +{ + if (_customTitle.empty()) + { + return "----------------------------------"; + } + else + { + return _customTitle; + } +} diff --git a/src/SeparatorMenuNode.h b/src/SeparatorMenuNode.h new file mode 100644 index 0000000..c140eb4 --- /dev/null +++ b/src/SeparatorMenuNode.h @@ -0,0 +1,46 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___SEPARATORMENUNODE_H +#define ___SEPARATORMENUNODE_H + +#include "MenuNode.h" +#include + +class IMenuNodeProcessor; + +class SeparatorMenuNode: public MenuNode +{ + private: + std::string _customTitle; + + public: + SeparatorMenuNode(std::string customTitle); + std::string CustomTitle(); + std::string DisplayText(); + + // MenuNode + virtual void Process(IMenuNodeProcessor* menuNodeProcessor); + SeparatorMenuNode* Clone(); +}; + +#endif diff --git a/src/SubMenuNode.cpp b/src/SubMenuNode.cpp new file mode 100644 index 0000000..664b009 --- /dev/null +++ b/src/SubMenuNode.cpp @@ -0,0 +1,78 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "SubMenuNode.h" +#include "ChildLock.h" +#include "IMenuNodeProcessor.h" + +using namespace std; + +SubMenuNode::SubMenuNode(string text) +{ + _text = text; +} + +SubMenuNode::~SubMenuNode() +{ + while (!_childs.empty()) + { + delete _childs.back(); + _childs.pop_back(); + } +} + +SubMenuNode* SubMenuNode::Clone() +{ + SubMenuNode* clone = new SubMenuNode(*this); + clone->Childs()->clear(); + for (MenuNodeList::iterator i = _childs.begin(); i != _childs.end(); i++) + { + (*i)->Clone()->AddToParent(clone); + } + return clone; +} + +MenuNodeList* SubMenuNode::Childs() +{ + return &_childs; +} + +MenuNode* SubMenuNode::AddChild(MenuNode* child) +{ + child->AddToParent(this); + return child; +} + +string SubMenuNode::Text() +{ + return _text; +} + +bool SubMenuNode::IsHidden() +{ + return ChildLock::IsMenuHidden(_text.c_str()); +} + +void SubMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) +{ + menuNodeProcessor->ProcessSubMenuNode(this); +} diff --git a/src/SubMenuNode.h b/src/SubMenuNode.h new file mode 100644 index 0000000..aa2299b --- /dev/null +++ b/src/SubMenuNode.h @@ -0,0 +1,50 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___SUBMENUNODE_H +#define ___SUBMENUNODE_H + +#include "MenuNode.h" +#include + +class IMenuNodeProcessor; + +class SubMenuNode: public MenuNode +{ + private: + std::string _text; + MenuNodeList _childs; + + public: + SubMenuNode(std::string text); + virtual ~SubMenuNode(); + std::string Text(); + + // MenuNode + SubMenuNode* Clone(); + virtual void Process(IMenuNodeProcessor* menuNodeProcessor); + bool IsHidden(); + MenuNode* AddChild(MenuNode* child); + MenuNodeList* Childs(); +}; + +#endif diff --git a/src/SystemMenuNode.cpp b/src/SystemMenuNode.cpp new file mode 100644 index 0000000..23766fa --- /dev/null +++ b/src/SystemMenuNode.cpp @@ -0,0 +1,71 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#include "SystemMenuNode.h" +#include "ChildLock.h" +#include "IMenuNodeProcessor.h" +#include + +using namespace std; + +SystemMenuNode::SystemMenuNode(VdrState state, string customTitle) + :_state(state) +{ + _customTitle = customTitle; +} + +SystemMenuNode* SystemMenuNode::Clone() +{ + return new SystemMenuNode(*this); +} + +bool SystemMenuNode::IsHidden() +{ + return ChildLock::IsMenuHidden(_state.Name().c_str()); +} + +void SystemMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) +{ + menuNodeProcessor->ProcessSystemMenuNode(this); +} + +VdrState SystemMenuNode::State() +{ + return _state; +} + +string SystemMenuNode::CustomTitle() +{ + return _customTitle; +} + +string SystemMenuNode::DisplayText() +{ + if (_customTitle.empty()) + { + return tr(_state.Name().c_str()); + } + else + { + return _customTitle; + } +} diff --git a/src/SystemMenuNode.h b/src/SystemMenuNode.h new file mode 100644 index 0000000..6e7b5cd --- /dev/null +++ b/src/SystemMenuNode.h @@ -0,0 +1,51 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___SYSTEMMENUNODE_H +#define ___SYSTEMMENUNODE_H + +#include "MenuNode.h" +#include +#include "VdrState.h" + +class IMenuNodeProcessor; + +class SystemMenuNode: public MenuNode +{ + private: + std::string _customTitle; + VdrState _state; + + public: + SystemMenuNode(VdrState state, std::string customTitle); + + std::string CustomTitle(); + VdrState State(); + std::string DisplayText(); + + // MenuNode + SystemMenuNode* Clone(); + virtual void Process(IMenuNodeProcessor* menuNodeProcessor); + bool IsHidden(); +}; + +#endif diff --git a/src/VdrState.cpp b/src/VdrState.cpp new file mode 100644 index 0000000..eaf9b1c --- /dev/null +++ b/src/VdrState.cpp @@ -0,0 +1,68 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id: childlock.cpp 5951 2007-08-24 05:45:20Z svntcreutz $ + * + */ + +#include "VdrState.h" + +using namespace std; + +list VdrState::_availableStates(VdrState::InitializeAvailableStates()); + +VdrState::VdrState(eOSState state, string name) +{ + _state = state; + _name = name; +} + +list VdrState::InitializeAvailableStates() +{ + list states; + states.push_back(VdrState(osSchedule, "Schedule")); + states.push_back(VdrState(osRecordings, "Recordings")); + states.push_back(VdrState(osChannels, "Channels")); + states.push_back(VdrState(osTimers, "Timers")); + states.push_back(VdrState(osCommands, "Commands")); + states.push_back(VdrState(osSetup, "Setup")); + return states; +} + +VdrState VdrState::ByName(std::string name) +{ + for (list::iterator i = _availableStates.begin(); i != _availableStates.end(); i++) + { + if ((*i).Name() == name) + { + return *i; + } + } + + throw "unknown state identifier: " + name; +} + +string VdrState::Name() +{ + return _name; +} + +eOSState VdrState::OSState() +{ + return _state; +} diff --git a/src/VdrState.h b/src/VdrState.h new file mode 100644 index 0000000..081b7c5 --- /dev/null +++ b/src/VdrState.h @@ -0,0 +1,47 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___VDRSTATE_H_ +#define ___VDRSTATE_H_ + +#include +#include +#include + +class VdrState +{ + private: + static std::list _availableStates; + eOSState _state; + std::string _name; + + private: + VdrState(eOSState state, std::string name); + static std::list InitializeAvailableStates(); + + public: + static VdrState ByName(std::string name); + eOSState OSState(); + std::string Name(); +}; + +#endif diff --git a/src/XmlConfigurationFactory.cpp b/src/XmlConfigurationFactory.cpp new file mode 100644 index 0000000..65d081f --- /dev/null +++ b/src/XmlConfigurationFactory.cpp @@ -0,0 +1,92 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id: commandmenunode.h 6123 2007-09-04 21:31:19Z svntcreutz $ + * + */ + +#include "XmlConfigurationFactory.h" +#include +#include "SystemMenuNode.h" +#include "PluginMenuNode.h" +#include "SubMenuNode.h" +#include "CommandMenuNode.h" +#include "SeparatorMenuNode.h" + +using namespace xmlpp; + +Document* XmlConfigurationFactory::CreateXmlConfig(SubMenuNode* node) +{ + Document* doc = new Document(); + XmlConfigurationFactory xmlMenuNodeFactory(doc->create_root_node("menus")); + for (MenuNodeList::iterator i = node->Childs()->begin(); i != node->Childs()->end(); i++) + { + (*i)->Process(&xmlMenuNodeFactory); + } + return doc; +} + +void XmlConfigurationFactory::ProcessSystemMenuNode(SystemMenuNode* node) +{ + Element* systemNode = _parent->add_child("system"); + systemNode->set_attribute("name", node->State().Name()); + if (!node->CustomTitle().empty()) + { + systemNode->set_attribute("title", node->CustomTitle()); + } +} + +void XmlConfigurationFactory::ProcessPluginMenuNode(PluginMenuNode* node) +{ + Element* pluginNode = _parent->add_child("plugin"); + pluginNode->set_attribute("name", node->PluginName()); + if (!node->CustomTitle().empty()) + { + pluginNode->set_attribute("title", node->CustomTitle()); + } +} + +void XmlConfigurationFactory::ProcessSubMenuNode(SubMenuNode* node) +{ + Element* menuNode = _parent->add_child("menu"); + menuNode->set_attribute("name", node->Text()); + XmlConfigurationFactory subMenuFactory(menuNode); + for (MenuNodeList::iterator i = node->Childs()->begin(); i != node->Childs()->end(); i++) + { + (*i)->Process(&subMenuFactory); + } +} + +void XmlConfigurationFactory::ProcessCommandMenuNode(CommandMenuNode* node) +{ + Element* commandNode = _parent->add_child("command"); + commandNode->set_attribute("name", node->Text()); + commandNode->set_attribute("execute", node->Command()); + commandNode->set_attribute("confirm", node->ShouldConfirm() ? "yes" : "no"); +} + +void XmlConfigurationFactory::ProcessSeparatorMenuNode(SeparatorMenuNode* node) +{ + Element* separatorNode = _parent->add_child("separator"); + separatorNode->set_attribute("title", node->CustomTitle()); +} + +XmlConfigurationFactory::XmlConfigurationFactory(Element* parent) +{ + _parent = parent; +} diff --git a/src/XmlConfigurationFactory.h b/src/XmlConfigurationFactory.h new file mode 100644 index 0000000..7f1dc6e --- /dev/null +++ b/src/XmlConfigurationFactory.h @@ -0,0 +1,55 @@ +/* + * vdr-menuorg - A plugin for the Linux Video Disk Recorder + * Copyright (C) 2007 Thomas Creutz, Tobias Grimm + * + * 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-1307 USA + * + * $Id$ + * + */ + +#ifndef ___XMLCONFIGURATIONFACTORY_H_ +#define ___XMLCONFIGURATIONFACTORY_H_ + +#include "IMenuNodeProcessor.h" + +namespace xmlpp { class Element; }; +namespace xmlpp { class Document; }; +class SystemMenuNode; +class PluginMenuNode; +class SubMenuNode; +class CommandMenuNode; +class SeparatorMenuNode; + +class XmlConfigurationFactory: public IMenuNodeProcessor +{ + private: + xmlpp::Element* _parent; + + public: + static xmlpp::Document* CreateXmlConfig(SubMenuNode* node); + + // IMenuNodeProcessor + void ProcessSystemMenuNode(SystemMenuNode* node); + void ProcessPluginMenuNode(PluginMenuNode* node); + void ProcessSubMenuNode(SubMenuNode* node); + void ProcessCommandMenuNode(CommandMenuNode* node); + void ProcessSeparatorMenuNode(SeparatorMenuNode* node); + + private: + XmlConfigurationFactory(xmlpp::Element* parent); +}; + +#endif diff --git a/src/childlock.cpp b/src/childlock.cpp deleted file mode 100644 index dbd2db2..0000000 --- a/src/childlock.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "childlock.h" -#include -#include "childlockservice.h" - -IChildLockService* ChildLock::_childLockService = NULL; - -bool ChildLock::IsMenuHidden(const char* MenuName) -{ - if (IChildLockService* childLockService = ChildLockService()) - { - return childLockService->IsMenuHidden(MenuName); - } - else - { - return false; - } -} - -bool ChildLock::IsPluginHidden(cPlugin* Plugin) -{ - if (IChildLockService* childLockService = ChildLockService()) - { - return childLockService->IsPluginHidden(Plugin); - } - else - { - return false; - } -} - -IChildLockService* ChildLock::ChildLockService() -{ - if (!_childLockService) - { - IChildLockService* childLockService; - - if (cPluginManager::CallFirstService(IChildLockService::ServiceId, &childLockService)) - { - _childLockService = childLockService; - } - else - { - _childLockService = NULL; - } - } - - return _childLockService; -} diff --git a/src/childlock.h b/src/childlock.h deleted file mode 100644 index f129b67..0000000 --- a/src/childlock.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___CHILDLOCK_H -#define ___CHILDLOCK_H - -class IChildLockService; -class cPlugin; - -class ChildLock -{ - private: - static IChildLockService* _childLockService; - - public: - static bool IsMenuHidden(const char* MenuName); - static bool IsPluginHidden(cPlugin* Plugin); - - private: - static IChildLockService* ChildLockService(); -}; - -#endif diff --git a/src/childlockservice.h b/src/childlockservice.h deleted file mode 100644 index f677f72..0000000 --- a/src/childlockservice.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___CHILDLOCKSERVICE_H -#define ___CHILDLOCKSERVICE_H - -#include - -class cChannel; -class cRecording; -class cPlugin; -class cTimer; -class cEvent; -class cOsdObject; - -class IChildLockService -{ - public: - static const char* ServiceId; - - public: - virtual ~IChildLockService() {}; - virtual bool IsUnlocked() = 0; - - virtual bool IsMenuProtected(const char* MenuName) = 0; - virtual bool IsChannelProtected(const cChannel* Channel) = 0; - virtual bool IsRecordingProtected(const cRecording* Recording, const char* Name, const char* Base, bool isDirectory) = 0; - virtual bool IsPluginProtected(cPlugin* Plugin) = 0; - - virtual bool IsMenuHidden(const char* MenuName) = 0; - virtual bool IsPluginHidden(cPlugin* Plugin) = 0; - virtual bool IsRecordingHidden(const cRecording* Recording, const char* Name, const char* Base, bool isDirectory) = 0; -}; - -const char* IChildLockService::ServiceId = "ChildLockService-v0.1::ChildLockService"; - -#endif diff --git a/src/commandmenunode.cpp b/src/commandmenunode.cpp deleted file mode 100644 index 1727a67..0000000 --- a/src/commandmenunode.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id: submenunode.cpp 5835 2007-08-19 21:45:51Z svntcreutz $ - * - */ - -#include "commandmenunode.h" -#include -#include -#include -#include "osditemdefinition.h" -#include "childlock.h" -#include "imenunodeprocessor.h" - -using namespace std; - -CommandMenuNode::CommandMenuNode(string text, string command, bool confirm) -{ - _text = text; - _command = command; - _confirm = confirm; -} - -cOsdMenu* CommandMenuNode::Execute() -{ - bool confirmed = true; - if (_confirm) - { - confirmed = Interface->Confirm((_text + '?').c_str()); - } - if (confirmed) - { - Skins.Message(mtStatus, (_text + "...").c_str()); - string result = ExecuteCommand(); - Skins.Message(mtStatus, NULL); - if (!result.empty()) - { - return new cMenuText(_text.c_str(), result.c_str(), fontFix); - } - } - return NULL; -} - -string CommandMenuNode::ExecuteCommand() -{ - string result; - dsyslog("executing command '%s'", _command.c_str()); - cPipe pipe; - if (pipe.Open(_command.c_str(), "r")) - { - int c; - while ((c = fgetc(pipe)) != EOF) - { - result += (char) c; - } - pipe.Close(); - } - else - { - esyslog("ERROR: can't open pipe for command '%s'", _command.c_str()); - } - return result; -} - -bool CommandMenuNode::IsHidden() -{ - return ChildLock::IsMenuHidden(_text.c_str()); -} - -void CommandMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) -{ - menuNodeProcessor->ProcessCommandMenuNode(this); -} - -string CommandMenuNode::Command() -{ - return _command; -} - -bool CommandMenuNode::ShouldConfirm() -{ - return _confirm; -} - -string CommandMenuNode::Text() -{ - return _text; -} diff --git a/src/commandmenunode.h b/src/commandmenunode.h deleted file mode 100644 index 9168e06..0000000 --- a/src/commandmenunode.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___COMMANDMENUNODE_H -#define ___COMMANDMENUNODE_H - -#include "menunode.h" -#include - -class IMenuNodeProcessor; - -class CommandMenuNode: public MenuNode -{ - private: - std::string _text; - std::string _command; - bool _confirm; - - public: - CommandMenuNode(std::string text, std::string _command, bool confirm); - std::string Text(); - std::string Command(); - bool ShouldConfirm(); - - // MenuNode - virtual void Process(IMenuNodeProcessor* menuNodeProcessor); - bool IsHidden(); - cOsdMenu* Execute(); - - private: - std::string ExecuteCommand(); -}; - -#endif diff --git a/src/imenunodeprocessor.h b/src/imenunodeprocessor.h deleted file mode 100644 index 5d3657d..0000000 --- a/src/imenunodeprocessor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___IMENUNODEPROCESSOR_H_ -#define ___IMENUNODEPROCESSOR_H_ - -class SystemMenuNode; -class PluginMenuNode; -class SubMenuNode; -class CommandMenuNode; -class LineMenuNode; - -class IMenuNodeProcessor -{ - public: - virtual ~IMenuNodeProcessor() {}; - virtual void ProcessSystemMenuNode(SystemMenuNode* node) = 0; - virtual void ProcessPluginMenuNode(PluginMenuNode* node) = 0; - virtual void ProcessSubMenuNode(SubMenuNode* node) = 0; - virtual void ProcessCommandMenuNode(CommandMenuNode* node) = 0; - virtual void ProcessLineMenuNode(LineMenuNode* node) = 0; -}; - -#endif diff --git a/src/linemenunode.cpp b/src/linemenunode.cpp deleted file mode 100644 index dcf2eee..0000000 --- a/src/linemenunode.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "linemenunode.h" -#include "imenunodeprocessor.h" - -using namespace std; - -LineMenuNode::LineMenuNode(std::string text) -{ - _text = text; -} - -void LineMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) -{ - menuNodeProcessor->ProcessLineMenuNode(this); -} - -string LineMenuNode::Text() -{ - return _text; - -} \ No newline at end of file diff --git a/src/linemenunode.h b/src/linemenunode.h deleted file mode 100644 index 69af41c..0000000 --- a/src/linemenunode.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___LINEMENUNODE_H -#define ___LINEMENUNODE_H - -#include "menunode.h" -#include - -class IMenuNodeProcessor; - -class LineMenuNode: public MenuNode -{ - private: - std::string _text; - - public: - LineMenuNode(std::string text); - std::string Text(); - - // MenuNode - virtual void Process(IMenuNodeProcessor* menuNodeProcessor); -}; -#endif diff --git a/src/mainmenuitemsprovider.cpp b/src/mainmenuitemsprovider.cpp deleted file mode 100644 index 35c22d1..0000000 --- a/src/mainmenuitemsprovider.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "mainmenuitemsprovider.h" -#include "submenunode.h" -#include "systemmenunode.h" -#include "pluginmenunode.h" -#include "commandmenunode.h" -#include "linemenunode.h" -#include -#include "childlock.h" -#include "menuconfiguration.h" -#include "osditemdefinition.h" -#include "pluginitemdefinition.h" -#include "osdlineitem.h" - -MainMenuItemsProvider::MainMenuItemsProvider(MenuConfiguration& menuConfiguration) - :_menuConfiguration(menuConfiguration) -{ - EnterRootMenu(); -} - -MainMenuItemsProvider::~MainMenuItemsProvider() -{ - delete _rootMenu; - ResetMainMenuItemsList(); -} - -MenuItemDefinitions* MainMenuItemsProvider::MainMenuItems() -{ - ResetMainMenuItemsList(); - - for (MenuNodeList::iterator i = _currentMenu->Childs()->begin(); - i != _currentMenu->Childs()->end(); i++) - { - if (!(*i)->IsHidden()) - { - (*i)->Process(this); - _currentMainMenuItems.push_back(_createdMenuItemDefinition); - } - } - - return &_currentMainMenuItems; -} - -void MainMenuItemsProvider::ResetMainMenuItemsList() -{ - - for( MenuItemDefinitions::iterator i = _currentMainMenuItems.begin(); - i != _currentMainMenuItems.end(); i++) - { - delete *i; - } - _currentMainMenuItems.clear(); -} - -void MainMenuItemsProvider::EnterRootMenu() -{ - _currentMenu = _rootMenu = _menuConfiguration.MenuTree();; -} - -void MainMenuItemsProvider::EnterSubMenu(cOsdItem* item) -{ - int itemIndex = IndexOfCustomOsdItem(item); - if (itemIndex >= 0) - { - _currentMenu = _currentMenu->Childs()->at(itemIndex); - } -} - -bool MainMenuItemsProvider::LeaveSubMenu() -{ - if (_currentMenu->Parent()) - { - _currentMenu = _currentMenu->Parent(); - return true; - } - else - { - return false; - } -} - -cOsdMenu* MainMenuItemsProvider::Execute(cOsdItem* item) -{ - int itemIndex = IndexOfCustomOsdItem(item); - if (itemIndex >= 0) - { - return _currentMenu->Childs()->at(itemIndex)->Execute(); - } - return NULL; -} - -int MainMenuItemsProvider::IndexOfCustomOsdItem(cOsdItem* item) -{ - for(unsigned int itemIndex=0; itemIndex < _currentMainMenuItems.size(); itemIndex++) - { - IMenuItemDefinition* menuItem = _currentMainMenuItems.at(itemIndex); - if (menuItem->IsCustomOsdItem() && (menuItem->CustomOsdItem() == item)) - { - return itemIndex; - } - } - return -1; -} - -void MainMenuItemsProvider::ProcessCommandMenuNode(CommandMenuNode* node) -{ - _createdMenuItemDefinition = new OsdItemDefinition(new cOsdItem(node->Text().c_str(), osUser2)); -} - -void MainMenuItemsProvider::ProcessPluginMenuNode(PluginMenuNode* node) -{ - _createdMenuItemDefinition = new PluginItemDefinition(node->Title().c_str(), node->PluginIndex()); -} - -void MainMenuItemsProvider::ProcessSubMenuNode(SubMenuNode* node) -{ - _createdMenuItemDefinition = new OsdItemDefinition(new cOsdItem(node->Text().c_str(), osUser1)); -} - -void MainMenuItemsProvider::ProcessSystemMenuNode(SystemMenuNode* node) -{ - _createdMenuItemDefinition = new OsdItemDefinition(new cOsdItem(tr(node->Text().c_str()), node->State())); -} - -void MainMenuItemsProvider::ProcessLineMenuNode(LineMenuNode* node) -{ - _createdMenuItemDefinition = new OsdItemDefinition(new cOsdLineItem(node->Text().c_str())); -} diff --git a/src/mainmenuitemsprovider.h b/src/mainmenuitemsprovider.h deleted file mode 100644 index fa7e93e..0000000 --- a/src/mainmenuitemsprovider.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___MAINMENUITEMSPROVIDER_H -#define ___MAINMENUITEMSPROVIDER_H - -#include -#include "imenunodeprocessor.h" - -class MenuNode; -class MenuConfiguration; - -class MainMenuItemsProvider: public IMainMenuItemsProvider, public IMenuNodeProcessor -{ - private: - MenuNode* _rootMenu; - MenuNode* _currentMenu; - MenuItemDefinitions _currentMainMenuItems; - MenuConfiguration& _menuConfiguration; - IMenuItemDefinition* _createdMenuItemDefinition; - - public: - MainMenuItemsProvider(MenuConfiguration& menuConfiguration); - ~MainMenuItemsProvider(); - - // IMenuNodeProcessor - MenuItemDefinitions* MainMenuItems(); - void EnterRootMenu(); - void EnterSubMenu(cOsdItem* item); - bool LeaveSubMenu(); - cOsdMenu* Execute(cOsdItem* item); - - // IMenuNodeProcessor - void ProcessSystemMenuNode(SystemMenuNode* node); - void ProcessPluginMenuNode(PluginMenuNode* node); - void ProcessSubMenuNode(SubMenuNode* node); - void ProcessCommandMenuNode(CommandMenuNode* node); - void ProcessLineMenuNode(LineMenuNode* node); - - private: - void ResetMainMenuItemsList(); - int IndexOfCustomOsdItem(cOsdItem* item); -}; - -#endif diff --git a/src/menuconfiguration.cpp b/src/menuconfiguration.cpp deleted file mode 100644 index 6e462cf..0000000 --- a/src/menuconfiguration.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "menuconfiguration.h" -#include -#include -#include -#include -#include "systemmenunode.h" -#include "submenunode.h" -#include "pluginmenunode.h" -#include "commandmenunode.h" -#include "linemenunode.h" - -using namespace xmlpp; -using namespace std; - -const string MenuConfiguration::_dtd = - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" - "\n" - "\n"; - -MenuConfiguration::MenuConfiguration(string menuFileName, bool unconfiguredPluginsShouldBeIncluded) -{ - _configuration = NULL; - _unconfiguredPluginsShouldBeIncluded = unconfiguredPluginsShouldBeIncluded; - - try - { - dsyslog("loading menuorg config file from %s", menuFileName.c_str()); - - _parser.set_substitute_entities(); - _parser.parse_file(menuFileName); - - DtdValidator validator; - validator.parse_memory(_dtd); - - Document *pDoc = _parser.get_document(); - validator.validate( pDoc ); - - _configuration = _parser.get_document()->get_root_node(); - - } - catch(const std::exception& ex) - { - cerr << "menuorg: Exception caught when parsing xml configuration: " << ex.what(); - esyslog("Exception caught when parsing xml configuration. See stderr output for details."); - } -} - -Element* MenuConfiguration::Configuration() -{ - return _configuration; -} - -MenuNode* MenuConfiguration::MenuTree() -{ - if (_configuration) - { - MenuNode* menuRoot = new SubMenuNode("root"); - CreateMenuTree(_configuration, menuRoot); - - if(_unconfiguredPluginsShouldBeIncluded) - AddUnconfiguredPlugins(menuRoot); - - return menuRoot; - } - else - { - return NULL; - } -} - -void MenuConfiguration::CreateMenuTree(const Element* menuRoot, MenuNode* menuNode) -{ - Node::NodeList children = menuRoot->get_children(); - for (Node::NodeList::iterator i = children.begin(); i != children.end(); i++) - { - const Element* childElement = dynamic_cast(*i); - - if (childElement) - { - const Attribute* nameAttribute = childElement->get_attribute("name"); - string name = nameAttribute ? (string) UnicodeToLocaleOrIso8859(nameAttribute->get_value()) : ""; - - string type = childElement->get_name(); - - if ( type == "menu") - { - MenuNode* subMenu = AddSubMenuNode(name, menuNode); - CreateMenuTree(childElement, subMenu); - } - else if (type == "system") - { - const Attribute* titleAttribute = childElement->get_attribute("title"); - string title = titleAttribute ? (string) UnicodeToLocaleOrIso8859(titleAttribute->get_value()) : name; - AddSystemMenuNode(name, title, menuNode); - } - else if (type == "plugin") - { - const Attribute* titleAttribute = childElement->get_attribute("title"); - string title = titleAttribute ? (string) UnicodeToLocaleOrIso8859(titleAttribute->get_value()) : name; - AddPluginMenuNode(name, title, menuNode); - } - else if (type == "command") - { - string execute = childElement->get_attribute("execute")->get_value(); - const Attribute* confirmAttribute = childElement->get_attribute("confirm"); - bool confirm = confirmAttribute ? (confirmAttribute->get_value() == "yes") : false; - AddCommandMenuNode(name, execute, confirm, menuNode); - } - else if (type == "line") - { - const Attribute* titleAttribute = childElement->get_attribute("title"); - string title = titleAttribute ? (string) UnicodeToLocaleOrIso8859(titleAttribute->get_value()) : "-----------------------------------"; - AddLineMenuNode(title, menuNode); - } - } - } -} - -MenuNode* MenuConfiguration::AddSubMenuNode(string name, MenuNode* menu) -{ - return menu->AddChild(new SubMenuNode(name)); -} - -void MenuConfiguration::AddSystemMenuNode(string name, string title, MenuNode* menu) -{ - menu->AddChild(new SystemMenuNode(MenuTextToVdrState(name), title)); -} - -void MenuConfiguration::AddPluginMenuNode(string pluginName, string title, MenuNode* menu) -{ - int pluginIndex; - cPlugin* plugin; - - if (FindPluginByName(pluginName, plugin, pluginIndex)) - { - _configuredPlugins.push_back(pluginName); - menu->AddChild(new PluginMenuNode(plugin, pluginIndex, title)); - } -} - -eOSState MenuConfiguration::MenuTextToVdrState(string menuText) -{ - if (menuText == "Schedule") - { - return osSchedule; - } - else if (menuText == "Channels") - { - return osChannels; - } - else if (menuText == "Timers") - { - return osTimers; - } - else if (menuText == "Recordings") - { - return osRecordings; - } - else if (menuText == "Setup") - { - return osSetup; - } - else if (menuText == "Commands") - { - return osCommands; - } - else - return osContinue; -} - -bool MenuConfiguration::FindPluginByName(string name, cPlugin*& plugin, int& pluginIndex) -{ - int i = 0; - - while (cPlugin *currentPlugin = cPluginManager::GetPlugin(i)) - { - if (name == currentPlugin->Name()) - { - plugin = currentPlugin; - pluginIndex = i; - return true; - } - i++; - } - - return false; -} - -void MenuConfiguration::AddUnconfiguredPlugins(MenuNode* menu) -{ - int i = 0; - - while (cPlugin *plugin = cPluginManager::GetPlugin(i)) - { - if (find(_configuredPlugins.begin(), _configuredPlugins.end(), plugin->Name()) == _configuredPlugins.end()) - { - menu->AddChild(new PluginMenuNode(plugin, i)); - } - i++; - } -} - -void MenuConfiguration::AddCommandMenuNode(string name, string command, bool confirm, MenuNode* menu) -{ - menu->AddChild(new CommandMenuNode(name, command, confirm)); -} - -void MenuConfiguration::AddLineMenuNode(string text, MenuNode* menu) -{ - menu->AddChild(new LineMenuNode(text)); -} - -string MenuConfiguration::UnicodeToLocaleOrIso8859(Glib::ustring unicodeString) -{ - try - { - return Glib::locale_from_utf8(unicodeString); - } - catch (Glib::ConvertError) - { - return Glib::convert_with_fallback(unicodeString, "ISO8859-2", "UTF-8"); - } -} diff --git a/src/menuconfiguration.h b/src/menuconfiguration.h deleted file mode 100644 index 42359c2..0000000 --- a/src/menuconfiguration.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___MENUCONFIGURARION_H -#define ___MENUCONFIGURATION_H - -#include -#include -#include -#include -#include - -namespace xmlpp { class Element; } -class MenuNode; -class cPlugin; - -class MenuConfiguration -{ - private: - static const std::string _dtd; - bool _unconfiguredPluginsShouldBeIncluded; - std::vector _configuredPlugins; - xmlpp::Element* _configuration; - xmlpp::DomParser _parser; - - public: - MenuConfiguration(std::string menuFileName, bool unconfiguredPluginsShouldBeIncluded); - MenuNode* MenuTree(); - xmlpp::Element* Configuration(); - - private: - void CreateMenuTree(const xmlpp::Element* menuRoot, MenuNode* menuNode); - eOSState MenuTextToVdrState(std::string menuText); - bool FindPluginByName(std::string name, cPlugin*& plugin, int& pluginIndex); - MenuNode* AddSubMenuNode(std::string name, MenuNode* menu); - void AddSystemMenuNode(std::string name, std::string title, MenuNode* menu); - void AddPluginMenuNode(std::string pluginName, std::string title, MenuNode* menu); - void AddUnconfiguredPlugins(MenuNode* menu); - void AddCommandMenuNode(std::string name, std::string command, bool confirm, MenuNode* menu); - void AddLineMenuNode(std::string text, MenuNode* menu); - std::string UnicodeToLocaleOrIso8859(Glib::ustring unicodeString); -}; - -#endif diff --git a/src/menuitemsetup.cpp b/src/menuitemsetup.cpp deleted file mode 100644 index 27583a7..0000000 --- a/src/menuitemsetup.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include -#include "menuitemsetup.h" -#include "osdxmlitem.h" - -cMenuItemSetup::cMenuItemSetup(cOsdXmlItem* osdXmlItem) -:cOsdMenu(tr("Item Setup")) -{ - itemTypeText[0] = "System"; - itemTypeText[1] = "Plugin"; - itemTypeText[2] = "Submenu"; - itemTypeText[3] = "Command"; - - _osdXmlItem = osdXmlItem; - _newItemType = _osdXmlItem->getItemType(); - //_newName = _osdXmlItem->getNameAttribute().c_str(); - //_newTitle = _osdXmlItem->getTitleAttribute().c_str(); - asprintf(&_newTitle, "%s", _osdXmlItem->getTitleAttribute().c_str()); - //_newCommand = _osdXmlItem->getCommandAttribute().c_str(); - CreateMenuItems(); -} - -cMenuItemSetup::~cMenuItemSetup() -{ - _osdXmlItem->setNameAttribute(_newName); - _osdXmlItem->setTitleAttribute(_newTitle); - _osdXmlItem->setCommandAttribute(_newCommand); - free(_newName); - free(_newTitle); - free(_newCommand); -} - -// TODO: When exit check if the type was menu and now is changed -> bring a warning on the osd that the subitems will be deleted - -void cMenuItemSetup::CreateMenuItems(void) -{ - esyslog("menuorg: _newItemType=%d", _newItemType); - esyslog("menuorg: _newTitle=%s", _newTitle); - - Clear(); - - Add(new cMenuEditStraItem(tr("Item Type"), (int*) &_newItemType, 4, itemTypeText)); - - switch(_newItemType) - { - case 0: - // Add listItem of valid System Items - //Add(new cMenuEditStraItem(tr("available System Items"),)) - // Add textItem for title attribute - Add(new cMenuEditStrItem(tr("title"), _newTitle, 64, NULL)); - break; - - case 1: - // Add listItem of unused plugins or a submenu with the items - //Add(new cMenuEditStraItem(tr("available Plugins Items"),)) - // Add textItem for title attribute - //Add(new cMenuEditStrItem(tr("title"), VAR, 64, NULL)) - break; - - case 2: - // Add textItem for name attribute - //Add(new cMenuEditStrItem(tr("name"), VAR, 64, NULL)) - break; - - case 3: - // Add textItem for name attribute - //Add(new cMenuEditStrItem(tr("name"), VAR, 64, NULL)) - // Add textItem for command attribute - //Add(new cMenuEditStrItem(tr("command"), VAR, 64, NULL)) - // Add boolItem for confirm attribute - //Add(new cMenuEditBoolItem(tr("confirm"), &_confirm)); - break; - } -} - -eOSState cMenuItemSetup::ProcessKey(eKeys Key) -{ - eOSState state = cOsdMenu::ProcessKey(Key); - return state; -} diff --git a/src/menuitemsetup.h b/src/menuitemsetup.h deleted file mode 100644 index 7ecf373..0000000 --- a/src/menuitemsetup.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___MENUITEMSETUP_H -#define ___MENUITEMSETUP_H - -#include -#include "osdxmlitem.h" - -class cMenuItemSetup : public cOsdMenu -{ - private: - cOsdXmlItem* _osdXmlItem; - cOsdXmlItem::sItemType _newItemType; - const char* itemTypeText[4]; - char* _newName; - char* _newTitle; - char* _newCommand; - - public: - cMenuItemSetup(cOsdXmlItem* osdXmlItem); - ~cMenuItemSetup(void); - virtual eOSState ProcessKey(eKeys Key); - - private: - void CreateMenuItems(void); -}; - -#endif diff --git a/src/menunode.cpp b/src/menunode.cpp deleted file mode 100644 index b50a6cf..0000000 --- a/src/menunode.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "menunode.h" - -MenuNode::MenuNode() -{ - _parent = NULL; -} - -MenuNode::~MenuNode() -{ - while (!_childs.empty()) - { - delete _childs.back(); - _childs.pop_back(); - } -} - -MenuNode* MenuNode::Parent() -{ - return _parent; -} - -MenuNodeList* MenuNode::Childs() -{ - return &_childs; -} - -MenuNode* MenuNode::AddChild(MenuNode* child) -{ - _childs.push_back(child); - child->SetParent(this); - return child; -} - -bool MenuNode::IsLeaf() -{ - return true; -} - -void MenuNode::SetParent(MenuNode* parent) -{ - _parent = parent; -} - -cOsdMenu* MenuNode::Execute() -{ - return NULL; -} - -bool MenuNode::IsHidden() -{ - return false; -} diff --git a/src/menunode.h b/src/menunode.h deleted file mode 100644 index a51f61c..0000000 --- a/src/menunode.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___MENUNODE_H -#define ___MENUNODE_H - -#include - -class IMenuItemDefinition; -class MenuNode; -class cOsdMenu; -class IMenuNodeProcessor; - -typedef std::vector MenuNodeList; - -class MenuNode -{ - private: - MenuNode* _parent; - MenuNodeList _childs; - - protected: - void SetParent(MenuNode* parent); - - public: - MenuNode(); - virtual ~MenuNode(); - MenuNode* Parent(); - MenuNodeList* Childs(); - MenuNode* AddChild(MenuNode* child); - virtual bool IsLeaf(); - virtual void Process(IMenuNodeProcessor* menuNodeProcessor) = 0; - virtual cOsdMenu* Execute(); - virtual bool IsHidden(); -}; - -#endif diff --git a/src/menuorg.cpp b/src/menuorg.cpp deleted file mode 100644 index d06994c..0000000 --- a/src/menuorg.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "version.h" -#include "menuorg.h" -#include "menusetup.h" -#include "menuconfiguration.h" -#include "mainmenuitemsprovider.h" -#include "i18n.h" -#include "pluginsetup.h" - -using namespace std; - -MenuOrgPlugin::MenuOrgPlugin(void) -{ - // Initialize any member variables here. - // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL - // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! - - _subMenuProvider = NULL; -} - -MenuOrgPlugin::~MenuOrgPlugin() -{ - delete _subMenuProvider; - delete _menuConfiguration; -} - -const char* MenuOrgPlugin::Version(void) -{ - return VERSION; -} - -const char* MenuOrgPlugin::Description(void) -{ - return tr("reorganize main menu"); -} - -const char* MenuOrgPlugin::MainMenuEntry(void) -{ - if(_pluginConfiguration.MainMenuEntryHidden()) - return NULL; - else - return tr("Menu-Organizer"); -} - -const char *MenuOrgPlugin::CommandLineHelp(void) -{ - return " -c FILE --config=FILE loads the specified xml file\n" - " (default: ConfigDir/plugins/menuorg.xml)\n"; -} - -bool MenuOrgPlugin::ProcessArgs(int argc, char *argv[]) -{ - static struct option longOptions[] = - { - { "config", required_argument, NULL, 'c'}, - { NULL} - }; - - optind = 0; - opterr = 0; - - int optionChar; - int optionIndex = 0; - while ((optionChar = getopt_long(argc, argv, "c:", longOptions, &optionIndex)) != -1) - { - switch (optionChar) - { - case 'c': - _configFile = optarg; - break; - - default: - cerr << argv[0] << ": " << "invalid option " << argv[optind-1] << endl; - return false; - } - } - return true; -} - -bool MenuOrgPlugin::Initialize(void) -{ - if (_configFile.empty()) - { - _configFile = (string) ConfigDirectory() + "/menuorg.xml"; - } - - _menuConfiguration = new MenuConfiguration(_configFile, _pluginConfiguration.UnconfiguredPluginsInluded()); - // TODO need handling of unloadable config File here!!! - - _subMenuProvider = new MainMenuItemsProvider(*_menuConfiguration); - - RegisterI18n(Phrases); - - return true; -} - -cOsdObject *MenuOrgPlugin::MainMenuAction(void) -{ - return new cMenuOrgSetup(*_menuConfiguration, _pluginConfiguration.MenuSetupStyle()); -} - -cMenuSetupPage *MenuOrgPlugin::SetupMenu(void) -{ - return new PluginSetup(_pluginConfiguration, *_menuConfiguration); -} - -bool MenuOrgPlugin::SetupParse(const char *Name, const char *Value) -{ - return _pluginConfiguration.SetConfigurationOptionByName(Name, Value); -} - -bool MenuOrgPlugin::Service(const char *Id, void *Data) -{ - if (strcmp(Id, MENU_ITEMS_PROVIDER_SERVICE_ID) == 0 && _pluginConfiguration.CustomMenuActive()) - { - if (_subMenuProvider) - { - IMainMenuItemsProvider** ptr = (IMainMenuItemsProvider**)Data; - *ptr = _subMenuProvider; - - return true; - } - else - { - // TODO; Handling of unloadable config file should not be done here - Skins.Message(mtError, tr("Failed to load MenuOrg's config file!")); - } - } - - return false; -} diff --git a/src/menuorg.h b/src/menuorg.h deleted file mode 100644 index 3ce939d..0000000 --- a/src/menuorg.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___MENUORGPLUGIN_H -#define ___MENUORGPLUGIN_H - -#include -#include -#include "pluginconfiguration.h" - -class MainMenuItemsProvider; -class MenuConfiguration; - -class MenuOrgPlugin : public cPlugin -{ - private: - MainMenuItemsProvider* _subMenuProvider; - std::string _configFile; - PluginConfiguration _pluginConfiguration; - MenuConfiguration* _menuConfiguration; - - public: - MenuOrgPlugin(void); - virtual ~MenuOrgPlugin(); - virtual const char* Version(void); - virtual const char* Description(void); - virtual const char* CommandLineHelp(void); - virtual bool ProcessArgs(int argc, char* argv[]); - virtual bool Initialize(void); - virtual const char* MainMenuEntry(void); - virtual cOsdObject* MainMenuAction(void); - virtual cMenuSetupPage *SetupMenu(void); - virtual bool SetupParse(const char* Name, const char* Value); - virtual bool Service(const char* Id, void* Data = NULL); -}; - -extern "C" void* VDRPluginCreator(); - -#endif diff --git a/src/menusetup.cpp b/src/menusetup.cpp deleted file mode 100644 index 1f7372b..0000000 --- a/src/menusetup.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "menusetup.h" -#include "menuconfiguration.h" -#include "menuitemsetup.h" -#include "osdxmlitem.h" -#include -#include -#include -#include - -using namespace xmlpp; -using namespace std; - -cMenuOrgSetup::cMenuOrgSetup(MenuConfiguration& menuConfiguration, bool flatMenuSetup) -:cOsdMenu(tr("Menu Setup")),_menuConfiguration(menuConfiguration) -{ - _flatMenuSetup = flatMenuSetup; - CreateMenuItems(_menuConfiguration.Configuration(), 0); -} - -void cMenuOrgSetup::CreateMenuItems(const Element* menuRoot, int iCount) -{ - int cur=Current(); - - if(iCount == 0) - Clear(); - - Node::NodeList children = menuRoot->get_children(); - for (Node::NodeList::iterator i = children.begin(); i != children.end(); i++) - { - const Element* childElement = dynamic_cast(*i); - - if (childElement) - { - const Attribute* nameAttribute = childElement->get_attribute("name"); - - string type = childElement->get_name(); - string name = nameAttribute->get_value(); - - for (int i=0; i <= iCount ;i++) - name = " " + name; - - if ( type == "menu" && _flatMenuSetup) - { - name = "+" + name; - Add(new cOsdXmlItem(name.c_str(), childElement, osUnknown)); - CreateMenuItems(childElement, iCount+1); - } - else - { - if(iCount > 0) - name = " " + name; - - Add(new cOsdXmlItem(name.c_str(), childElement, osUnknown)); - } - } - } - if(iCount == 0) - { - SetCurrent(Get(cur)); - Display(); - DrawButton(); - } -} - -eOSState cMenuOrgSetup::ProcessKey(eKeys Key) -{ - eOSState state = cOsdMenu::ProcessKey(Key); - - if(HasSubMenu()) - { - return state; - } - if(state == osUnknown) - { - switch(Key) - { - case kRed: - DrawButton(); - break; - - case kGreen: - { - cOsdXmlItem *item = (cOsdXmlItem*) Get(Current()); - state = AddSubMenu(new cMenuItemSetup(item)); - } - break; - - case kYellow: - DrawButton(); - break; - - case kBlue: - DrawButton(); - break; - - case kUp: - case kDown: - case kLeft: - DrawButton(); - break; - - case kOk: - if (Interface->Confirm(tr("Apply Changes?"))) - { - // Save it! - } - return osEnd; - break; - - case kBack : - return osBack; - break; - - default: - DrawButton(); - break; - } - } - return state; -} - -void cMenuOrgSetup::DrawButton(void) -{ - SetHelp(tr("Create"),tr("Edit"),tr("Delete"),tr("Move")); - Display(); -} diff --git a/src/menusetup.h b/src/menusetup.h deleted file mode 100644 index 8fd64e7..0000000 --- a/src/menusetup.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___MENUSETUP_H -#define ___MENUSETUP_H - -#include -#include - -namespace xmlpp { class Element; } - -class MenuConfiguration; - -class cMenuOrgSetup : public cOsdMenu -{ - private: - MenuConfiguration& _menuConfiguration; - bool _flatMenuSetup; - - public: - cMenuOrgSetup(MenuConfiguration& menuConfiguration, bool flatMenuSetup); - virtual eOSState ProcessKey(eKeys Key); - - private: - void DrawButton(void); - void CreateMenuItems(const xmlpp::Element* menuRoot, int iCount); -}; - -#endif diff --git a/src/osditemdefinition.cpp b/src/osditemdefinition.cpp deleted file mode 100644 index f28334b..0000000 --- a/src/osditemdefinition.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "osditemdefinition.h" - -OsdItemDefinition::OsdItemDefinition(cOsdItem* osdItem) -{ - _osdItem = osdItem; -} - -bool OsdItemDefinition::IsCustomOsdItem() -{ - return true; -} - -bool OsdItemDefinition::IsPluginItem() -{ - return false; -} - -cOsdItem* OsdItemDefinition::CustomOsdItem() -{ - return _osdItem; -} - -const char* OsdItemDefinition::PluginMenuEntry() -{ - return NULL; -} - -int OsdItemDefinition::PluginIndex() -{ - return 0; -} diff --git a/src/osditemdefinition.h b/src/osditemdefinition.h deleted file mode 100644 index 0c4bad7..0000000 --- a/src/osditemdefinition.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___OSDITEMDEFINITION_H -#define ___OSDITEMDEFINITION_H - -#include - -class OsdItemDefinition: public IMenuItemDefinition -{ - private: - cOsdItem* _osdItem; - - public: - OsdItemDefinition(cOsdItem* osdItem); - virtual bool IsCustomOsdItem(); - virtual bool IsPluginItem(); - virtual cOsdItem* CustomOsdItem(); - virtual const char* PluginMenuEntry(); - virtual int PluginIndex(); -}; - -#endif diff --git a/src/osdlineitem.cpp b/src/osdlineitem.cpp deleted file mode 100644 index a3e8461..0000000 --- a/src/osdlineitem.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "osdlineitem.h" - -cOsdLineItem::cOsdLineItem(const char *Text) -{ - SetSelectable(false); - SetText(Text); -} diff --git a/src/osdlineitem.h b/src/osdlineitem.h deleted file mode 100644 index 4fb6cb6..0000000 --- a/src/osdlineitem.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___OSDLINEITEM_H -#define ___OSDLINEITEM_H - -#include - -class cOsdLineItem : public cOsdItem -{ - public: - cOsdLineItem(const char *Text); -}; - -#endif diff --git a/src/osdxmlitem.cpp b/src/osdxmlitem.cpp deleted file mode 100644 index 77e99f1..0000000 --- a/src/osdxmlitem.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include -#include -#include -#include "osdxmlitem.h" - -using namespace std; -using namespace xmlpp; - -cOsdXmlItem::cOsdXmlItem(const char* Text, const xmlpp::Element* xmlElement, eOSState State=osUnknown) -: cOsdItem(Text, State) -{ - _xmlElement = xmlElement; - parseXmlElement(); -} - -void cOsdXmlItem::parseXmlElement(void) -{ - const Attribute* nameAttribute = _xmlElement->get_attribute("name"); - - string type = _xmlElement->get_name(); - string name = nameAttribute->get_value(); - - setNameAttribute(name); - - if (type == "system") - { - setItemType(SYSTEM); - const Attribute* titleAttribute = _xmlElement->get_attribute("title"); - string title = titleAttribute ? (string) titleAttribute->get_value() : ""; - setTitleAttribute(title); - } - else if (type == "plugin") - { - setItemType(PLUGIN); - const Attribute* titleAttribute = _xmlElement->get_attribute("title"); - string title = titleAttribute ? (string) titleAttribute->get_value() : ""; - setTitleAttribute(title); - } - else if ( type == "menu") - { - setItemType(MENU); - } - else if (type == "command") - { - setItemType(COMMAND); - - string execute = _xmlElement->get_attribute("execute")->get_value(); - setCommandAttribute(execute); - - const Attribute* confirmAttribute = _xmlElement->get_attribute("confirm"); - if (confirmAttribute) - setConfirmAttribute(confirmAttribute->get_value()); - } -} - -cOsdXmlItem::sItemType cOsdXmlItem::getItemType(void) -{ - return _ItemType; -} - -string cOsdXmlItem::getNameAttribute(void) -{ - return _nameAttribute; -} - -string cOsdXmlItem::getTitleAttribute(void) -{ - return _titleAttribute; -} - -string cOsdXmlItem::getCommandAttribute(void) -{ - return _commandAttribute; -} - -string cOsdXmlItem::getConfirmAttribute(void) -{ - return _confirmAttribute; -} - -void cOsdXmlItem::setItemType(sItemType type) -{ - _ItemType = type; -} - -void cOsdXmlItem::setNameAttribute(string name) -{ - _nameAttribute = name; -} - -void cOsdXmlItem::setTitleAttribute(string title) -{ - _titleAttribute = title; -} - -void cOsdXmlItem::setCommandAttribute(string command) -{ - _commandAttribute = command; -} - -void cOsdXmlItem::setConfirmAttribute(string confirm) -{ - _confirmAttribute = confirm; -} diff --git a/src/osdxmlitem.h b/src/osdxmlitem.h deleted file mode 100644 index 1167f3d..0000000 --- a/src/osdxmlitem.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___OSDXMLITEM_H -#define ___OSDXMLITEM_H - -#include -#include -#include - -using namespace std; -namespace xmlpp { class Element; } - -class cOsdXmlItem: public cOsdItem -{ - public: - const xmlpp::Element* _xmlElement; - - enum sItemType - { - SYSTEM = 0, - PLUGIN = 1, - MENU = 2, - COMMAND = 3 - }; - - private: - sItemType _ItemType; - string _nameAttribute; - string _titleAttribute; - string _commandAttribute; - string _confirmAttribute; - - public: - cOsdXmlItem(const char* Text, const xmlpp::Element* xmlElement, eOSState State); - - sItemType getItemType(void); - string getNameAttribute(void); - string getTitleAttribute(void); - string getCommandAttribute(void); - string getConfirmAttribute(void); - - void setItemType(sItemType type); - void setNameAttribute(string name); - void setTitleAttribute(string title); - void setCommandAttribute(string command); - void setConfirmAttribute(string confirm); - - private: - void parseXmlElement(void); // parse the xml element and set the private attributes -}; - -#endif diff --git a/src/pluginconfiguration.cpp b/src/pluginconfiguration.cpp deleted file mode 100644 index 681d010..0000000 --- a/src/pluginconfiguration.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id: pluginsetup.h 6098 2007-08-28 12:20:45Z svntcreutz $ - * - */ - -#include "pluginconfiguration.h" -#include -#include - -const char* PluginConfiguration::SetupName::CustomMenuActive = "customMenuActive"; -const char* PluginConfiguration::SetupName::UnconfiguredPluginsIncluded = "unconfiguredPluginsIncluded"; -const char* PluginConfiguration::SetupName::HideMainMenuEntry = "hideMainMenuEntry"; -const char* PluginConfiguration::SetupName::MenuSetupStyle = "menuSetupStyle"; - -PluginConfiguration::PluginConfiguration() -{ - SetDefaults(); -} - -bool PluginConfiguration::CustomMenuActive() -{ - return _customMenuActive; -} - -bool PluginConfiguration::UnconfiguredPluginsInluded() -{ - return _unconfiguredPluginsIncluded; -} - -bool PluginConfiguration::MainMenuEntryHidden() -{ - return _hideMainMenuEntry; -} - -int PluginConfiguration::MenuSetupStyle() -{ - return _menuSetupStyle; -} - -void PluginConfiguration::SetDefaults() -{ - _customMenuActive = true; - _hideMainMenuEntry = true; - _menuSetupStyle = 0; - _unconfiguredPluginsIncluded = true; -} - -bool PluginConfiguration::SetConfigurationOptionByName(const char* Name, const char* Value) -{ - if (!strcasecmp(Name, SetupName::CustomMenuActive)) - { - _customMenuActive = (atoi(Value) != 0); - } - else if(!strcasecmp(Name, SetupName::UnconfiguredPluginsIncluded)) - { - _unconfiguredPluginsIncluded = (atoi(Value) != 0); - } - else if(!strcasecmp(Name, SetupName::HideMainMenuEntry)) - { - _hideMainMenuEntry = (atoi(Value) != 0); - } - else if(!strcasecmp(Name, SetupName::MenuSetupStyle)) - { - _menuSetupStyle = (atoi(Value) != 0); - } - else - return false; - - return true; -} diff --git a/src/pluginconfiguration.h b/src/pluginconfiguration.h deleted file mode 100644 index b90d6b0..0000000 --- a/src/pluginconfiguration.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___PLUGINCONFIGURATION_H_ -#define ___PLUGINCONFIGURATION_H_ - -class PluginConfiguration -{ - friend class PluginSetup; - - private: - struct SetupName - { - static const char* CustomMenuActive; - static const char* UnconfiguredPluginsIncluded; - static const char* HideMainMenuEntry; - static const char* MenuSetupStyle; - }; - - private: - bool _customMenuActive; - bool _unconfiguredPluginsIncluded; - bool _hideMainMenuEntry; - int _menuSetupStyle; - - public: - PluginConfiguration(); - bool SetConfigurationOptionByName(const char* Name, const char* Value); - bool CustomMenuActive(); - bool UnconfiguredPluginsInluded(); - bool MainMenuEntryHidden(); - int MenuSetupStyle(); - - private: - void SetDefaults(); -}; - -#endif - diff --git a/src/plugincreator.cpp b/src/plugincreator.cpp deleted file mode 100644 index bffc72b..0000000 --- a/src/plugincreator.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id:$ - * - */ - -#include "menuorg.h" - -extern "C" void *VDRPluginCreator() -{ - MenuOrgPlugin* plugin = new MenuOrgPlugin(); - return plugin; -} diff --git a/src/pluginitemdefinition.cpp b/src/pluginitemdefinition.cpp deleted file mode 100644 index f74a04d..0000000 --- a/src/pluginitemdefinition.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "pluginitemdefinition.h" - -PluginItemDefinition::PluginItemDefinition(const char* mainMenuEntry, int pluginIndex) -{ - _mainMenuEntry = mainMenuEntry; - _pluginIndex = pluginIndex; -} - -bool PluginItemDefinition::IsCustomOsdItem() -{ - return false; -} - -bool PluginItemDefinition::IsPluginItem() -{ - return true; -} - -cOsdItem* PluginItemDefinition::CustomOsdItem() -{ - return NULL; -} - -const char* PluginItemDefinition::PluginMenuEntry() -{ - return _mainMenuEntry; -} - -int PluginItemDefinition::PluginIndex() -{ - return _pluginIndex; -} diff --git a/src/pluginitemdefinition.h b/src/pluginitemdefinition.h deleted file mode 100644 index 75ad0a3..0000000 --- a/src/pluginitemdefinition.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___PLUGINITEMDEFINITION_H -#define ___PLUGINITEMDEFINITION_H - -#include - -class PluginItemDefinition: public IMenuItemDefinition -{ - private: - const char* _mainMenuEntry; - int _pluginIndex; - - public: - PluginItemDefinition(const char* mainMenuEntry, int pluginIndex); - virtual bool IsCustomOsdItem(); - virtual bool IsPluginItem(); - virtual cOsdItem* CustomOsdItem(); - virtual const char* PluginMenuEntry(); - virtual int PluginIndex(); -}; - -#endif diff --git a/src/pluginmenunode.cpp b/src/pluginmenunode.cpp deleted file mode 100644 index af45efe..0000000 --- a/src/pluginmenunode.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include -#include "pluginmenunode.h" -#include -#include -#include "pluginitemdefinition.h" -#include "childlock.h" -#include "imenunodeprocessor.h" - -using namespace std; - -PluginMenuNode::PluginMenuNode(cPlugin* plugin, int pluginIndex, string title) -{ - _plugin = plugin; - _pluginIndex = pluginIndex; - _title = title; -} - -bool PluginMenuNode::IsHidden() -{ - return (!HasMainMenuEntry()) || ChildLock::IsPluginHidden(_plugin); -} - -bool PluginMenuNode::HasMainMenuEntry() -{ - return (_plugin->MainMenuEntry() != NULL); -} - -cPlugin* PluginMenuNode::Plugin() -{ - return _plugin; -} - -void PluginMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) -{ - menuNodeProcessor->ProcessPluginMenuNode(this); -} - -int PluginMenuNode::PluginIndex(){ - return _pluginIndex; -} - -std::string PluginMenuNode::Title(){ - return _title; -} diff --git a/src/pluginmenunode.h b/src/pluginmenunode.h deleted file mode 100644 index fa89c13..0000000 --- a/src/pluginmenunode.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___PLUGINMENUNODE_H -#define ___PLUGINMENUNODE_H - -#include -#include "menunode.h" - -class cPlugin; -class IMenuNodeProcessor; - -class PluginMenuNode: public MenuNode -{ - private: - cPlugin* _plugin; - int _pluginIndex; - std::string _title; - - public: - PluginMenuNode(cPlugin* plugin, int pluginIndex, std::string title = ""); - cPlugin* Plugin(); - int PluginIndex(); - std::string Title(); - - // MenuNode - virtual void Process(IMenuNodeProcessor* menuNodeProcessor); - bool IsHidden(); - - private: - bool HasMainMenuEntry(); -}; - -#endif diff --git a/src/pluginsetup.cpp b/src/pluginsetup.cpp deleted file mode 100644 index 54d2a72..0000000 --- a/src/pluginsetup.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include -#include -#include "menuorg.h" -#include "pluginsetup.h" -#include "menusetup.h" -#include "RecursiveMenuSetup.h" -#include "menuconfiguration.h" - -PluginSetup::PluginSetup(PluginConfiguration& pluginConfiguration, MenuConfiguration& menuConfiguration) - :_pluginConfiguration(pluginConfiguration), _menuConfiguration(menuConfiguration) -{ - CreateMenuItems(); -} - -void PluginSetup::Store(void) -{ - SetupStore(PluginConfiguration::SetupName::CustomMenuActive, - _pluginConfiguration._customMenuActive = _newCustomMenuActive); - SetupStore(PluginConfiguration::SetupName::UnconfiguredPluginsIncluded, - _pluginConfiguration._unconfiguredPluginsIncluded = _newUnconfiguredPluginsIncluded); - SetupStore(PluginConfiguration::SetupName::HideMainMenuEntry, - _pluginConfiguration._hideMainMenuEntry = _newHideMainMenuEntry); - SetupStore(PluginConfiguration::SetupName::MenuSetupStyle, - _pluginConfiguration._menuSetupStyle = _newMenuSetupStyle); -} - -eOSState PluginSetup::ProcessKey(eKeys Key) -{ - eOSState state = cOsdMenu::ProcessKey(Key); - - if (HasSubMenu()) - { - return state; - } - switch(state) - { - case osUser1: - if (_pluginConfiguration.MenuSetupStyle() == 0 ) - { - return AddSubMenu(new cMenuOrgSetup(_menuConfiguration, _pluginConfiguration._menuSetupStyle)); - } - else - { - return AddSubMenu(new RecursiveMenuSetup(*_menuConfiguration.MenuTree())); - } - - case osContinue: - if(NORMALKEY(Key)==kUp || NORMALKEY(Key)==kDown) - { - cOsdItem *item=Get(Current()); - if(item) item->ProcessKey(kNone); - } - break; - - case osUnknown: - if(Key==kOk) - { - Store(); - state=osBack; - } - break; - - default: - break; - } - return state; -} - -void PluginSetup::CreateMenuItems() -{ - Add(new cMenuEditBoolItem(tr("Enable custom menu"), &_newCustomMenuActive)); - Add(new cMenuEditBoolItem(tr("Include unconfigured plugins"), &_newUnconfiguredPluginsIncluded)); - Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &_newHideMainMenuEntry)); - Add(new cMenuEditBoolItem(tr("Menu setup style"), &_newMenuSetupStyle, tr("MenuBased"), tr("Flat"))); - Add(new cOsdItem(tr("Configure menu"), osUser1)); -} diff --git a/src/pluginsetup.h b/src/pluginsetup.h deleted file mode 100644 index 99ff705..0000000 --- a/src/pluginsetup.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___PLUGINSETUP_H -#define ___PLUGINSETUP_H - -#include - -class PluginConfiguration; -class MenuConfiguration; - -class PluginSetup : public cMenuSetupPage -{ - private: - int _newCustomMenuActive; - int _newUnconfiguredPluginsIncluded; - int _newHideMainMenuEntry; - int _newMenuSetupStyle; - PluginConfiguration& _pluginConfiguration; - MenuConfiguration& _menuConfiguration; - - public: - PluginSetup(PluginConfiguration& pluginConfiguration, MenuConfiguration& menuConfiguration); - virtual eOSState ProcessKey(eKeys Key); - - protected: - virtual void Store(void); - - private: - void CreateMenuItems(); -}; - -#endif diff --git a/src/submenunode.cpp b/src/submenunode.cpp deleted file mode 100644 index 95a15d2..0000000 --- a/src/submenunode.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "submenunode.h" -#include -#include "osditemdefinition.h" -#include "childlock.h" -#include "imenunodeprocessor.h" - -using namespace std; - -SubMenuNode::SubMenuNode(string text) -{ - _text = text; -} - -bool SubMenuNode::IsLeaf() -{ - return false; -} - -string SubMenuNode::Text() -{ - return _text; -} - -bool SubMenuNode::IsHidden() -{ - return ChildLock::IsMenuHidden(_text.c_str()); -} - -void SubMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) -{ - menuNodeProcessor->ProcessSubMenuNode(this); -} diff --git a/src/submenunode.h b/src/submenunode.h deleted file mode 100644 index 5ad1c6b..0000000 --- a/src/submenunode.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___SUBMENUNODE_H -#define ___SUBMENUNODE_H - -#include "menunode.h" -#include - -class IMenuNodeProcessor; - -class SubMenuNode: public MenuNode -{ - private: - std::string _text; - - public: - SubMenuNode(std::string text); - std::string Text(); - - // MenuNode - bool IsLeaf(); - virtual void Process(IMenuNodeProcessor* menuNodeProcessor); - bool IsHidden(); -}; - -#endif diff --git a/src/systemmenunode.cpp b/src/systemmenunode.cpp deleted file mode 100644 index 4eb080b..0000000 --- a/src/systemmenunode.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#include "systemmenunode.h" -#include -#include "osditemdefinition.h" -#include "childlock.h" -#include "imenunodeprocessor.h" - -using namespace std; - -SystemMenuNode::SystemMenuNode(eOSState state, string text) -{ - _text = text; - _state = state; -} - -bool SystemMenuNode::IsHidden() -{ - return ChildLock::IsMenuHidden(_text.c_str()); -} - -void SystemMenuNode::Process(IMenuNodeProcessor* menuNodeProcessor) -{ - menuNodeProcessor->ProcessSystemMenuNode(this); -} - -eOSState SystemMenuNode::State() -{ - return _state; -} - -string SystemMenuNode::Text() -{ - return _text; -} diff --git a/src/systemmenunode.h b/src/systemmenunode.h deleted file mode 100644 index 8b14f2d..0000000 --- a/src/systemmenunode.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * vdr-menuorg - A plugin for the Linux Video Disk Recorder - * Copyright (C) 2007 Thomas Creutz, Tobias Grimm - * - * 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-1307 USA - * - * $Id$ - * - */ - -#ifndef ___SYSTEMMENUNODE_H -#define ___SYSTEMMENUNODE_H - -#include "menunode.h" -#include -#include - -class IMenuNodeProcessor; - -class SystemMenuNode: public MenuNode -{ - private: - std::string _text; - eOSState _state; - - public: - SystemMenuNode(eOSState state, std::string text); - - std::string Text(); - eOSState State(); - - // MenuNode - virtual void Process(IMenuNodeProcessor* menuNodeProcessor); - bool IsHidden(); -}; - -#endif -- cgit v1.2.3