vdr/vdr/debian/patches 03_cmdsubmenu.dpatch 00list

Tobias Grimm pkg-vdr-dvb-changes@lists.alioth.debian.org
Sun, 23 May 2004 21:43:12 +0000


Update of /cvsroot/pkg-vdr-dvb/vdr/vdr/debian/patches
In directory haydn:/tmp/cvs-serv18238/patches

Modified Files:
	00list 
Added Files:
	03_cmdsubmenu.dpatch 
Log Message:
added submenu patch

--- NEW FILE: 03_cmdsubmenu.dpatch ---
#!/bin/sh -e
## submenu patch
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: adds submenus within the commands and recording commnnds menu

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"

case "$1" in
       -patch) patch $patch_opts -p1 < $0;;
       -unpatch) patch $patch_opts -p1 -R < $0;;
        *)
                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
                exit 1;;
esac

exit 0

@DPATCH@
--- vdr-1.2.6.orig/Makefile	Thu Oct  9 11:42:01 2003
+++ vdr-1.2.6/Makefile	Thu Oct  9 01:57:24 2003
@@ -51,6 +53,7 @@

 DEFINES += -DREMOTE_$(REMOTE)

+DEFINES += -DCMD_SUBMENUS
 DEFINES += -D_GNU_SOURCE

 DEFINES += -DVIDEODIR=\"$(VIDEODIR)\"
--- vdr-1.2.6.orig/config.c	Thu Oct  9 11:42:01 2003
+++ vdr-1.2.6/config.c	Thu Oct  9 00:14:17 2003
@@ -27,18 +27,29 @@
 {
   title = command = NULL;
   confirm = false;
+  nIndent = 0;
+  childs = NULL;
 }
 
 cCommand::~cCommand()
 {
   free(title);
   free(command);
+  delete childs;
 }
 
 bool cCommand::Parse(const char *s)
 {
   const char *p = strchr(s, ':');
   if (p) {
+    nIndent = 0;
+#ifdef CMD_SUBMENUS
+    while (*s == '-')
+    {
+      nIndent++;
+      s++;
+    }
+#endif // CMD_SUBMENUS
      int l = p - s;
      if (l > 0) {
         title = MALLOC(char, l + 1);
@@ -83,6 +94,76 @@
      esyslog("ERROR: can't open pipe for command '%s'", cmd);
   free(cmdbuf);
   return result;
+}
+
+int cCommand::getIndent ()
+{
+  return nIndent;
+}
+
+void cCommand::setIndent (int nNewIndent)
+{
+  nIndent = nNewIndent;
+}
+
+bool cCommand::hasChilds ()
+{
+  if (!childs)
+  {
+    return false;
+  }
+  return (childs->Count () > 0);
+}
+
+int cCommand::getChildCount ()
+{
+  if (!childs)
+  {
+    return false;
+  }
+  return childs->Count ();
+}
+
+void cCommand::addChild (cCommand *newChild)
+{
+  if (!childs)
+  {
+    childs = new cCommands ();
+  }
+  childs->Add (newChild);
+}
+
+
+cCommands *cCommand::getChilds ()
+{
+  return childs;
+}
+
+// --- cCommands -------------------------------------------------------
+
+void cCommands::Add(cListObject *Object, cListObject *After = NULL)
+{
+  cCommand *c = (cCommand *) Object;
+  cCommand *cParent;
+  int nIndent;
+  int nIndex;
+
+  if (!c)
+  {
+    return;
+  }
+  nIndent = c->getIndent ();
+  //  isyslog ("nIndent %d %s\n", nIndent, c->Title ());
+  for (nIndex = Count () - 1; nIndex >= 0; nIndex--)
+  {
+    cParent = (cCommand *) Get (nIndex);
+    if (cParent->getIndent () < nIndent)
+    {
+      cParent->addChild (c);
+      return;
+    }
+  }
+  cConfig<cCommand>::Add (Object, After);
 }
 
 // -- cSVDRPhost -------------------------------------------------------------
--- vdr-1.2.6.orig/config.h	Thu Oct  9 11:42:01 2003
+++ vdr-1.2.6/config.h	Thu Oct  9 01:28:20 2003
@@ -33,11 +33,15 @@
 
 #define MaxFileName 256
 
+class cCommands;
+
 class cCommand : public cListObject {
 private:
   char *title;
   char *command;
   bool confirm;
+  int nIndent;
+  cCommands *childs;
   static char *result;
 public:
   cCommand(void);
@@ -46,6 +50,12 @@
   const char *Title(void) { return title; }
   bool Confirm(void) { return confirm; }
   const char *Execute(const char *Parameters = NULL);
+  int getIndent ();
+  void setIndent (int nNewIndent);
+  bool hasChilds ();
+  int getChildCount ();
+  cCommands *getChilds ();
+  void addChild (cCommand *newChild);
   };
 
 typedef uint32_t in_addr_t; //XXX from /usr/include/netinet/in.h (apparently this is not defined on systems with glibc < 2.2)
@@ -222,7 +232,11 @@
   }
   };
 
-class cCommands : public cConfig<cCommand> {};
+class cCommands : public cConfig<cCommand> 
+{
+ public:
+  virtual void Add(cListObject *Object, cListObject *After = NULL);
+};
 
 class cSVDRPhosts : public cConfig<cSVDRPhost> {
 public:
--- vdr-1.2.6.orig/menu.c	Thu Oct  9 11:42:01 2003
+++ vdr-1.2.6/menu.c	Thu Oct  9 01:39:01 2003
@@ -28,6 +28,8 @@
 #include "timers.h"
 #include "transfer.h"
 #include "videodir.h"
+
+/* #include "dvbsub.h" */
 
 #include <malloc.h>//TK
 
@@ -1744,6 +1745,16 @@
   if (command) {
      char *buffer = NULL;
      bool confirmed = true;
+#ifdef CMD_SUBMENUS
+     if (command->hasChilds ())
+     {
+        cMenuCommands *menu;
+        eOSState state = AddSubMenu(menu = new cMenuCommands(command->Title (), command->getChilds (), parameters));
+	return osContinue;
+     }
+     else
+     {
+#endif // CMD_SUBMENUS
      if (command->Confirm()) {
         asprintf(&buffer, "%s?", command->Title());
         confirmed = Interface->Confirm(buffer);
@@ -1759,7 +1770,11 @@
            return AddSubMenu(new cMenuText(command->Title(), Result, fontFix));
         return osEnd;
         }
+#ifdef CMD_SUBMENUS
      }
+#endif // CMD_SUBMENUS
+
+  }
   return osContinue;
 }
 
--- vdr-1.2.6.orig/tools.h	Thu Oct  9 11:42:01 2003
+++ vdr-1.2.6/tools.h	Thu Oct  9 00:14:17 2003
@@ -158,7 +158,7 @@
   cListBase(void);
 public:
   virtual ~cListBase();
-  void Add(cListObject *Object, cListObject *After = NULL);
+  virtual void Add(cListObject *Object, cListObject *After = NULL);
   void Ins(cListObject *Object, cListObject *Before = NULL);
   void Del(cListObject *Object, bool DeleteObject = true);
   virtual void Move(int From, int To);

Index: 00list
===================================================================
RCS file: /cvsroot/pkg-vdr-dvb/vdr/vdr/debian/patches/00list,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- 00list	1 May 2004 13:11:14 -0000	1.2
+++ 00list	23 May 2004 21:43:10 -0000	1.3
@@ -1,2 +1,3 @@
 01_vdr_1.2.6-3.1.diff.gz
 02_Makefile-CFGDIR
+03_cmdsubmenu