aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>2008-02-01 23:15:24 +0000
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>2008-02-01 23:15:24 +0000
commitd89be097be4a9ac52166c5f47cc189c5522d3441 (patch)
tree7da4329e4fa22017a7312da52bfe7b1df8a16a02 /lib
parentec200e0207d0a5ddb91c9c6c4ab8ae1c8f33ecea (diff)
downloadenigma2-d89be097be4a9ac52166c5f47cc189c5522d3441.tar.gz
enigma2-d89be097be4a9ac52166c5f47cc189c5522d3441.zip
add possibilty to hide menu entries when needed hardware is not available
Diffstat (limited to 'lib')
-rw-r--r--lib/driver/avswitch.cpp14
-rw-r--r--lib/driver/avswitch.h1
-rw-r--r--lib/driver/misc_options.cpp12
-rw-r--r--lib/driver/misc_options.h1
-rw-r--r--lib/driver/rfmod.h2
-rw-r--r--lib/python/Components/AVSwitch.py3
-rw-r--r--lib/python/Components/Harddisk.py4
-rw-r--r--lib/python/Components/Makefile.am2
-rw-r--r--lib/python/Components/RFmod.py65
-rw-r--r--lib/python/Components/UsageConfig.py3
-rw-r--r--lib/python/Screens/Ci.py5
-rw-r--r--lib/python/Screens/Menu.py8
-rw-r--r--lib/python/Screens/Setup.py5
13 files changed, 91 insertions, 34 deletions
diff --git a/lib/driver/avswitch.cpp b/lib/driver/avswitch.cpp
index d582db81..a936aa54 100644
--- a/lib/driver/avswitch.cpp
+++ b/lib/driver/avswitch.cpp
@@ -1,6 +1,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
+#include <string.h>
#include <lib/base/init.h>
#include <lib/base/init_num.h>
@@ -81,6 +82,19 @@ eAVSwitch *eAVSwitch::getInstance()
return instance;
}
+bool eAVSwitch::haveScartSwitch()
+{
+ char tmp[255];
+ int fd = open("/proc/stb/avs/0/input_choices", O_RDONLY);
+ if(fd < 0) {
+ eDebug("cannot open /proc/stb/avs/0/input_choices");
+ return false;
+ }
+ read(fd, tmp, 255);
+ close(fd);
+ return !!strstr(tmp, "scart");
+}
+
void eAVSwitch::setInput(int val)
{
/*
diff --git a/lib/driver/avswitch.h b/lib/driver/avswitch.h
index 2b3b40fb..cc92e20e 100644
--- a/lib/driver/avswitch.h
+++ b/lib/driver/avswitch.h
@@ -24,6 +24,7 @@ public:
~eAVSwitch();
#endif
static eAVSwitch *getInstance();
+ bool haveScartSwitch();
int getVCRSlowBlanking();
void setFastBlank(int val);
void setColorFormat(int format);
diff --git a/lib/driver/misc_options.cpp b/lib/driver/misc_options.cpp
index ecb7bdb1..c567878c 100644
--- a/lib/driver/misc_options.cpp
+++ b/lib/driver/misc_options.cpp
@@ -39,6 +39,18 @@ int Misc_Options::set_12V_output(int state)
return 0;
}
+bool Misc_Options::detected_12V_output()
+{
+ int fd = open("/proc/stb/misc/12V_output", O_WRONLY);
+ if (fd < 0)
+ {
+ eDebug("couldn't open /proc/stb/misc/12V_output");
+ return false;
+ }
+ close(fd);
+ return true;
+}
+
Misc_Options *Misc_Options::getInstance()
{
return instance;
diff --git a/lib/driver/misc_options.h b/lib/driver/misc_options.h
index 6baf2cf2..81924944 100644
--- a/lib/driver/misc_options.h
+++ b/lib/driver/misc_options.h
@@ -15,6 +15,7 @@ public:
static Misc_Options *getInstance();
int set_12V_output(int val);
int get_12V_output() { return m_12V_output_state; }
+ bool detected_12V_output();
};
#endif // __misc_options_h
diff --git a/lib/driver/rfmod.h b/lib/driver/rfmod.h
index 909a08de..56f9ef50 100644
--- a/lib/driver/rfmod.h
+++ b/lib/driver/rfmod.h
@@ -16,7 +16,7 @@ public:
~eRFmod();
#endif
static eRFmod *getInstance();
-
+ bool detected() { return fd >= 0; }
void setFunction(int val); //0=Enable 1=Disable
void setTestmode(int val); //0=Enable 1=Disable
void setSoundFunction(int val); //0=Enable 1=Disable
diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py
index d3224fd7..ab17fd82 100644
--- a/lib/python/Components/AVSwitch.py
+++ b/lib/python/Components/AVSwitch.py
@@ -1,5 +1,6 @@
from config import config, ConfigSelection, ConfigYesNo, ConfigEnableDisable, ConfigSubsection, ConfigBoolean
from enigma import eAVSwitch
+from SystemInfo import SystemInfo
class AVSwitch:
INPUT = { "ENCODER": (0, 4), "SCART": (1, 3), "AUX": (2, 4) }
@@ -120,3 +121,5 @@ def InitAVSwitch():
config.av.wss.addNotifier(setWSS)
iAVSwitch.setInput("ENCODER") # init on startup
+ SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch()
+
diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py
index 16736b20..82535447 100644
--- a/lib/python/Components/Harddisk.py
+++ b/lib/python/Components/Harddisk.py
@@ -3,6 +3,8 @@ from os import system, listdir, statvfs, popen, makedirs
from Tools.Directories import SCOPE_HDD, resolveFilename
from Tools.CList import CList
+from SystemInfo import SystemInfo
+
def tryOpen(filename):
try:
procFile = open(filename)
@@ -215,6 +217,8 @@ class HarddiskManager:
hdd = Harddisk(hddNum)
self.hdd.append(hdd)
+ SystemInfo["Harddisc"] = len(self.hdd) > 0
+
# currently, this is just an enumeration of what's possible,
# this probably has to be changed to support automount stuff.
# still, if stuff is mounted into the correct mountpoints by
diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am
index 03c5d1c2..7a17eb74 100644
--- a/lib/python/Components/Makefile.am
+++ b/lib/python/Components/Makefile.am
@@ -17,4 +17,4 @@ install_PYTHON = \
FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \
MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py \
Element.py Playlist.py ParentalControl.py ParentalControlList.py \
- Ipkg.py SelectionList.py Scanner.py
+ Ipkg.py SelectionList.py Scanner.py SystemInfo.py
diff --git a/lib/python/Components/RFmod.py b/lib/python/Components/RFmod.py
index be088a53..a8f7c9f5 100644
--- a/lib/python/Components/RFmod.py
+++ b/lib/python/Components/RFmod.py
@@ -1,5 +1,6 @@
from config import config, ConfigSelection, ConfigSubsection, ConfigOnOff, ConfigSlider
from enigma import eRFmod
+from Components.SystemInfo import SystemInfo
# CHECK ME.
RFMOD_CHANNEL_MIN = 21
@@ -23,34 +24,36 @@ class RFmod:
eRFmod.getInstance().setFinetune(value)
def InitRFmod():
-
- config.rfmod = ConfigSubsection()
- config.rfmod.enable = ConfigOnOff(default=False)
- config.rfmod.test = ConfigOnOff(default=False)
- config.rfmod.sound = ConfigOnOff(default=True)
- config.rfmod.soundcarrier = ConfigSelection(choices=[("4500","4.5 MHz"), ("5500", "5.5 MHz"), ("6000", "6.0 MHz"), ("6500", "6.5 MHz")], default="5500")
- config.rfmod.channel = ConfigSelection(default = "36", choices = ["%d" % x for x in range(RFMOD_CHANNEL_MIN, RFMOD_CHANNEL_MAX)])
- config.rfmod.finetune = ConfigSlider(default=5, limits=(1, 10))
-
- iRFmod = RFmod()
-
- def setFunction(configElement):
- iRFmod.setFunction(configElement.value);
- def setTestmode(configElement):
- iRFmod.setTestmode(configElement.value);
- def setSoundFunction(configElement):
- iRFmod.setSoundFunction(configElement.value);
- def setSoundCarrier(configElement):
- iRFmod.setSoundCarrier(configElement.index);
- def setChannel(configElement):
- iRFmod.setChannel(int(configElement.value));
- def setFinetune(configElement):
- iRFmod.setFinetune(configElement.value - 5);
-
- # this will call the "setup-val" initial
- config.rfmod.enable.addNotifier(setFunction);
- config.rfmod.test.addNotifier(setTestmode);
- config.rfmod.sound.addNotifier(setSoundFunction);
- config.rfmod.soundcarrier.addNotifier(setSoundCarrier);
- config.rfmod.channel.addNotifier(setChannel);
- config.rfmod.finetune.addNotifier(setFinetune);
+ detected = eRFmod.getInstance().detected()
+ SystemInfo["RfModulator"] = detected
+ if detected:
+ config.rfmod = ConfigSubsection()
+ config.rfmod.enable = ConfigOnOff(default=False)
+ config.rfmod.test = ConfigOnOff(default=False)
+ config.rfmod.sound = ConfigOnOff(default=True)
+ config.rfmod.soundcarrier = ConfigSelection(choices=[("4500","4.5 MHz"), ("5500", "5.5 MHz"), ("6000", "6.0 MHz"), ("6500", "6.5 MHz")], default="5500")
+ config.rfmod.channel = ConfigSelection(default = "36", choices = ["%d" % x for x in range(RFMOD_CHANNEL_MIN, RFMOD_CHANNEL_MAX)])
+ config.rfmod.finetune = ConfigSlider(default=5, limits=(1, 10))
+
+ iRFmod = RFmod()
+
+ def setFunction(configElement):
+ iRFmod.setFunction(configElement.value);
+ def setTestmode(configElement):
+ iRFmod.setTestmode(configElement.value);
+ def setSoundFunction(configElement):
+ iRFmod.setSoundFunction(configElement.value);
+ def setSoundCarrier(configElement):
+ iRFmod.setSoundCarrier(configElement.index);
+ def setChannel(configElement):
+ iRFmod.setChannel(int(configElement.value));
+ def setFinetune(configElement):
+ iRFmod.setFinetune(configElement.value - 5);
+
+ # this will call the "setup-val" initial
+ config.rfmod.enable.addNotifier(setFunction);
+ config.rfmod.test.addNotifier(setTestmode);
+ config.rfmod.sound.addNotifier(setSoundFunction);
+ config.rfmod.soundcarrier.addNotifier(setSoundCarrier);
+ config.rfmod.channel.addNotifier(setChannel);
+ config.rfmod.finetune.addNotifier(setFinetune);
diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py
index 73538eaf..36d149cf 100644
--- a/lib/python/Components/UsageConfig.py
+++ b/lib/python/Components/UsageConfig.py
@@ -1,5 +1,6 @@
from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigInteger
from enigma import Misc_Options, setTunerTypePriorityOrder;
+from SystemInfo import SystemInfo
import os
def InitUsageConfig():
@@ -63,4 +64,6 @@ def InitUsageConfig():
Misc_Options.getInstance().set_12V_output(0)
config.usage.output_12V.addNotifier(set12VOutput)
+ SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output()
+
config.usage.keymap = ConfigText(default = "/usr/share/enigma2/keymap.xml")
diff --git a/lib/python/Screens/Ci.py b/lib/python/Screens/Ci.py
index d19386b2..10423ada 100644
--- a/lib/python/Screens/Ci.py
+++ b/lib/python/Screens/Ci.py
@@ -6,7 +6,9 @@ from Components.Label import Label
from Components.config import config, ConfigSubsection, ConfigSelection, ConfigSubList, getConfigListEntry, KEY_LEFT, KEY_RIGHT, KEY_0, ConfigNothing, ConfigPIN
from Components.ConfigList import ConfigList
-from enigma import eTimer, eDVBCI_UI
+from Components.SystemInfo import SystemInfo
+
+from enigma import eTimer, eDVBCI_UI, eDVBCIInterfaces
MAX_NUM_CI = 4
@@ -224,6 +226,7 @@ class CiMessageHandler:
self.ci = { }
self.dlgs = { }
eDVBCI_UI.getInstance().ciStateChanged.get().append(self.ciStateChanged)
+ SystemInfo["CommonInterface"]= eDVBCIInterfaces.getInstance().getNumOfSlots() > 0
def setSession(self, session):
self.session = session
diff --git a/lib/python/Screens/Menu.py b/lib/python/Screens/Menu.py
index 7c084d45..ce7f2ea6 100644
--- a/lib/python/Screens/Menu.py
+++ b/lib/python/Screens/Menu.py
@@ -5,6 +5,7 @@ from Components.Sources.StaticText import StaticText
from Components.config import configfile
from Components.PluginComponent import plugins
from Components.config import config
+from Components.SystemInfo import SystemInfo
from Tools.Directories import resolveFilename, SCOPE_SKIN
@@ -102,6 +103,9 @@ class Menu(Screen):
self.session.openWithCallback(self.menuClosed, Setup, dialog)
def addMenu(self, destList, node):
+ requires = node.getAttribute("requires")
+ if requires and not SystemInfo.get(requires, False):
+ return
MenuTitle = _(node.getAttribute("text").encode("UTF-8") or "??")
entryID = node.getAttribute("entryID") or "undefined"
weight = node.getAttribute("weight") or 50
@@ -122,6 +126,9 @@ class Menu(Screen):
self.close(True)
def addItem(self, destList, node):
+ requires = node.getAttribute("requires")
+ if requires and not SystemInfo.get(requires, False):
+ return
item_text = node.getAttribute("text").encode("UTF-8")
entryID = node.getAttribute("entryID") or "undefined"
weight = node.getAttribute("weight") or 50
@@ -173,6 +180,7 @@ class Menu(Screen):
continue
elif x.tagName == 'item':
item_level = int(x.getAttribute("level") or "0")
+
if item_level <= config.usage.setup_level.index:
self.addItem(list, x)
count += 1
diff --git a/lib/python/Screens/Setup.py b/lib/python/Screens/Setup.py
index f7b4fa58..f352e8cb 100644
--- a/lib/python/Screens/Setup.py
+++ b/lib/python/Screens/Setup.py
@@ -1,6 +1,7 @@
from Screen import Screen
from Components.ActionMap import NumberActionMap
from Components.config import config, ConfigNothing
+from Components.SystemInfo import SystemInfo
from Components.ConfigList import ConfigListScreen
from Components.Label import Label
from Components.Pixmap import Pixmap
@@ -133,6 +134,10 @@ class Setup(ConfigListScreen, Screen):
if item_level > config.usage.setup_level.index:
continue
+ requires = x.getAttribute("requires")
+ if requires and not SystemInfo.get(requires, False):
+ continue;
+
item_text = _(x.getAttribute("text").encode("UTF-8") or "??")
b = eval(XMLTools.mergeText(x.childNodes));
if b == "":