import sha
from time import time
+rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?']
def bin2long(s):
return reduce( lambda x,y:(x<<8L)+y, map(ord, s))
def checkNetworkCB(self,data):
if data is not None:
if data <= 2:
- SoftwareTools.NetworkConnectionAvailable = True
+ self.NetworkConnectionAvailable = True
self.getUpdates()
else:
- SoftwareTools.NetworkConnectionAvailable = False
+ self.NetworkConnectionAvailable = False
self.getUpdates()
def getUpdates(self, callback = None):
- if SoftwareTools.lastDownloadDate is None:
+ if self.lastDownloadDate is None:
if self.hardware_info.device_name != "dm7025":
- rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?']
etpm = eTPM()
l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT)
if l2cert is None:
return
l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT)
if l3cert is None:
- print "please run the genuine dreambox plugin"
return
l3key = validate_cert(l3cert, l2key)
if l3key is None:
val = etpm.challenge(rnd)
result = decrypt_block(val, l3key)
if self.hardware_info.device_name == "dm7025" or result[80:88] == rnd:
- if SoftwareTools.NetworkConnectionAvailable == True:
- SoftwareTools.lastDownloadDate = time()
- if SoftwareTools.list_updating is False and callback is None:
- SoftwareTools.list_updating = True
+ if self.NetworkConnectionAvailable == True:
+ self.lastDownloadDate = time()
+ if self.list_updating is False and callback is None:
+ self.list_updating = True
self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
- elif SoftwareTools.list_updating is False and callback is not None:
- SoftwareTools.list_updating = True
+ elif self.list_updating is False and callback is not None:
+ self.list_updating = True
self.NotifierCallback = callback
self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
- elif SoftwareTools.list_updating is True and callback is not None:
+ elif self.list_updating is True and callback is not None:
self.NotifierCallback = callback
else:
- SoftwareTools.list_updating = False
+ self.list_updating = False
if callback is not None:
callback(False)
elif self.NotifierCallback is not None:
self.NotifierCallback(False)
else:
- SoftwareTools.NetworkConnectionAvailable = False
- SoftwareTools.list_updating = False
+ self.NetworkConnectionAvailable = False
+ self.list_updating = False
if callback is not None:
callback(False)
elif self.NotifierCallback is not None:
self.NotifierCallback(False)
else:
- if SoftwareTools.NetworkConnectionAvailable == True:
- SoftwareTools.lastDownloadDate = time()
- if SoftwareTools.list_updating is False and callback is None:
- SoftwareTools.list_updating = True
+ if self.NetworkConnectionAvailable == True:
+ self.lastDownloadDate = time()
+ if self.list_updating is False and callback is None:
+ self.list_updating = True
self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
- elif SoftwareTools.list_updating is False and callback is not None:
- SoftwareTools.list_updating = True
+ elif self.list_updating is False and callback is not None:
+ self.list_updating = True
self.NotifierCallback = callback
self.ipkg.startCmd(IpkgComponent.CMD_UPDATE)
- elif SoftwareTools.list_updating is True and callback is not None:
+ elif self.list_updating is True and callback is not None:
self.NotifierCallback = callback
else:
- SoftwareTools.list_updating = False
- if callback is not None:
- callback(False)
- elif self.NotifierCallback is not None:
- self.NotifierCallback(False)
+ if self.list_updating and callback is not None:
+ if self.hardware_info.device_name != "dm7025":
+ etpm = eTPM()
+ l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT)
+ if l2cert is None:
+ return
+ l2key = validate_cert(l2cert, rootkey)
+ if l2key is None:
+ return
+ l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT)
+ if l3cert is None:
+ return
+ l3key = validate_cert(l3cert, l2key)
+ if l3key is None:
+ return
+ rnd = read_random()
+ if rnd is None:
+ return
+ val = etpm.challenge(rnd)
+ result = decrypt_block(val, l3key)
+ if self.hardware_info.device_name == "dm7025" or result[80:88] == rnd:
+ self.NotifierCallback = callback
+ self.startIpkgListAvailable()
+ else:
+ self.list_updating = False
+ if callback is not None:
+ callback(False)
+ elif self.NotifierCallback is not None:
+ self.NotifierCallback(False)
def ipkgCallback(self, event, param):
if event == IpkgComponent.EVENT_ERROR:
- SoftwareTools.list_updating = False
+ self.list_updating = False
if self.NotifierCallback is not None:
self.NotifierCallback(False)
elif event == IpkgComponent.EVENT_DONE:
- if SoftwareTools.list_updating:
+ if self.list_updating:
self.startIpkgListAvailable()
#print event, "-", param
pass
def startIpkgListAvailable(self, callback = None):
if callback is not None:
- SoftwareTools.list_updating = True
- if SoftwareTools.list_updating:
+ self.list_updating = True
+ if self.list_updating:
if not self.UpdateConsole:
self.UpdateConsole = Console()
cmd = "ipkg list"
def IpkgListAvailableCB(self, result, retval, extra_args = None):
(callback) = extra_args
if result:
- if SoftwareTools.list_updating:
- SoftwareTools.available_packetlist = []
+ if self.list_updating:
+ self.available_packetlist = []
for x in result.splitlines():
tokens = x.split(' - ')
name = tokens[0].strip()
l = len(tokens)
version = l > 1 and tokens[1].strip() or ""
descr = l > 2 and tokens[2].strip() or ""
- SoftwareTools.available_packetlist.append([name, version, descr])
+ self.available_packetlist.append([name, version, descr])
if callback is None:
self.startInstallMetaPackage()
else:
if len(self.UpdateConsole.appContainers) == 0:
callback(True)
else:
- SoftwareTools.list_updating = False
+ self.list_updating = False
if self.UpdateConsole:
if len(self.UpdateConsole.appContainers) == 0:
if callback is not None:
def startInstallMetaPackage(self, callback = None):
if callback is not None:
- SoftwareTools.list_updating = True
- if SoftwareTools.list_updating:
- if not self.UpdateConsole:
- self.UpdateConsole = Console()
- cmd = "ipkg install enigma2-meta enigma2-plugins-meta enigma2-skins-meta"
- self.UpdateConsole.ePopen(cmd, self.InstallMetaPackageCB, callback)
+ self.list_updating = True
+ if self.list_updating:
+ if self.NetworkConnectionAvailable == True:
+ if not self.UpdateConsole:
+ self.UpdateConsole = Console()
+ cmd = "ipkg install enigma2-meta enigma2-plugins-meta enigma2-skins-meta"
+ self.UpdateConsole.ePopen(cmd, self.InstallMetaPackageCB, callback)
+ else:
+ self.InstallMetaPackageCB(True)
- def InstallMetaPackageCB(self, result, retval, extra_args = None):
+ def InstallMetaPackageCB(self, result, retval = None, extra_args = None):
(callback) = extra_args
if result:
self.fillPackagesIndexList()
if len(self.UpdateConsole.appContainers) == 0:
callback(True)
else:
- SoftwareTools.list_updating = False
+ self.list_updating = False
if self.UpdateConsole:
if len(self.UpdateConsole.appContainers) == 0:
if callback is not None:
callback(False)
def startIpkgListInstalled(self, callback = None):
+ print "STARTIPKGLISTINSTALLED"
if callback is not None:
- SoftwareTools.list_updating = True
- if SoftwareTools.list_updating:
+ self.list_updating = True
+ if self.list_updating:
if not self.UpdateConsole:
self.UpdateConsole = Console()
cmd = "ipkg list_installed"
def IpkgListInstalledCB(self, result, retval, extra_args = None):
(callback) = extra_args
if result:
- SoftwareTools.installed_packetlist = {}
+ self.installed_packetlist = {}
for x in result.splitlines():
tokens = x.split(' - ')
name = tokens[0].strip()
if not any(name.endswith(x) for x in self.unwanted_extensions):
l = len(tokens)
version = l > 1 and tokens[1].strip() or ""
- SoftwareTools.installed_packetlist[name] = version
+ self.installed_packetlist[name] = version
for package in self.packagesIndexlist[:]:
if not self.verifyPrerequisites(package[0]["prerequisites"]):
self.packagesIndexlist.remove(package)
if len(self.UpdateConsole.appContainers) == 0:
callback(True)
else:
- SoftwareTools.list_updating = False
+ self.list_updating = False
if self.UpdateConsole:
if len(self.UpdateConsole.appContainers) == 0:
if callback is not None:
callback(False)
def countUpdates(self, callback = None):
- SoftwareTools.available_updates = 0
- SoftwareTools.available_updatelist = []
+ self.available_updates = 0
+ self.available_updatelist = []
for package in self.packagesIndexlist[:]:
attributes = package[0]["attributes"]
packagename = attributes["packagename"]
- for x in SoftwareTools.available_packetlist:
+ for x in self.available_packetlist:
if x[0] == packagename:
- if SoftwareTools.installed_packetlist.has_key(packagename):
- if SoftwareTools.installed_packetlist[packagename] != x[1]:
- SoftwareTools.available_updates +=1
- SoftwareTools.available_updatelist.append([packagename])
+ if self.installed_packetlist.has_key(packagename):
+ if self.installed_packetlist[packagename] != x[1]:
+ self.available_updates +=1
+ self.available_updatelist.append([packagename])
- SoftwareTools.list_updating = False
+ self.list_updating = False
if self.UpdateConsole:
if len(self.UpdateConsole.appContainers) == 0:
if callback is not None:
statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png"))
self.statuslist.append(( _("Package list update"), '', _("Searching for new installed or removed packages. Please wait..." ),'', '', statuspng, divpng, None, '' ))
elif status == 'error':
+ self["key_green"].setText(_("Continue"))
statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png"))
self.statuslist.append(( _("Error"), '', _("There was an error downloading the packetlist. Please try again." ),'', '', statuspng, divpng, None, '' ))
self["list"].style = "default"
def getUpdateInfos(self):
- self.setState('update')
- iSoftwareTools.startSoftwareTools(self.getUpdateInfosCB)
+ if (iSoftwareTools.lastDownloadDate is not None and iSoftwareTools.NetworkConnectionAvailable is False):
+ self.rebuildList()
+ else:
+ self.setState('update')
+ iSoftwareTools.startSoftwareTools(self.getUpdateInfosCB)
def getUpdateInfosCB(self, retval = None):
if retval is not None:
self["status"].setText(_("There are no updates available."))
self.rebuildList()
elif retval is False:
- self.setState('error')
- if iSoftwareTools.NetworkConnectionAvailable:
- self["status"].setText(_("Updatefeed not available."))
+ if iSoftwareTools.lastDownloadDate is None:
+ self.setState('error')
+ if iSoftwareTools.NetworkConnectionAvailable:
+ self["status"].setText(_("Updatefeed not available."))
+ else:
+ self["status"].setText(_("No network connection available."))
else:
- self["status"].setText(_("No network connection available."))
+ iSoftwareTools.lastDownloadDate = time()
+ iSoftwareTools.list_updating = True
+ self.setState('update')
+ iSoftwareTools.getUpdates(self.getUpdateInfosCB)
def rebuildList(self, retval = None):
if self.currentSelectedTag is None:
self["key_green"].setText(_("Uninstall"))
elif current[4] == 'installable':
self["key_green"].setText(_("Install"))
+ if iSoftwareTools.NetworkConnectionAvailable is False:
+ self["key_green"].setText("")
elif current[4] == 'remove':
self["key_green"].setText(_("Undo uninstall"))
elif current[4] == 'install':
self["key_green"].setText(_("Undo install"))
+ if iSoftwareTools.NetworkConnectionAvailable is False:
+ self["key_green"].setText("")
self["key_yellow"].setText(_("View details"))
self["key_blue"].setText("")
if len(self.selectedFiles) == 0 and iSoftwareTools.available_updates is not 0:
if entry[0] == detailsFile:
alreadyinList = True
if not alreadyinList:
- self.selectedFiles.append((detailsFile,current[4],current[3]))
- self.currentSelectedPackage = ((detailsFile,current[4],current[3]))
+ if (iSoftwareTools.NetworkConnectionAvailable is False and current[4] in ('installable','install')):
+ pass
+ else:
+ self.selectedFiles.append((detailsFile,current[4],current[3]))
+ self.currentSelectedPackage = ((detailsFile,current[4],current[3]))
if current[4] == 'installed':
self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'remove', True)
elif current[4] == 'installable':
- self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'install', True)
+ if iSoftwareTools.NetworkConnectionAvailable:
+ self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'install', True)
elif current[4] == 'remove':
self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'installed', False)
elif current[4] == 'install':
- self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'installable',False)
+ if iSoftwareTools.NetworkConnectionAvailable:
+ self.list[idx] = self.buildEntryComponent(current[0], current[1], current[2], current[3], 'installable',False)
self["list"].setList(self.list)
self["list"].setIndex(idx)
self["list"].updateList(self.list)
self.selectionChanged()
-
+ elif self.currList == "status":
+ iSoftwareTools.lastDownloadDate = time()
+ iSoftwareTools.list_updating = True
+ self.setState('update')
+ iSoftwareTools.getUpdates(self.getUpdateInfosCB)
+
def handleSelected(self):
current = self["list"].getCurrent()
if current:
self["author"].setText(_("Author: ") + self.author)
self["detailtext"].setText(_(self.description))
if self.pluginstate in ('installable', 'install'):
- self["key_green"].setText(_("Install"))
+ if iSoftwareTools.NetworkConnectionAvailable:
+ self["key_green"].setText(_("Install"))
+ else:
+ self["key_green"].setText("")
else:
self["key_green"].setText(_("Remove"))
if thumbnailUrl is not None:
self.thumbnail = "/tmp/" + thumbnailUrl.split('/')[-1]
print "[PluginDetails] downloading screenshot " + thumbnailUrl + " to " + self.thumbnail
- client.downloadPage(thumbnailUrl,self.thumbnail).addCallback(self.setThumbnail).addErrback(self.fetchFailed)
+ if iSoftwareTools.NetworkConnectionAvailable:
+ client.downloadPage(thumbnailUrl,self.thumbnail).addCallback(self.setThumbnail).addErrback(self.fetchFailed)
+ else:
+ self.setThumbnail(noScreenshot = True)
else:
self.setThumbnail(noScreenshot = True)
if len(self.cmdList):
self.session.openWithCallback(self.runRemove, MessageBox, _("Do you want to remove the package:\n") + self.pluginname + "\n" + self.oktext)
else:
- if self.packagefiles:
- for package in self.packagefiles[:]:
- self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package["name"] }))
- if len(self.cmdList):
- self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to install the package:\n") + self.pluginname + "\n" + self.oktext)
+ if iSoftwareTools.NetworkConnectionAvailable:
+ if self.packagefiles:
+ for package in self.packagefiles[:]:
+ self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package["name"] }))
+ if len(self.cmdList):
+ self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to install the package:\n") + self.pluginname + "\n" + self.oktext)
def runUpgrade(self, result):
if result:
<widget name="activityslider" position="0,0" size="550,5" />
<widget name="slider" position="0,150" size="550,30" />
<widget source="package" render="Label" position="10,30" size="540,20" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
- <widget source="status" render="Label" position="10,60" size="540,45" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
+ <widget source="status" render="Label" position="10,180" size="540,100" font="Regular;20" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
</screen>"""
def __init__(self, session, args = None):
self.activityTimer.stop()
self.activityslider.setValue(0)
- self.package.setText("")
- self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages + "\n\n" + self.oktext)
+ self.package.setText(_("Done - Installed or upgraded %d packages") % self.packages)
+ self.status.setText(self.oktext)
else:
self.activityTimer.stop()
self.activityslider.setValue(0)