Skip to content

Commit

Permalink
[SoftcamSetup] use openpli version
Browse files Browse the repository at this point in the history
  • Loading branch information
teamblue-e2 committed Jun 4, 2024
1 parent 67326df commit 05a85ed
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 4 deletions.
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions data/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

<!-- Menu / Settings / CAM/CI Menu -->
<menu key="cam" weight="30" level="1" text="CAM/CI">
<item key="softcam_setup" weight="10" level="0" text="Softcam Setup" requires="HasSoftcamInstalled"><screen module="SoftcamSetup" screen="SoftcamSetup"/></item>
<item key="ci_setup" weight="0" level="1" text="CI" requires="CommonInterface"><screen module="Ci" screen="CiSelection" /></item>
<!-- <item key="ci_setup" weight="5" level="1" text="CI PIN" requires="CommonInterface"><screen module="Ci" screen="CiDefaultPinSetup" /></item> -->
</menu>
Expand Down
6 changes: 5 additions & 1 deletion lib/python/Components/SystemInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion lib/python/Plugins/SystemPlugins/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/python/Screens/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
130 changes: 130 additions & 0 deletions lib/python/Screens/SoftcamSetup.py
Original file line number Diff line number Diff line change
@@ -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()
54 changes: 54 additions & 0 deletions lib/python/Tools/camcontrol.py
Original file line number Diff line number Diff line change
@@ -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])

0 comments on commit 05a85ed

Please sign in to comment.