From 05a85edfb1d84cbb3d725ae80673f49893405a7e Mon Sep 17 00:00:00 2001 From: teamblue-e2 Date: Tue, 4 Jun 2024 16:08:29 +0200 Subject: [PATCH] [SoftcamSetup] use openpli version --- configure.ac | 1 - data/menu.xml | 1 + lib/python/Components/SystemInfo.py | 6 +- lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- lib/python/Screens/Makefile.am | 2 +- lib/python/Screens/SoftcamSetup.py | 130 +++++++++++++++++++ lib/python/Tools/camcontrol.py | 54 ++++++++ 7 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 lib/python/Screens/SoftcamSetup.py create mode 100644 lib/python/Tools/camcontrol.py diff --git a/configure.ac b/configure.ac index f4e3365999..29041c4b3e 100644 --- a/configure.ac +++ b/configure.ac @@ -492,7 +492,6 @@ lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/Makefile lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/meta/Makefile lib/python/Plugins/SystemPlugins/Satfinder/Makefile lib/python/Plugins/SystemPlugins/Satfinder/meta/Makefile -lib/python/Plugins/SystemPlugins/SoftcamStartup/Makefile lib/python/Plugins/SystemPlugins/SoftwareManager/Makefile lib/python/Plugins/SystemPlugins/SoftwareManager/meta/Makefile lib/python/Plugins/SystemPlugins/SwapManager/Makefile diff --git a/data/menu.xml b/data/menu.xml index e0b3f88d89..a46947236b 100644 --- a/data/menu.xml +++ b/data/menu.xml @@ -68,6 +68,7 @@ + diff --git a/lib/python/Components/SystemInfo.py b/lib/python/Components/SystemInfo.py index 6fb551f4ca..f0fd57d63f 100644 --- a/lib/python/Components/SystemInfo.py +++ b/lib/python/Components/SystemInfo.py @@ -128,6 +128,10 @@ def countFrontpanelLEDs(): return numLeds +def hassoftcaminstalled(): + from Tools.camcontrol import CamControl + return len(CamControl("softcam").getList()) > 1 + def getHasTuners(): if fileExists("/proc/bus/nim_sockets"): nimfile = open("/proc/bus/nim_sockets") @@ -158,7 +162,7 @@ def setBoxInfoItems(): for cislot in range(0, BoxInfo.getItem("CommonInterface")): BoxInfo.setItem("CI%dSupportsHighBitrates" % cislot, fileCheck("/proc/stb/tsmux/ci%d_tsclk" % cislot)) BoxInfo.setItem("CI%dRelevantPidsRoutingSupport" % cislot, fileCheck("/proc/stb/tsmux/ci%d_relevant_pids_routing" % cislot)) - + BoxInfo.setItem("HasSoftcamInstalled", hassoftcaminstalled()) BoxInfo.setItem("NumVideoDecoders", getNumVideoDecoders()) BoxInfo.setItem("PIPAvailable", BoxInfo.getItem("NumVideoDecoders") > 1) BoxInfo.setItem("CanMeasureFrontendInputPower", eDVBResourceManager.getInstance().canMeasureFrontendInputPower()) diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am index ff8d317711..d3c0372464 100644 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = SoftwareManager PositionerSetup Satfinder \ DefaultServicesScanner DiseqcTester CommonInterfaceAssignment GBAspectRatioSwitch \ CableScan FastScan OSDPositionSetup OSD3DSetup HdmiCEC VideoClippingSetup \ VideoEnhancement WirelessLan NetworkWizard DeviceManager FastChannelChange \ - SwapManager SoftcamStartup + SwapManager install_PYTHON = \ __init__.py diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index 398674d9c7..6014af362b 100644 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -16,4 +16,4 @@ install_PYTHON = \ SessionGlobals.py LocationBox.py WizardLanguage.py TaskView.py Rc.py VirtualKeyBoard.py \ TextBox.py FactoryReset.py RecordPaths.py UnhandledKey.py ServiceStopScreen.py \ InputDeviceSetup.py DVD.py SoftwareUpdate.py AutoDiseqc.py InstallWizard.py ScreenSaver.py \ - Hotkey.py StreamingClientsInfo.py SetupFallbacktuner.py FlashImage.py + Hotkey.py StreamingClientsInfo.py SetupFallbacktuner.py FlashImage.py SoftcamSetup.py diff --git a/lib/python/Screens/SoftcamSetup.py b/lib/python/Screens/SoftcamSetup.py new file mode 100644 index 0000000000..b54423e9d1 --- /dev/null +++ b/lib/python/Screens/SoftcamSetup.py @@ -0,0 +1,130 @@ +from Screens.Setup import Setup +from Screens.MessageBox import MessageBox +from Components.ConfigList import ConfigListScreen +from Components.ActionMap import ActionMap +from Components.config import ConfigSelection, ConfigAction +from Components.ScrollLabel import ScrollLabel +from Tools.Directories import resolveFilename, SCOPE_PLUGINS +from Tools.GetEcmInfo import GetEcmInfo +from Components.Sources.StaticText import StaticText + +import os +from Tools.camcontrol import CamControl +from enigma import eTimer + + +class SoftcamSetup(Setup): + def __init__(self, session): + Setup.__init__(self, session, blue_button={'function': self.key_blue, 'helptext': _("Show softcam information")}) + self.setTitle(_("Softcam setup")) + self.softcam = CamControl('softcam') + self.cardserver = CamControl('cardserver') + + self.ecminfo = GetEcmInfo() + (newEcmFound, ecmInfo) = self.ecminfo.getEcm() + self["info"] = ScrollLabel("".join(ecmInfo)) + self.EcmInfoPollTimer = eTimer() + self.EcmInfoPollTimer.callback.append(self.setEcmInfo) + self.EcmInfoPollTimer.start(1000) + + softcams = self.softcam.getList() + cardservers = self.cardserver.getList() + + self.softcams = ConfigSelection(choices=softcams) + self.softcams.value = self.softcam.current() + + self.softcams_text = _("Select Softcam") + self.list.append((self.softcams_text, self.softcams)) + if cardservers: + self.cardservers = ConfigSelection(choices=cardservers) + self.cardservers.value = self.cardserver.current() + self.list.append((_("Select Card Server"), self.cardservers)) + + self.list.append((_("Restart softcam"), ConfigAction(self.restart, "s"))) + if cardservers: + self.list.append((_("Restart cardserver"), ConfigAction(self.restart, "c"))) + self.list.append((_("Restart both"), ConfigAction(self.restart, "sc"))) + self.blueButton() + + def changedEntry(self): + if self["config"].getCurrent()[0] == self.softcams_text: + self.blueButton() + + def blueButton(self): + if self.softcams.value and self.softcams.value.lower() != "none": + self["key_blue"].setText(_("Info")) + else: + self["key_blue"].setText("") + + def setEcmInfo(self): + (newEcmFound, ecmInfo) = self.ecminfo.getEcm() + if newEcmFound: + self["info"].setText("".join(ecmInfo)) + + def key_blue(self): + ppanelFileName = '/etc/ppanels/' + self.softcams.value + '.xml' + if "oscam" in self.softcams.value.lower() and os.path.isfile(resolveFilename(SCOPE_PLUGINS, 'Extensions/OscamStatus/plugin.pyc')): + from Plugins.Extensions.OscamStatus.plugin import OscamStatus + self.session.open(OscamStatus) + elif "cccam" in self.softcams.value.lower() and os.path.isfile(resolveFilename(SCOPE_PLUGINS, 'Extensions/CCcamInfo/plugin.pyc')): + from Plugins.Extensions.CCcamInfo.plugin import CCcamInfoMain + self.session.open(CCcamInfoMain) + elif os.path.isfile(ppanelFileName) and os.path.isfile(resolveFilename(SCOPE_PLUGINS, 'Extensions/PPanel/plugin.pyc')): + from Plugins.Extensions.PPanel.ppanel import PPanel + self.session.open(PPanel, name=self.softcams.value + ' PPanel', node=None, filename=ppanelFileName, deletenode=None) + else: + return 0 + + def restart(self, what): + self.what = what + if "s" in what: + if "c" in what: + msg = _("Please wait, restarting softcam and cardserver.") + else: + msg = _("Please wait, restarting softcam.") + elif "c" in what: + msg = _("Please wait, restarting cardserver.") + self.mbox = self.session.open(MessageBox, msg, MessageBox.TYPE_INFO) + self.activityTimer = eTimer() + self.activityTimer.timeout.get().append(self.doStop) + self.activityTimer.start(100, False) + + def doStop(self): + self.activityTimer.stop() + if "c" in self.what: + self.cardserver.command('stop') + if "s" in self.what: + self.softcam.command('stop') + self.oldref = self.session.nav.getCurrentlyPlayingServiceOrGroup() + self.session.nav.stopService() + self.activityTimer = eTimer() + self.activityTimer.timeout.get().append(self.doStart) + self.activityTimer.start(1000, False) + + def doStart(self): + self.activityTimer.stop() + del self.activityTimer + if "c" in self.what: + self.cardserver.select(self.cardservers.value) + self.cardserver.command('start') + if "s" in self.what: + self.softcam.select(self.softcams.value) + self.softcam.command('start') + if self.mbox: + self.mbox.close() + self.close() + self.session.nav.playService(self.oldref, adjust=False) + + def saveAll(self): + what = '' + if hasattr(self, 'cardservers') and (self.cardservers.value != self.cardserver.current()): + what = 'sc' + elif self.softcams.value != self.softcam.current(): + what = 's' + if what: + self.restart(what) + else: + self.close() + + def cancel(self): + self.close() diff --git a/lib/python/Tools/camcontrol.py b/lib/python/Tools/camcontrol.py new file mode 100644 index 0000000000..706d3953c8 --- /dev/null +++ b/lib/python/Tools/camcontrol.py @@ -0,0 +1,54 @@ +import os +import enigma + + +class CamControl: + '''CAM convention is that a softlink named /etc/init.c/softcam.* points + to the start/stop script.''' + + def __init__(self, name): + self.name = name + self.link = '/etc/init.d/' + name + if not os.path.exists(self.link): + print("[CamControl] No softcam link?", self.link) + + def getList(self): + result = [] + prefix = self.name + '.' + for f in os.listdir("/etc/init.d"): + if f.startswith(prefix): + result.append(f[len(prefix):]) + return result + + def current(self): + try: + l = os.readlink(self.link) + prefix = self.name + '.' + return os.path.split(l)[1].split(prefix, 2)[1] + except: + pass + return None + + def command(self, cmd): + if os.path.exists(self.link): + print("Executing", self.link + ' ' + cmd) + enigma.eConsoleAppContainer().execute(self.link + ' ' + cmd) + + def select(self, which): + print("Selecting CAM:", which) + if not which: + which = "None" + dst = self.name + '.' + which + if not os.path.exists('/etc/init.d/' + dst): + print("[CamControl] init script does not exist:", dst) + return + try: + os.unlink(self.link) + except: + pass + try: + os.symlink(dst, self.link) + except: + print("Failed to create symlink for softcam:", dst) + import sys + print(sys.exc_info()[:2])