[vdr] [PATCH] vdr-1.3.33 - channelfilter 0.1

Walter Koch koch at u32.de
Sun Sep 25 20:35:22 CEST 2005


Moin, 

this patch filters the channel list on demand. 
A additional column of channel attributes is also added:
 "t" = TV
 "r" = radio
 "d" = data
 "x" = encrypted

Pressing the key "2" in the channel list hides all non TV channels.

Pressing the key "3" hides all non radio channels.

Pressing the key "4" hides all encrypted channesls (caid>4) 
Pressing the "4" again shows the encrypted channels again.
This works also in conjunction with the other filters.
e.g. pressing "2" and then "4", results in a list containing only 
unencrypted tv channels.

The filtering works also together with vdr's own sorting (key "0")

Pressing "1" or closing and reopening the channel list
resets any filtering.

I tested the patch against vdr 1.3.31 and vdr 1.3.33. It should 
also works with older 1.3.x-Versions. There are no translations yet. I'll
add them after final bugfixing.

Install it as usual in the source directory of vdr
  patch -p1 < vdr-1.3.xx-channelfilter-0.1.diff
  make
  make plugins
(a header file was changed, so plugin needs to be rebuild too)

Homepage www.u32.de/vdr.html#patches

Gruss,
  Walter



-- 
Die Gedanken sind frei. Das Nähere regelt ein Bundesgesetz.
-------------- next part --------------
diff -u vdr-1.3.33-org-nackt/channels.h w/channels.h
--- vdr-1.3.33-org-nackt/channels.h	2005-09-17 11:59:14.000000000 +0200
+++ w/channels.h	2005-09-25 19:19:32.000000000 +0200
@@ -172,6 +172,10 @@
   int Tid(void) const { return tid; }
   int Sid(void) const { return sid; }
   int Rid(void) const { return rid; }
+  bool IsTV(void)    const { return (vpid > 0)  && (Apid(0)>0); }
+  bool IsRadio(void) const { return (vpid == 0) && (Apid(0)>0); }
+  bool IsData(void) const { return (Dpid(0) > 0); }
+  bool IsCrypted(void) const { return (Ca() > 4); }
   int Number(void) const { return number; }
   void SetNumber(int Number) { number = Number; }
   bool GroupSep(void) const { return groupSep; }
diff -u vdr-1.3.33-org-nackt/menu.c w/menu.c
--- vdr-1.3.33-org-nackt/menu.c	2005-09-25 15:37:21.000000000 +0200
+++ w/menu.c	2005-09-25 19:19:32.000000000 +0200
@@ -370,7 +370,13 @@
      if (sortMode == csmProvider)
         asprintf(&buffer, "%d\t%s - %s", channel->Number(), channel->Provider(), channel->Name());
      else
-        asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name());
+        asprintf(&buffer, "%4d  %s%s%s%s  %s", channel->Number(), 
+	                                 channel->Vpid()>0 ? "t":" ", 
+					 (channel->Vpid()==0) && (channel->Apid(0) > 0) ? "r":" ",
+					 (channel->Dpid(0) > 0) ? "d":" ",
+					 channel->Ca(0)>4  ? "x":" ", 
+					 channel->Name()
+	);
      }
   else
      asprintf(&buffer, "---\t%s ----------------------------------------------------------------", channel->Name());
@@ -384,6 +390,8 @@
   void Setup(void);
   cChannel *GetChannel(int Index);
   void Propagate(void);
+  bool IsFiltered(void);
+  int onlyTV, onlyRadio, onlyUncrypt;
 protected:
   eOSState Switch(void);
   eOSState Edit(void);
@@ -399,6 +407,7 @@
 cMenuChannels::cMenuChannels(void)
 :cOsdMenu(tr("Channels"), CHNUMWIDTH)
 {
+  onlyTV = onlyRadio = onlyUncrypt = 0;
   Setup();
   Channels.IncBeingEdited();
 }
@@ -414,19 +423,38 @@
   if (!currentChannel)
      currentChannel = Channels.GetByNumber(cDevice::CurrentChannel());
   cMenuChannelItem *currentItem = NULL;
+  cMenuChannelItem *lastUsedItem = NULL;
+  cMenuChannelItem *firstUsedItem = NULL;
   Clear();
+  
   for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
-      if (!channel->GroupSep() || cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber && *channel->Name()) {
-         cMenuChannelItem *item = new cMenuChannelItem(channel);
-         Add(item);
-         if (channel == currentChannel)
-            currentItem = item;
-         }
+      if ((!channel->GroupSep() || cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber)
+            && *channel->Name()  //Channel must have a name
+	    && (channel->GroupSep() || //Do not filter Groupseperators
+            	(  !(onlyTV      && !channel->IsTV()     ) 
+  		&& !(onlyRadio   && !channel->IsRadio()  )
+		&& !(onlyUncrypt && channel->IsCrypted() ) 
+	    ))) {
+            cMenuChannelItem *item = new cMenuChannelItem(channel);
+            Add(item);
+            if (channel == currentChannel)
+        	currentItem = item;
+	    if (!channel->GroupSep()) {
+		lastUsedItem = item;
+		if( !firstUsedItem )
+		    firstUsedItem = item;
+	    }
+      } else {
+            if (channel == currentChannel)
+        	currentItem = lastUsedItem; // current channel is now invisible, so we use the nearest channel
       }
+  }
   if (cMenuChannelItem::SortMode() != cMenuChannelItem::csmNumber)
      Sort();
+  if (!currentItem) // happens, if after filtering the first line is a groupsep
+     currentItem = firstUsedItem;
   SetCurrent(currentItem);
-  SetHelp(tr("Edit"), tr("New"), tr("Delete"), cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber ? tr("Mark") : NULL);
+  SetHelp(tr("Edit"), tr("New"), tr("Delete"), !IsFiltered() && cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber ? tr("Mark") : NULL);
   Display();
 }
 
@@ -445,6 +473,11 @@
   Channels.SetModified(true);
 }
 
+bool cMenuChannels::IsFiltered(void)
+{
+  return onlyTV || onlyRadio || onlyUncrypt;
+}
+
 eOSState cMenuChannels::Switch(void)
 {
   if (HasSubMenu())
@@ -532,11 +565,36 @@
               case k0:      cMenuChannelItem::IncSortMode();
                             Setup();
                             break;
+              case k1:      // show all channels (default)
+	                    onlyTV = onlyRadio = onlyUncrypt = 0;
+                            Setup();
+			    Skins.Message(mtStatus, "All channels");
+                            break;
+              case k2:      // show only TV-channels with sound
+	                    onlyTV = !0;
+			    onlyRadio = 0;
+                            Setup();
+			    Skins.Message(mtStatus, "Show only tv channels");
+                            break;
+              case k3:      // show only radio/broadcast
+	                    onlyTV = 0;
+	                    onlyRadio = !0;
+                            Setup();
+			    Skins.Message(mtStatus, "Show only radio channels");
+                            break;
+              case k4:      // switch Crypt
+	                    onlyUncrypt = !onlyUncrypt;
+                            Setup();
+			    if( onlyUncrypt ) 
+			       Skins.Message(mtStatus, "Show only uncrypted channels");
+			    else
+			       Skins.Message(mtStatus, "Show uncrypted and crypted channels");
+                            break;
               case kOk:     return Switch();
               case kRed:    return Edit();
               case kGreen:  return New();
               case kYellow: return Delete();
-              case kBlue:   if (!HasSubMenu() && cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber)
+              case kBlue:   if (!HasSubMenu() && !IsFiltered() && cMenuChannelItem::SortMode() == cMenuChannelItem::csmNumber)
                                Mark();
                             break;
               default: break;
diff -u vdr-1.3.33-org-nackt/README.channelfilterpatch w/README.channelfilterpatch
--- vdr-1.3.33-org-nackt/README.channelfilterpatch	2005-09-25 19:46:45.000000000 +0200
+++ w/README.channelfilterpatch	2005-09-25 19:45:12.000000000 +0200
@@ -0,0 +1,78 @@
+english text see below
+
+Dieser Patch filtert in der Kanalliste (Punkt 2 im Hauptmenü)
+bei Bedarf unerwünschte Einträge, was die Übersichtlichkeit erhöhen kann.
+Ausserdem werden in der Liste Kanalattribute angezeigt:
+ "t" = TV
+ "r" = Radio
+ "d" = Daten
+ "x" = verschlüsselt
+
+Drückt man in der Liste die Taste "2", so werden nur noch Fernsehsender 
+angezeigt (also keine Radiosender, keine veraltete Einträge, keine reine
+Datenkanäle und keine Standbildersender)
+
+Drückt man die Taste "3" so werden analog nur Radiosender angezeigt.
+
+Drückt man die "4", so werden alle verschlüsselten Kanäle (caid>4) 
+ausgeblendet.
+Drückt man die "4" nochmal, so werden die verschlüsselten Kanäle 
+wieder eingeblendet. Das funktioniert auch im Zusammenhang mit den 
+anderen Filtern: Drückt man z.B. die "2" und die "4", so werden nur
+unverschlüsselte TV-Kanäle aufgelistet.
+
+Das Filtern funktioniert auch zusammen mit dem vdr-eigenen 
+Sortieren (Taste "0").
+
+Die Taste "1" oder das Beenden und Wiederaufrufen der Kanalliste 
+stellt jederzeit den originalen Zustand wieder her.
+
+Der Patch ist auf vdr 1.3.31 und vdr 1.3.33 getestet, geht aber wohl auch 
+mit älteren Version. Es fehlt allerdings noch die Übersetzungen; die 
+liefere ich nach, wenn etwaige Fehler beseitigt sind. 
+
+Installation wie üblich per 
+  patch -p1 < vdr-1.3.xx-channelfilter-0.1.diff
+im vdr-Quellcodeverzeichnis. Danach per "make" neu compilieren. 
+Eine Header-Datei wurde geändert, daher müssen die Plugins auch 
+neu übersetzt werden: "make plugins".
+
+Homepage www.u32.de/vdr.html#patches
+Fehlerberichte an vdrpatch at u32.de
+
+----------- english ---------------------
+
+This patch filters the channel list on demand. 
+A additional column of channel attributes is also added:
+ "t" = TV
+ "r" = radio
+ "d" = data
+ "x" = encrypted
+
+Pressing the key "2" in the channel list hides all non TV channels.
+
+Pressing the key "3" hides all non radio channels.
+
+Pressing the key "4" hides all encrypted channesls (caid>4) 
+Pressing the "4" again shows the encrypted channels again.
+This works also in conjunction with the other filters.
+e.g. pressing "2" and then "4", results in a list containing only 
+unencrypted tv channels.
+
+The filtering works also together with vdr's own sorting (key "0")
+
+Pressing "1" or closing and reopening the channel list
+resets any filtering.
+
+I tested the patch against vdr 1.3.31 and vdr 1.3.33. It should 
+also works with older 1.3.x-Versions. There are no translations yet. I'll 
+add them after final bugfixing.
+
+Install it as usual in the source directory of vdr
+  patch -p1 < vdr-1.3.xx-channelfilter-0.1.diff
+  make
+  make plugins
+(a header file was changed, so plugin needs to be rebuild too)
+
+Homepage www.u32.de/vdr.html#patches
+Reports Bugs to vdrpatch at u32.de


More information about the vdr mailing list