-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67326df
commit 05a85ed
Showing
7 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |