From e5953c16c3ff3664f0f7a763f242a3eb69fed19d Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 2 Nov 2009 16:02:59 +0100 Subject: Revert "disable m2ts support for release 2.6" This reverts commit bce2a7b606d6fdfdcac86c7ccc1c02f147dc26c9. --- lib/python/Plugins/Extensions/MediaPlayer/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 0e3bdf02..596f2d5a 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -110,7 +110,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB # 'None' is magic to start at the list of mountpoints defaultDir = config.mediaplayer.defaultDir.getValue() - self.filelist = FileList(defaultDir, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|mkv|mp4|m4a|dat|flac|mov)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") + self.filelist = FileList(defaultDir, matchingPattern = "(?i)^.*\.(mp2|mp3|ogg|ts|m2ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|divx|mkv|mp4|m4a|dat|flac|mov)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls") self["filelist"] = self.filelist self.playlist = MyPlayList() -- cgit v1.2.3 From e6a3b9fdb8f5ac0774a27794b175d79cf0973976 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 4 Nov 2009 12:59:17 +0100 Subject: DVDBurn fix capacity report for full dual layer media in Media Toolbox --- .../Plugins/Extensions/DVDBurn/DVDToolbox.py | 42 ++++++++++++++-------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py index feb39a95..53287a36 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py @@ -82,7 +82,9 @@ class DVDToolbox(Screen): self.update() def mediainfoCB(self, mediuminfo, retval, extra_args): - capacity = 1 + formatted_capacity = 0 + read_capacity = 0 + capacity = 0 used = 0 infotext = "" mediatype = "" @@ -93,21 +95,17 @@ class DVDToolbox(Screen): self.formattable = True else: self.formattable = False - if line.find("Legacy lead-out at:") > -1: + elif line.find("Legacy lead-out at:") > -1: used = int(line.rsplit('=',1)[1]) / 1048576.0 - print "[lead out] used =", used + print "[dvd+rw-mediainfo] lead out used =", used elif line.find("formatted:") > -1: - capacity = int(line.rsplit('=',1)[1]) / 1048576.0 - print "[formatted] capacity =", capacity - elif capacity == 1 and line.find("READ CAPACITY:") > -1: - capacity = int(line.rsplit('=',1)[1]) / 1048576.0 - print "[READ CAP] capacity =", capacity - elif line.find("Disc status:") > -1: - if line.find("blank") > -1: - print "[Disc status] capacity=%d, used=0" % (capacity) - capacity = used - used = 0 - elif line.find("Free Blocks:") > -1: + formatted_capacity = int(line.rsplit('=',1)[1]) / 1048576.0 + print "[dvd+rw-mediainfo] formatted capacity =", formatted_capacity + elif formatted_capacity == 0 and line.find("READ CAPACITY:") > -1: + read_capacity = int(line.rsplit('=',1)[1]) / 1048576.0 + print "[dvd+rw-mediainfo] READ CAPACITY =", read_capacity + for line in mediuminfo.splitlines(): + if line.find("Free Blocks:") > -1: try: size = eval(line[14:].replace("KB","*1024")) except: @@ -116,8 +114,22 @@ class DVDToolbox(Screen): capacity = size / 1048576 if used: used = capacity-used - print "[free blocks] capacity=%d, used=%d" % (capacity, used) + print "[dvd+rw-mediainfo] free blocks capacity=%d, used=%d" % (capacity, used) + elif line.find("Disc status:") > -1: + if line.find("blank") > -1: + print "[dvd+rw-mediainfo] Disc status blank capacity=%d, used=0" % (capacity) + capacity = used + used = 0 + elif line.find("complete") > -1 and formatted_capacity == 0: + print "[dvd+rw-mediainfo] Disc status complete capacity=0, used=%d" % (capacity) + used = read_capacity + capacity = 1 + else: + capacity = formatted_capacity infotext += line+'\n' + if capacity and used > capacity: + used = read_capacity or capacity + capacity = formatted_capacity or capacity self["details"].setText(infotext) if self.formattable: self["key_yellow"].text = _("Format") -- cgit v1.2.3 From 37e3c1814cc8ea6ef4eaef9a4bbc5d757d98972f Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 6 Nov 2009 11:44:06 +0100 Subject: Revert "disable fast winding for non TS mediafiles until we have a usable solution for this.." This reverts commit b643641e2c6288eff61d0346a3dda82bd820b3b7. --- .../Extensions/DVDPlayer/src/servicedvd.cpp | 2 +- lib/python/Screens/InfoBarGenerics.py | 14 ------------ lib/service/servicedvb.cpp | 2 +- lib/service/servicemp3.cpp | 26 +--------------------- lib/service/servicexine.cpp | 2 +- 5 files changed, 4 insertions(+), 42 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index 0372c497..94f2ee38 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -696,7 +696,7 @@ RESULT eServiceDVD::setTrickmode(int /*trick*/) RESULT eServiceDVD::isCurrentlySeekable() { - return m_state == stRunning ? 3 : 0; + return m_state == stRunning; } RESULT eServiceDVD::keyPressed(int key) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 9a6a099c..b98cd469 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -691,7 +691,6 @@ class InfoBarSeek: iPlayableService.evEOF: self.__evEOF, iPlayableService.evSOF: self.__evSOF, }) - self.fast_winding_hint_message_showed = False class InfoBarSeekActionMap(HelpableActionMap): def __init__(self, screen, *args, **kwargs): @@ -818,7 +817,6 @@ class InfoBarSeek: # print "seekable" def __serviceStarted(self): - self.fast_winding_hint_message_showed = False self.seekstate = self.SEEK_STATE_PLAY self.__seekableStatusChanged() @@ -909,12 +907,6 @@ class InfoBarSeek: self.showAfterSeek() def seekFwd(self): - seek = self.getSeek() - if seek and (seek.isCurrentlySeekable() & 1) and not (seek.isCurrentlySeekable() & 2): - if not self.fast_winding_hint_message_showed: - self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10) - self.fast_winding_hint_message_showed = True - return if self.seekstate == self.SEEK_STATE_PLAY: self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value))) elif self.seekstate == self.SEEK_STATE_PAUSE: @@ -944,12 +936,6 @@ class InfoBarSeek: self.setSeekState(self.makeStateSlowMotion(speed)) def seekBack(self): - seek = self.getSeek() - if seek and (seek.isCurrentlySeekable() & 1) and not (seek.isCurrentlySeekable() & 2): - if not self.fast_winding_hint_message_showed: - self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10) - self.fast_winding_hint_message_showed = True - return seekstate = self.seekstate if seekstate == self.SEEK_STATE_PLAY: self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value))) diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index ddc675e6..1a28fbdd 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -1370,7 +1370,7 @@ RESULT eDVBServicePlay::setTrickmode(int trick) RESULT eDVBServicePlay::isCurrentlySeekable() { - return m_is_pvr || m_timeshift_active ? 3 : 0; // fast forward/backward possible and seeking possible + return m_is_pvr || m_timeshift_active; } RESULT eDVBServicePlay::frontendInfo(ePtr &ptr) diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 52f2bc99..c95609a3 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -641,31 +641,7 @@ RESULT eServiceMP3::setTrickmode(int trick) RESULT eServiceMP3::isCurrentlySeekable() { - int ret = 3; // seeking and fast/slow winding possible - GstElement *sink; - - if (!m_gst_playbin) - return 0; - if (m_state != stRunning) - return 0; - - g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL); - - // disable fast winding yet when a dvbvideosink or dvbaudiosink is used - // for this we must do some changes on different places.. (gstreamer.. our sinks.. enigma2) - if (sink) { - ret &= ~2; // only seeking possible - gst_object_unref(sink); - } - else { - g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL); - if (sink) { - ret &= ~2; // only seeking possible - gst_object_unref(sink); - } - } - - return ret; + return 1; } RESULT eServiceMP3::info(ePtr&i) diff --git a/lib/service/servicexine.cpp b/lib/service/servicexine.cpp index 6b9adfb9..44e6a6e0 100644 --- a/lib/service/servicexine.cpp +++ b/lib/service/servicexine.cpp @@ -315,7 +315,7 @@ RESULT eServiceXine::setTrickmode(int trick) RESULT eServiceXine::isCurrentlySeekable() { - return 3; + return 1; } RESULT eServiceXine::info(ePtr&i) -- cgit v1.2.3 From 4e08450f3d15c875231a264dfeec4fa0bcfa8997 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Mon, 9 Nov 2009 17:38:21 +0100 Subject: WirelessLan/plugin.py: - properly escape spaces inside an SSID name when returning the ConfigString. This fixes #175 --- lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index 74520dcc..9f6a13fe 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -276,8 +276,15 @@ def configStrings(iface): return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -Dralink\n post-down wpa_cli terminate" if driver == 'madwifi': if config.plugins.wlan.essid.value == "hidden...": - return " pre-up iwconfig "+iface+" essid "+config.plugins.wlan.hiddenessid.value+"\n pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate" - return " pre-up iwconfig "+iface+" essid "+config.plugins.wlan.essid.value+"\n pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate" + if ' ' in config.plugins.wlan.hiddenessid.value: + return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' + else: + return ' pre-up iwconfig '+iface+' essid '+config.plugins.wlan.hiddenessid.value+'\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' + else: + if ' ' in config.plugins.wlan.essid.value: + return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' + else: + return ' pre-up iwconfig '+iface+' essid '+config.plugins.wlan.essid.value+'\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' if driver == 'zydas': return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -dd -Dzydas\n post-down wpa_cli terminate" -- cgit v1.2.3 From a87dcad83a4096c1d29ccdf5cda873ee43629f70 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Wed, 11 Nov 2009 18:34:04 +0100 Subject: WirelessLan/plugin.py: - always use quotes for the ssid name, small cleanup --- .../Plugins/SystemPlugins/WirelessLan/plugin.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index 9f6a13fe..b7a64b9a 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -271,22 +271,14 @@ def callFunction(iface): def configStrings(iface): driver = iNetwork.detectWlanModule() - print "WLAN-MODULE",driver - if driver == 'ralink': - return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -Dralink\n post-down wpa_cli terminate" - if driver == 'madwifi': + print "Found WLAN-Driver:",driver + if driver in ('ralink', 'zydas'): + return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -D"+driver+"\n post-down wpa_cli terminate" + else: if config.plugins.wlan.essid.value == "hidden...": - if ' ' in config.plugins.wlan.hiddenessid.value: - return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' - else: - return ' pre-up iwconfig '+iface+' essid '+config.plugins.wlan.hiddenessid.value+'\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' + return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n post-down wpa_cli terminate' else: - if ' ' in config.plugins.wlan.essid.value: - return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' - else: - return ' pre-up iwconfig '+iface+' essid '+config.plugins.wlan.essid.value+'\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -Dmadwifi\n post-down wpa_cli terminate' - if driver == 'zydas': - return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -dd -Dzydas\n post-down wpa_cli terminate" + return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n post-down wpa_cli terminate' def Plugins(**kwargs): return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."}) -- cgit v1.2.3 From b79bdb964320dabf4180ef6820a1ce335afccaa5 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 3 Dec 2009 15:23:41 +0100 Subject: Plugins/Plugin.py, InfoBarGenerics.py: add WHERE_AUDIOMENU for plugins .. requested by Tode for the AudioSync Plugin fixes bug #305 --- lib/python/Plugins/Plugin.py | 2 ++ lib/python/Screens/InfoBarGenerics.py | 47 ++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 9 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Plugin.py b/lib/python/Plugins/Plugin.py index d7fc6898..dc68ebf3 100755 --- a/lib/python/Plugins/Plugin.py +++ b/lib/python/Plugins/Plugin.py @@ -52,6 +52,8 @@ class PluginDescriptor: # reason (True: Networkconfig read finished, False: Networkconfig reload initiated ) WHERE_NETWORKCONFIG_READ = 12 + WHERE_AUDIOMENU = 13 + def __init__(self, name = "Plugin", where = [ ], description = "", icon = None, fnc = None, wakeupfnc = None, internal = False): self.name = name self.internal = internal diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index b98cd469..b672b682 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -1663,17 +1663,46 @@ class InfoBarAudioSelection: else: break + availableKeys = [] + usedKeys = [] + if SystemInfo["CanDownmixAC3"]: - tlist = [(_("AC3 downmix") + " - " +(_("Off"), _("On"))[config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix), - ((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"), - ("--", "")] + tlist - keys = [ "red", "green", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n - selection += 3 - else: - tlist = [((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist - keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n + flist = [(_("AC3 downmix") + " - " +(_("Off"), _("On"))[config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix), + ((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode")] + usedKeys.extend(["red", "green"]) + availableKeys.extend(["yellow", "blue"]) selection += 2 - self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys, skin_name = "AudioTrackSelection") + else: + flist = [((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode")] + usedKeys.extend(["red"]) + availableKeys.extend(["green", "yellow", "blue"]) + selection += 1 + + if hasattr(self, "runPlugin"): + class PluginCaller: + def __init__(self, fnc, *args): + self.fnc = fnc + self.args = args + def __call__(self, *args, **kwargs): + self.fnc(*self.args) + + Plugins = [ (p.name, PluginCaller(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_AUDIOMENU) ] + + for p in Plugins: + selection += 1 + flist.append((p[0], "CALLFUNC", p[1])) + if availableKeys: + usedKeys.append(availableKeys[0]) + del availableKeys[0] + else: + usedKeys.append("") + + flist.append(("--", "")) + usedKeys.append("") + selection += 1 + + keys = usedKeys + [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ] + [""] * n + self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = flist + tlist, selection = selection, keys = keys, skin_name = "AudioTrackSelection") else: del self.audioTracks -- cgit v1.2.3 From 15b64dc4fbead7b5c15cb309a82914f79ae78b0a Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 5 Nov 2009 11:37:29 +0100 Subject: disable fast winding for non TS mediafiles until we have a usable solution for this.. --- .../Extensions/DVDPlayer/src/servicedvd.cpp | 2 +- lib/python/Screens/InfoBarGenerics.py | 14 ++++++++++++ lib/service/servicedvb.cpp | 2 +- lib/service/servicemp3.cpp | 26 +++++++++++++++++++++- lib/service/servicexine.cpp | 2 +- 5 files changed, 42 insertions(+), 4 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index 94f2ee38..0372c497 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -696,7 +696,7 @@ RESULT eServiceDVD::setTrickmode(int /*trick*/) RESULT eServiceDVD::isCurrentlySeekable() { - return m_state == stRunning; + return m_state == stRunning ? 3 : 0; } RESULT eServiceDVD::keyPressed(int key) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index b672b682..24ebada7 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -691,6 +691,7 @@ class InfoBarSeek: iPlayableService.evEOF: self.__evEOF, iPlayableService.evSOF: self.__evSOF, }) + self.fast_winding_hint_message_showed = False class InfoBarSeekActionMap(HelpableActionMap): def __init__(self, screen, *args, **kwargs): @@ -817,6 +818,7 @@ class InfoBarSeek: # print "seekable" def __serviceStarted(self): + self.fast_winding_hint_message_showed = False self.seekstate = self.SEEK_STATE_PLAY self.__seekableStatusChanged() @@ -907,6 +909,12 @@ class InfoBarSeek: self.showAfterSeek() def seekFwd(self): + seek = self.getSeek() + if seek and (seek.isCurrentlySeekable() & 1) and not (seek.isCurrentlySeekable() & 2): + if not self.fast_winding_hint_message_showed: + self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10) + self.fast_winding_hint_message_showed = True + return if self.seekstate == self.SEEK_STATE_PLAY: self.setSeekState(self.makeStateForward(int(config.seek.enter_forward.value))) elif self.seekstate == self.SEEK_STATE_PAUSE: @@ -936,6 +944,12 @@ class InfoBarSeek: self.setSeekState(self.makeStateSlowMotion(speed)) def seekBack(self): + seek = self.getSeek() + if seek and (seek.isCurrentlySeekable() & 1) and not (seek.isCurrentlySeekable() & 2): + if not self.fast_winding_hint_message_showed: + self.session.open(MessageBox, _("No fast winding possible yet.. but you can use the number buttons to skip forward/backward!"), MessageBox.TYPE_INFO, timeout=10) + self.fast_winding_hint_message_showed = True + return seekstate = self.seekstate if seekstate == self.SEEK_STATE_PLAY: self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value))) diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index f85ce9cc..16d09bc6 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -1385,7 +1385,7 @@ RESULT eDVBServicePlay::setTrickmode(int trick) RESULT eDVBServicePlay::isCurrentlySeekable() { - return m_is_pvr || m_timeshift_active; + return m_is_pvr || m_timeshift_active ? 3 : 0; // fast forward/backward possible and seeking possible } RESULT eDVBServicePlay::frontendInfo(ePtr &ptr) diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 0f604b84..c0ae42fd 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -641,7 +641,31 @@ RESULT eServiceMP3::setTrickmode(int trick) RESULT eServiceMP3::isCurrentlySeekable() { - return 1; + int ret = 3; // seeking and fast/slow winding possible + GstElement *sink; + + if (!m_gst_playbin) + return 0; + if (m_state != stRunning) + return 0; + + g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL); + + // disable fast winding yet when a dvbvideosink or dvbaudiosink is used + // for this we must do some changes on different places.. (gstreamer.. our sinks.. enigma2) + if (sink) { + ret &= ~2; // only seeking possible + gst_object_unref(sink); + } + else { + g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL); + if (sink) { + ret &= ~2; // only seeking possible + gst_object_unref(sink); + } + } + + return ret; } RESULT eServiceMP3::info(ePtr&i) diff --git a/lib/service/servicexine.cpp b/lib/service/servicexine.cpp index 44e6a6e0..6b9adfb9 100644 --- a/lib/service/servicexine.cpp +++ b/lib/service/servicexine.cpp @@ -315,7 +315,7 @@ RESULT eServiceXine::setTrickmode(int trick) RESULT eServiceXine::isCurrentlySeekable() { - return 1; + return 3; } RESULT eServiceXine::info(ePtr&i) -- cgit v1.2.3 From 1eb03ca87ad5537ec41506a84f32c90774a66f1b Mon Sep 17 00:00:00 2001 From: acid-burn Date: Tue, 15 Dec 2009 19:33:32 +0100 Subject: fix merge conflict. --- .../Plugins/SystemPlugins/WirelessLan/plugin.py | 2000 ++++++++++++++++---- 1 file changed, 1666 insertions(+), 334 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index 6bfaec52..8aafd9a7 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -1,402 +1,1734 @@ -from enigma import eTimer +from Plugins.Plugin import PluginDescriptor +from Screens.Console import Console +from Screens.ChoiceBox import ChoiceBox +from Screens.MessageBox import MessageBox from Screens.Screen import Screen +from Screens.Ipkg import Ipkg from Components.ActionMap import ActionMap, NumberActionMap -from Components.Pixmap import Pixmap,MultiPixmap -from Components.Label import Label +from Components.Input import Input +from Components.Ipkg import IpkgComponent from Components.Sources.StaticText import StaticText -from Components.Sources.List import List +from Components.ScrollLabel import ScrollLabel +from Components.Pixmap import Pixmap from Components.MenuList import MenuList -from Components.config import config, getConfigListEntry, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection, ConfigPassword -from Components.ConfigList import ConfigListScreen -from Components.Network import Network, iNetwork +from Components.Sources.List import List +from Components.Slider import Slider +from Components.Harddisk import harddiskmanager +from Components.config import config,getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations from Components.Console import Console -from Plugins.Plugin import PluginDescriptor -from os import system, path as os_path, listdir -from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE +from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest +from Components.SelectionList import SelectionList +from Components.PluginComponent import plugins +from Components.About import about +from Components.DreamInfoHandler import DreamInfoHandler +from Components.Language import language +from Components.AVSwitch import AVSwitch +from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_PLUGIN, SCOPE_CURRENT_SKIN, SCOPE_METADIR from Tools.LoadPixmap import LoadPixmap -from Wlan import Wlan, wpaSupplicant, iStatus +from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad +from cPickle import dump, load +from os import path as os_path, system as os_system, unlink, stat, mkdir, popen, makedirs, listdir, access, rename, remove, W_OK, R_OK, F_OK +from time import time, gmtime, strftime, localtime +from stat import ST_MTIME +from datetime import date +from twisted.web import client +from twisted.internet import reactor -plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan" +from ImageWizard import ImageWizard +from BackupRestore import BackupSelection, RestoreMenu, BackupScreen, RestoreScreen, getBackupPath, getBackupFilename +#from SoftwareTools import extensions -list = [] -list.append("WEP") -list.append("WPA") -list.append("WPA2") -list.append("WPA/WPA2") +config.plugins.configurationbackup = ConfigSubsection() +config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) +config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) -weplist = [] -weplist.append("ASCII") -weplist.append("HEX") +def write_cache(cache_file, cache_data): + #Does a cPickle dump + if not os_path.isdir( os_path.dirname(cache_file) ): + try: + mkdir( os_path.dirname(cache_file) ) + except OSError: + print os_path.dirname(cache_file), 'is a file' + fd = open(cache_file, 'w') + dump(cache_data, fd, -1) + fd.close() -config.plugins.wlan = ConfigSubsection() -config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False)) -config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = "home", fixed_size = False)) +def valid_cache(cache_file, cache_ttl): + #See if the cache file exists and is still living + try: + mtime = stat(cache_file)[ST_MTIME] + except: + return 0 + curr_time = time() + if (curr_time - mtime) > cache_ttl: + return 0 + else: + return 1 -config.plugins.wlan.encryption = ConfigSubsection() -config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = False)) -config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = "WPA/WPA2" )) -config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(weplist, default = "ASCII")) -config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = "mysecurewlan", fixed_size = False)) +def load_cache(cache_file): + #Does a cPickle load + fd = open(cache_file) + cache_data = load(fd) + fd.close() + return cache_data -class WlanStatus(Screen): +class UpdatePluginMenu(Screen): skin = """ - + - - - - - - - - - - - - - - - - - - - - + + + + {"template": [ + MultiContentEntryText(pos = (2, 2), size = (290, 22), flags = RT_HALIGN_LEFT, text = 1), # index 0 is the MenuText, + ], + "fonts": [gFont("Regular", 20)], + "itemHeight": 25 + } + + + + + {"template": [ + MultiContentEntryText(pos = (2, 2), size = (240, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 2 is the Description, + ], + "fonts": [gFont("Regular", 20)], + "itemHeight": 300 + } + + """ - - def __init__(self, session, iface): + + def __init__(self, session, args = 0): Screen.__init__(self, session) - self.session = session - self.iface = iface - - self["LabelBSSID"] = StaticText(_('Accesspoint:')) - self["LabelESSID"] = StaticText(_('SSID:')) - self["LabelQuality"] = StaticText(_('Link Quality:')) - self["LabelSignal"] = StaticText(_('Signal Strength:')) - self["LabelBitrate"] = StaticText(_('Bitrate:')) - self["LabelEnc"] = StaticText(_('Encryption:')) - - self["BSSID"] = StaticText() - self["ESSID"] = StaticText() - self["quality"] = StaticText() - self["signal"] = StaticText() - self["bitrate"] = StaticText() - self["enc"] = StaticText() - - self["IFtext"] = StaticText() - self["IF"] = StaticText() - self["Statustext"] = StaticText() - self["statuspic"] = MultiPixmap() - self["statuspic"].hide() + self.skin_path = plugin_path + self.menu = args + self.list = [] + self.oktext = _("\nPress OK on your remote control to continue.") + self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) + if self.menu == 0: + self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + self.oktext, None)) + self.list.append(("install-plugins", _("Install extensions"), _("\nInstall new Extensions or Plugins to your dreambox" ) + self.oktext, None)) + self.list.append(("software-restore", _("Software restore"), _("\nRestore your Dreambox with a new firmware." ) + self.oktext, None)) + self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext, None)) + self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext, None)) + self.list.append(("ipkg-install", _("Install local extension"), _("\nScan for local packages and install them." ) + self.oktext, None)) + for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER): + if p.__call__.has_key("SoftwareSupported"): + callFnc = p.__call__["SoftwareSupported"](None) + if callFnc is not None: + if p.__call__.has_key("menuEntryName"): + menuEntryName = p.__call__["menuEntryName"](None) + else: + menuEntryName = _('Extended Software') + if p.__call__.has_key("menuEntryDescription"): + menuEntryDescription = p.__call__["menuEntryDescription"](None) + else: + menuEntryDescription = _('Extended Software Plugin') + self.list.append(('default-plugin', menuEntryName, menuEntryDescription + self.oktext, callFnc)) + if config.usage.setup_level.index >= 2: # expert+ + self.list.append(("advanced", _("Advanced Options"), _("\nAdvanced options and settings." ) + self.oktext, None)) + elif self.menu == 1: + self.list.append(("advancedrestore", _("Advanced restore"), _("\nRestore your backups by date." ) + self.oktext, None)) + self.list.append(("backuplocation", _("Choose backup location"), _("\nSelect your backup device.\nCurrent device: " ) + config.plugins.configurationbackup.backuplocation.value + self.oktext, None)) + self.list.append(("backupfiles", _("Choose backup files"), _("Select files for backup. Currently selected:\n" ) + self.backupdirs + self.oktext, None)) + if config.usage.setup_level.index >= 2: # expert+ + self.list.append(("ipkg-manager", _("Packet management"), _("\nView, install and remove available or installed packages." ) + self.oktext, None)) + self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext, None)) + for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER): + if p.__call__.has_key("AdvancedSoftwareSupported"): + callFnc = p.__call__["AdvancedSoftwareSupported"](None) + if callFnc is not None: + if p.__call__.has_key("menuEntryName"): + menuEntryName = p.__call__["menuEntryName"](None) + else: + menuEntryName = _('Advanced Software') + if p.__call__.has_key("menuEntryDescription"): + menuEntryDescription = p.__call__["menuEntryDescription"](None) + else: + menuEntryDescription = _('Advanced Software Plugin') + self.list.append(('advanced-plugin', menuEntryName, menuEntryDescription + self.oktext, callFnc)) + + self["menu"] = List(self.list) self["key_red"] = StaticText(_("Close")) - self.resetList() - self.updateStatusbar() - - self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions", "ShortcutActions"], + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], { - "ok": self.exit, - "back": self.exit, - "red": self.exit, + "ok": self.go, + "back": self.close, + "red": self.close, }, -1) - self.timer = eTimer() - self.timer.timeout.get().append(self.resetList) - self.onShown.append(lambda: self.timer.start(5000)) + self.onLayoutFinish.append(self.layoutFinished) - self.onClose.append(self.cleanup) + self.backuppath = getBackupPath() + self.backupfile = getBackupFilename() + self.fullbackupfilename = self.backuppath + "/" + self.backupfile + self.onShown.append(self.setWindowTitle) + + def layoutFinished(self): + idx = 0 + self["menu"].index = idx + + def setWindowTitle(self): + self.setTitle(_("Software manager")) - def cleanup(self): - iStatus.stopWlanConsole() + def go(self): + current = self["menu"].getCurrent() + if current: + currentEntry = current[0] + if self.menu == 0: + if (currentEntry == "software-update"): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?")+"\n"+_("\nAfter pressing OK, please wait!")) + elif (currentEntry == "software-restore"): + self.session.open(ImageWizard) + elif (currentEntry == "install-plugins"): + self.session.open(PluginManager, self.skin_path) + elif (currentEntry == "system-backup"): + self.session.openWithCallback(self.backupDone,BackupScreen, runBackup = True) + elif (currentEntry == "system-restore"): + if os_path.exists(self.fullbackupfilename): + self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore your Enigma2 backup?\nEnigma2 will restart after the restore")) + else: + self.session.open(MessageBox, _("Sorry no backups found!"), MessageBox.TYPE_INFO, timeout = 10) + elif (currentEntry == "ipkg-install"): + try: + from Plugins.Extensions.MediaScanner.plugin import main + main(self.session) + except: + self.session.open(MessageBox, _("Sorry MediaScanner is not installed!"), MessageBox.TYPE_INFO, timeout = 10) + elif (currentEntry == "default-plugin"): + self.extended = current[3] + self.extended(self.session, None) + elif (currentEntry == "advanced"): + self.session.open(UpdatePluginMenu, 1) + elif self.menu == 1: + if (currentEntry == "ipkg-manager"): + self.session.open(PacketManager, self.skin_path) + elif (currentEntry == "backuplocation"): + parts = [ (r.description, r.mountpoint, self.session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] + for x in parts: + if not access(x[1], F_OK|R_OK|W_OK) or x[1] == '/': + parts.remove(x) + for x in parts: + if x[1].startswith('/autofs/'): + parts.remove(x) + if len(parts): + self.session.openWithCallback(self.backuplocation_choosen, ChoiceBox, title = _("Please select medium to use as backup location"), list = parts) + elif (currentEntry == "backupfiles"): + self.session.openWithCallback(self.backupfiles_choosen,BackupSelection) + elif (currentEntry == "advancedrestore"): + self.session.open(RestoreMenu, self.skin_path) + elif (currentEntry == "ipkg-source"): + self.session.open(IPKGMenu, self.skin_path) + elif (currentEntry == "advanced-plugin"): + self.extended = current[3] + self.extended(self.session, None) + + def backupfiles_choosen(self, ret): + self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) + + def backuplocation_choosen(self, option): + if option is not None: + config.plugins.configurationbackup.backuplocation.value = str(option[1]) + config.plugins.configurationbackup.backuplocation.save() + config.plugins.configurationbackup.save() + config.save() + self.createBackupfolders() + + def runUpgrade(self, result): + if result: + self.session.open(UpdatePlugin, self.skin_path) + + def createBackupfolders(self): + print "Creating backup folder if not already there..." + self.backuppath = getBackupPath() + try: + if (os_path.exists(self.backuppath) == False): + makedirs(self.backuppath) + except OSError: + self.session.open(MessageBox, _("Sorry, your backup destination is not writeable.\n\nPlease choose another one."), MessageBox.TYPE_INFO, timeout = 10) + + def backupDone(self,retval = None): + if retval is True: + self.session.open(MessageBox, _("Backup done."), MessageBox.TYPE_INFO, timeout = 10) + else: + self.session.open(MessageBox, _("Backup failed."), MessageBox.TYPE_INFO, timeout = 10) + + def startRestore(self, ret = False): + if (ret == True): + self.exe = True + self.session.open(RestoreScreen, runRestore = True) + +class IPKGMenu(Screen): + skin = """ + + + + + + + """ + + def __init__(self, session, plugin_path): + Screen.__init__(self, session) + self.skin_path = plugin_path + + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Edit")) + + self.sel = [] + self.val = [] + self.entry = False + self.exe = False + self.path = "" + + self["actions"] = NumberActionMap(["SetupActions"], + { + "ok": self.KeyOk, + "cancel": self.keyCancel + }, -1) + + self["shortcuts"] = ActionMap(["ShortcutActions"], + { + "red": self.keyCancel, + "green": self.KeyOk, + }) + self.flist = [] + self["filelist"] = MenuList(self.flist) + self.fill_list() + self.onLayoutFinish.append(self.layoutFinished) + def layoutFinished(self): - self.setTitle(_("Wireless Network State")) + self.setWindowTitle() + + def setWindowTitle(self): + self.setTitle(_("Select upgrade source to edit.")) + + def fill_list(self): + self.flist = [] + self.path = '/etc/ipkg/' + if (os_path.exists(self.path) == False): + self.entry = False + return + for file in listdir(self.path): + if (file.endswith(".conf")): + if file != 'arch.conf': + self.flist.append((file)) + self.entry = True + self["filelist"].l.setList(self.flist) + + def KeyOk(self): + if (self.exe == False) and (self.entry == True): + self.sel = self["filelist"].getCurrent() + self.val = self.path + self.sel + self.session.open(IPKGSource, self.val) + + def keyCancel(self): + self.close() + + def Exit(self): + self.close() + + +class IPKGSource(Screen): + skin = """ + + + + + + + """ + + def __init__(self, session, configfile = None): + Screen.__init__(self, session) + self.session = session + self.configfile = configfile + text = "" + if self.configfile: + try: + fp = file(configfile, 'r') + sources = fp.readlines() + if sources: + text = sources[0] + fp.close() + except IOError: + pass + + desk = getDesktop(0) + x= int(desk.size().width()) + y= int(desk.size().height()) + + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Save")) + + if (y>=720): + self["text"] = Input(text, maxSize=False, type=Input.TEXT) + else: + self["text"] = Input(text, maxSize=False, visible_width = 55, type=Input.TEXT) + + self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"], + { + "ok": self.go, + "back": self.close, + "red": self.close, + "green": self.go, + "left": self.keyLeft, + "right": self.keyRight, + "home": self.keyHome, + "end": self.keyEnd, + "deleteForward": self.keyDeleteForward, + "deleteBackward": self.keyDeleteBackward, + "1": self.keyNumberGlobal, + "2": self.keyNumberGlobal, + "3": self.keyNumberGlobal, + "4": self.keyNumberGlobal, + "5": self.keyNumberGlobal, + "6": self.keyNumberGlobal, + "7": self.keyNumberGlobal, + "8": self.keyNumberGlobal, + "9": self.keyNumberGlobal, + "0": self.keyNumberGlobal + }, -1) + + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setWindowTitle() + self["text"].right() + + def setWindowTitle(self): + self.setTitle(_("Edit upgrade source url.")) + + def go(self): + text = self["text"].getText() + if text: + fp = file(self.configfile, 'w') + fp.write(text) + fp.write("\n") + fp.close() + self.close() + + def keyLeft(self): + self["text"].left() + + def keyRight(self): + self["text"].right() + + def keyHome(self): + self["text"].home() + + def keyEnd(self): + self["text"].end() + + def keyDeleteForward(self): + self["text"].delete() + + def keyDeleteBackward(self): + self["text"].deleteBackward() + + def keyNumberGlobal(self, number): + self["text"].number(number) + + +class PacketManager(Screen): + skin = """ + + + + + + + + {"template": [ + MultiContentEntryText(pos = (5, 1), size = (440, 28), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (5, 26), size = (440, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description + MultiContentEntryPixmapAlphaTest(pos = (445, 2), size = (48, 48), png = 4), # index 4 is the status pixmap + MultiContentEntryPixmapAlphaTest(pos = (5, 50), size = (510, 2), png = 5), # index 4 is the div pixmap + ], + "fonts": [gFont("Regular", 22),gFont("Regular", 14)], + "itemHeight": 52 + } + + + """ - def resetList(self): - iStatus.getDataForInterface(self.iface,self.getInfoCB) + def __init__(self, session, plugin_path, args = None): + Screen.__init__(self, session) + self.session = session + self.skin_path = plugin_path + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + { + "ok": self.go, + "back": self.exit, + "red": self.exit, + "green": self.reload, + }, -1) - def getInfoCB(self,data,status): - if data is not None: - if data is True: - if status is not None: - self["BSSID"].setText(status[self.iface]["acesspoint"]) - self["ESSID"].setText(status[self.iface]["essid"]) - self["quality"].setText(status[self.iface]["quality"]+"%") - self["signal"].setText(status[self.iface]["signal"]) - self["bitrate"].setText(status[self.iface]["bitrate"]) - self["enc"].setText(status[self.iface]["encryption"]) - self.updateStatusLink(status) + self.list = [] + self.statuslist = [] + self["list"] = List(self.list) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Reload")) + + self.list_updating = True + self.packetlist = [] + self.installed_packetlist = {} + self.Console = Console() + self.cmdList = [] + self.cachelist = [] + self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid (24h should be ok for caching ipkgs) + self.cache_file = '/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache' #Path to cache directory + self.oktext = _("\nAfter pressing OK, please wait!") + self.unwanted_extensions = ('-dbg', '-dev', '-doc', 'busybox') + + self.ipkg = IpkgComponent() + self.ipkg.addCallback(self.ipkgCallback) + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.rebuildList) def exit(self): - self.timer.stop() - self.close(True) - - def updateStatusbar(self): - self["BSSID"].setText(_("Please wait...")) - self["ESSID"].setText(_("Please wait...")) - self["quality"].setText(_("Please wait...")) - self["signal"].setText(_("Please wait...")) - self["bitrate"].setText(_("Please wait...")) - self["enc"].setText(_("Please wait...")) - self["IFtext"].setText(_("Network:")) - self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface)) - self["Statustext"].setText(_("Link:")) - - def updateStatusLink(self,status): - if status is not None: - if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False: - self["statuspic"].setPixmapNum(1) - else: - self["statuspic"].setPixmapNum(0) - self["statuspic"].show() + self.ipkg.stop() + if self.Console is not None: + if len(self.Console.appContainers): + for name in self.Console.appContainers.keys(): + self.Console.kill(name) + self.close() + + def reload(self): + if (os_path.exists(self.cache_file) == True): + remove(self.cache_file) + self.list_updating = True + self.rebuildList() + + def setWindowTitle(self): + self.setTitle(_("Packet manager")) + + def setStatus(self,status = None): + if status: + self.statuslist = [] + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + if status == 'update': + statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) + self.statuslist.append(( _("Package list update"), '', _("Trying to download a new packetlist. Please wait..." ),'',statuspng, divpng )) + self['list'].setList(self.statuslist) + elif status == 'error': + 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 )) + self['list'].setList(self.statuslist) + + def rebuildList(self): + self.setStatus('update') + self.inv_cache = 0 + self.vc = valid_cache(self.cache_file, self.cache_ttl) + if self.cache_ttl > 0 and self.vc != 0: + try: + self.buildPacketList() + except: + self.inv_cache = 1 + if self.cache_ttl == 0 or self.inv_cache == 1 or self.vc == 0: + self.run = 0 + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + + def go(self, returnValue = None): + cur = self["list"].getCurrent() + if cur: + status = cur[3] + package = cur[0] + self.cmdList = [] + if status == 'installed': + self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package })) + if len(self.cmdList): + self.session.openWithCallback(self.runRemove, MessageBox, _("Do you want to remove the package:\n") + package + "\n" + self.oktext) + elif status == 'upgradeable': + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package })) + if len(self.cmdList): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to upgrade the package:\n") + package + "\n" + self.oktext) + elif status == "installable": + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package })) + if len(self.cmdList): + self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to install the package:\n") + package + "\n" + self.oktext) + + def runRemove(self, result): + if result: + self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList) + + def runRemoveFinished(self): + self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def RemoveReboot(self, result): + if result is None: + return + if result is False: + cur = self["list"].getCurrent() + if cur: + item = self['list'].getIndex() + self.list[item] = self.buildEntryComponent(cur[0], cur[1], cur[2], 'installable') + self.cachelist[item] = [cur[0], cur[1], cur[2], 'installable'] + self['list'].setList(self.list) + write_cache(self.cache_file, self.cachelist) + self.reloadPluginlist() + if result: + quitMainloop(3) + + def runUpgrade(self, result): + if result: + self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList) + + def runUpgradeFinished(self): + self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def UpgradeReboot(self, result): + if result is None: + return + if result is False: + cur = self["list"].getCurrent() + if cur: + item = self['list'].getIndex() + self.list[item] = self.buildEntryComponent(cur[0], cur[1], cur[2], 'installed') + self.cachelist[item] = [cur[0], cur[1], cur[2], 'installed'] + self['list'].setList(self.list) + write_cache(self.cache_file, self.cachelist) + self.reloadPluginlist() + if result: + quitMainloop(3) + + def ipkgCallback(self, event, param): + if event == IpkgComponent.EVENT_ERROR: + self.list_updating = False + self.setStatus('error') + elif event == IpkgComponent.EVENT_DONE: + if self.list_updating: + self.list_updating = False + if not self.Console: + self.Console = Console() + cmd = "ipkg list" + self.Console.ePopen(cmd, self.IpkgList_Finished) + #print event, "-", param + pass + + def IpkgList_Finished(self, result, retval, extra_args = None): + if len(result): + self.packetlist = [] + for x in result.splitlines(): + split = x.split(' - ') #self.blacklisted_packages + if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): + self.packetlist.append([split[0].strip(), split[1].strip(),split[2].strip()]) + if not self.Console: + self.Console = Console() + cmd = "ipkg list_installed" + self.Console.ePopen(cmd, self.IpkgListInstalled_Finished) + + def IpkgListInstalled_Finished(self, result, retval, extra_args = None): + if len(result): + self.installed_packetlist = {} + for x in result.splitlines(): + split = x.split(' - ') + if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): + self.installed_packetlist[split[0].strip()] = split[1].strip() + self.buildPacketList() + + def buildEntryComponent(self, name, version, description, state): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + if state == 'installed': + installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) + return((name, version, description, state, installedpng, divpng)) + elif state == 'upgradeable': + upgradeablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgradeable.png")) + return((name, version, description, state, upgradeablepng, divpng)) + else: + installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) + return((name, version, description, state, installablepng, divpng)) + + def buildPacketList(self): + self.list = [] + self.cachelist = [] + + if self.cache_ttl > 0 and self.vc != 0: + print 'Loading packagelist cache from ',self.cache_file + try: + self.cachelist = load_cache(self.cache_file) + if len(self.cachelist) > 0: + for x in self.cachelist: + self.list.append(self.buildEntryComponent(x[0], x[1], x[2], x[3])) + self['list'].setList(self.list) + except: + self.inv_cache = 1 + + if self.cache_ttl == 0 or self.inv_cache == 1 or self.vc == 0: + print 'rebuilding fresh package list' + for x in self.packetlist: + status = "" + if self.installed_packetlist.has_key(x[0].strip()): + if self.installed_packetlist[x[0].strip()] == x[1].strip(): + status = "installed" + self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status)) + else: + status = "upgradeable" + self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status)) + else: + status = "installable" + self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status)) + if not any(x[0].strip().endswith(x) for x in self.unwanted_extensions): + self.cachelist.append([x[0].strip(), x[1].strip(), x[2].strip(), status]) + write_cache(self.cache_file, self.cachelist) + self['list'].setList(self.list) + + def reloadPluginlist(self): + plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) + + +class PluginManager(Screen, DreamInfoHandler): + + lastDownloadDate = None -class WlanScan(Screen): skin = """ - + + - + + + + {"templates": + {"default": (51,[ + MultiContentEntryText(pos = (30, 1), size = (470, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (30, 25), size = (470, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description + MultiContentEntryPixmapAlphaTest(pos = (475, 0), size = (48, 48), png = 5), # index 5 is the status pixmap + MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 6), # index 6 is the div pixmap + ]), + "category": (40,[ + MultiContentEntryText(pos = (30, 0), size = (500, 22), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (30, 22), size = (500, 16), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the description + MultiContentEntryPixmapAlphaTest(pos = (0, 38), size = (550, 2), png = 3), # index 3 is the div pixmap + ]) + }, + "fonts": [gFont("Regular", 22),gFont("Regular", 16)], + "itemHeight": 52 + } + + + + """ + + def __init__(self, session, plugin_path, args = None): + Screen.__init__(self, session) + self.session = session + self.skin_path = plugin_path + aboutInfo = about.getImageVersionString() + if aboutInfo.startswith("dev-"): + self.ImageVersion = 'Experimental' + else: + self.ImageVersion = 'Stable' + self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" + + DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, neededTag = 'ALL_TAGS', neededFlag = self.ImageVersion, language = self.language) + self.directory = resolveFilename(SCOPE_METADIR) + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions", "InfobarEPGActions", "HelpActions" ], + { + "ok": self.handleCurrent, + "back": self.exit, + "red": self.exit, + "green": self.handleCurrent, + "yellow": self.handleSelected, + "showEventInfo": self.handleSelected, + "displayHelp": self.handleHelp, + }, -1) + + self.list = [] + self.statuslist = [] + self.selectedFiles = [] + self.categoryList = [] + self["list"] = List(self.list) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText("") + self["key_yellow"] = StaticText("") + self["key_blue"] = StaticText("") + self["status"] = StaticText("") + + self.list_updating = True + self.packetlist = [] + self.installed_packetlist = {} + self.available_packetlist = [] + self.available_updates = 0 + self.Console = Console() + self.cmdList = [] + self.oktext = _("\nAfter pressing OK, please wait!") + self.unwanted_extensions = ('-dbg', '-dev', '-doc') + + self.ipkg = IpkgComponent() + self.ipkg.addCallback(self.ipkgCallback) + if not self.selectionChanged in self["list"].onSelectionChanged: + self["list"].onSelectionChanged.append(self.selectionChanged) + + self.currList = "" + self.currentSelectedTag = None + self.currentSelectedIndex = None + + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.rebuildList) + + def setWindowTitle(self): + self.setTitle(_("Plugin manager")) + + def exit(self): + if self.currList == "packages": + self.currList = "category" + self.currentSelectedTag = None + self["list"].style = "category" + self['list'].setList(self.categoryList) + self["list"].setIndex(self.currentSelectedIndex) + self["list"].updateList(self.categoryList) + self.selectionChanged() + else: + self.ipkg.stop() + if self.Console is not None: + if len(self.Console.appContainers): + for name in self.Console.appContainers.keys(): + self.Console.kill(name) + self.prepareInstall() + if len(self.cmdList): + self.session.openWithCallback(self.runExecute, PluginManagerInfo, self.skin_path, self.cmdList) + else: + self.close() + + def handleHelp(self): + if self.currList != "status": + self.session.open(PluginManagerHelp, self.skin_path) + + def setState(self,status = None): + if status: + self.currList = "status" + self.statuslist = [] + self["key_green"].setText("") + self["key_blue"].setText("") + self["key_yellow"].setText("") + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + if status == 'update': + statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) + self.statuslist.append(( _("Package list update"), '', _("Trying to download a new packetlist. Please wait..." ),'', '', statuspng, divpng, None, '' )) + self["list"].style = "default" + self['list'].setList(self.statuslist) + elif status == 'sync': + 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, '' )) + self["list"].style = "default" + self['list'].setList(self.statuslist) + elif status == 'error': + 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" + self['list'].setList(self.statuslist) + + def statusCallback(self, status, progress): + pass + + def selectionChanged(self): + current = self["list"].getCurrent() + self["status"].setText("") + if current: + if self.currList == "packages": + self["key_red"].setText(_("Back")) + if current[4] == 'installed': + self["key_green"].setText(_("Remove")) + elif current[4] == 'installable': + self["key_green"].setText(_("Install")) + elif current[4] == 'remove': + self["key_green"].setText(_("Undo\nRemove")) + elif current[4] == 'install': + self["key_green"].setText(_("Undo\nInstall")) + self["key_yellow"].setText(_("View details")) + self["key_blue"].setText("") + if len(self.selectedFiles) == 0 and self.available_updates is not 0: + self["status"].setText(_("There are at least ") + str(self.available_updates) + _(" updates available.")) + elif len(self.selectedFiles) is not 0: + self["status"].setText(str(len(self.selectedFiles)) + _(" packages selected.")) + else: + self["status"].setText(_("There is nothing to be done.")) + elif self.currList == "category": + self["key_red"].setText(_("Close")) + self["key_green"].setText("") + self["key_yellow"].setText("") + self["key_blue"].setText("") + if len(self.selectedFiles) == 0 and self.available_updates is not 0: + self["status"].setText(_("There are at least ") + str(self.available_updates) + _(" updates available.")) + self["key_yellow"].setText(_("Update")) + elif len(self.selectedFiles) is not 0: + self["status"].setText(str(len(self.selectedFiles)) + _(" packages selected.")) + self["key_yellow"].setText(_("Process")) + else: + self["status"].setText(_("There is nothing to be done.")) + + def getSelectionState(self, detailsFile): + for entry in self.selectedFiles: + if entry[0] == detailsFile: + return True + return False + + def rebuildList(self): + self.setState('update') + if not PluginManager.lastDownloadDate or (time() - PluginManager.lastDownloadDate) > 3600: + # Only update from internet once per hour + PluginManager.lastDownloadDate = time() + print "last update time > 1h" + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + else: + print "last update time < 1h" + self.startIpkgList() + + def ipkgCallback(self, event, param): + if event == IpkgComponent.EVENT_ERROR: + self.list_updating = False + self.setState('error') + elif event == IpkgComponent.EVENT_DONE: + self.startIpkgList() + pass + + def startIpkgList(self): + if self.list_updating: + if not self.Console: + self.Console = Console() + cmd = "ipkg list" + self.Console.ePopen(cmd, self.IpkgList_Finished) + + def IpkgList_Finished(self, result, retval, extra_args = None): + if len(result): + self.available_packetlist = [] + for x in result.splitlines(): + split = x.split(' - ') + if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): + self.available_packetlist.append([split[0].strip(), split[1].strip(), split[2].strip()]) + self.startInstallMetaPackage() + + def startInstallMetaPackage(self): + if self.list_updating: + self.list_updating = False + if not self.Console: + self.Console = Console() + cmd = "ipkg install enigma2-meta enigma2-plugins-meta enigma2-skins-meta" + self.Console.ePopen(cmd, self.InstallMetaPackage_Finished) + + def InstallMetaPackage_Finished(self, result, retval, extra_args = None): + if len(result): + self.fillPackagesIndexList() + if not self.Console: + self.Console = Console() + self.setState('sync') + cmd = "ipkg list_installed" + self.Console.ePopen(cmd, self.IpkgListInstalled_Finished) + + def IpkgListInstalled_Finished(self, result, retval, extra_args = None): + if len(result): + self.installed_packetlist = {} + for x in result.splitlines(): + split = x.split(' - ') + if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): + self.installed_packetlist[split[0].strip()] = split[1].strip() + self.countUpdates() + if self.currentSelectedTag is None: + self.buildCategoryList() + else: + self.buildPacketList(self.currentSelectedTag) + + def countUpdates(self): + self.available_updates = 0 + for package in self.packagesIndexlist[:]: + attributes = package[0]["attributes"] + packagename = attributes["packagename"] + for x in self.available_packetlist: + if x[0].strip() == packagename: + if self.installed_packetlist.has_key(packagename): + if self.installed_packetlist[packagename] != x[1].strip(): + self.available_updates +=1 + + def handleCurrent(self): + current = self["list"].getCurrent() + if current: + if self.currList == "category": + self.currentSelectedIndex = self["list"].index + selectedTag = current[2] + self.buildPacketList(selectedTag) + elif self.currList == "packages": + if current[7] is not '': + idx = self["list"].getIndex() + detailsFile = self.list[idx][1] + if self.list[idx][7] == True: + for entry in self.selectedFiles: + if entry[0] == detailsFile: + self.selectedFiles.remove(entry) + else: + alreadyinList = False + for entry in self.selectedFiles: + if entry[0] == detailsFile: + alreadyinList = True + if not alreadyinList: + self.selectedFiles.append((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) + 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) + self["list"].setList(self.list) + self["list"].setIndex(idx) + self["list"].updateList(self.list) + self.selectionChanged() + + def handleSelected(self): + current = self["list"].getCurrent() + if current: + if self.currList == "packages": + if current[7] is not '': + detailsfile = self.directory[0] + "/" + current[1] + if (os_path.exists(detailsfile) == True): + self.session.openWithCallback(self.detailsClosed, PluginDetails, self.skin_path, current) + else: + self.session.open(MessageBox, _("Sorry, no Details available!"), MessageBox.TYPE_INFO, timeout = 10) + elif self.currList == "category": + self.prepareInstall() + if len(self.cmdList): + self.session.openWithCallback(self.runExecute, PluginManagerInfo, self.skin_path, self.cmdList) + + def detailsClosed(self, result): + if result: + if not self.Console: + self.Console = Console() + self.setState('sync') + PluginManager.lastDownloadDate = time() + self.selectedFiles = [] + cmd = "ipkg update" + self.Console.ePopen(cmd, self.InstallMetaPackage_Finished) + + def buildEntryComponent(self, name, details, description, packagename, state, selected = False): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + if state == 'installed': + installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) + return((name, details, description, packagename, state, installedpng, divpng, selected)) + elif state == 'installable': + installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) + return((name, details, description, packagename, state, installablepng, divpng, selected)) + elif state == 'remove': + removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) + return((name, details, description, packagename, state, removepng, divpng, selected)) + elif state == 'install': + installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) + return((name, details, description, packagename, state, installpng, divpng, selected)) + + def buildPacketList(self, categorytag = None): + if categorytag is not None: + self.currList = "packages" + self.currentSelectedTag = categorytag + self.packetlist = [] + for package in self.packagesIndexlist[:]: + prerequisites = package[0]["prerequisites"] + if prerequisites.has_key("tag"): + for foundtag in prerequisites["tag"]: + if categorytag == foundtag: + attributes = package[0]["attributes"] + if attributes.has_key("packagetype"): + if attributes["packagetype"] == "internal": + continue + self.packetlist.append([attributes["name"], attributes["details"], attributes["shortdescription"], attributes["packagename"]]) + else: + self.packetlist.append([attributes["name"], attributes["details"], attributes["shortdescription"], attributes["packagename"]]) + self.list = [] + for x in self.packetlist: + status = "" + selectState = self.getSelectionState(x[1].strip()) + if self.installed_packetlist.has_key(x[3].strip()): + if selectState == True: + status = "remove" + else: + status = "installed" + self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = selectState)) + else: + if selectState == True: + status = "install" + else: + status = "installable" + self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = selectState)) + if len(self.list): + self.list.sort(key=lambda x: x[0]) + self["list"].style = "default" + self['list'].setList(self.list) + self["list"].updateList(self.list) + self.selectionChanged() + + def buildCategoryList(self): + self.currList = "category" + self.categories = [] + self.categoryList = [] + for package in self.packagesIndexlist[:]: + prerequisites = package[0]["prerequisites"] + if prerequisites.has_key("tag"): + for foundtag in prerequisites["tag"]: + attributes = package[0]["attributes"] + if foundtag not in self.categories: + self.categories.append(foundtag) + self.categoryList.append(self.buildCategoryComponent(foundtag)) + self.categoryList.sort(key=lambda x: x[0]) + self["list"].style = "category" + self['list'].setList(self.categoryList) + self["list"].updateList(self.categoryList) + self.selectionChanged() + + def buildCategoryComponent(self, tag = None): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + if tag is not None: + if tag == 'System': + return(( _("System"), _("View list of available system extensions" ), tag, divpng )) + elif tag == 'Skin': + return(( _("Skins"), _("View list of available skins" ), tag, divpng )) + elif tag == 'Recording': + return(( _("Recordings"), _("View list of available recording extensions" ), tag, divpng )) + elif tag == 'Network': + return(( _("Network"), _("View list of available networking extensions" ), tag, divpng )) + elif tag == 'CI': + return(( _("CommonInterface"), _("View list of available CommonInterface extensions" ), tag, divpng )) + elif tag == 'Default': + return(( _("Default Settings"), _("View list of available default settings" ), tag, divpng )) + elif tag == 'SAT': + return(( _("Satteliteequipment"), _("View list of available Satteliteequipment extensions." ), tag, divpng )) + elif tag == 'Software': + return(( _("Software"), _("View list of available software extensions" ), tag, divpng )) + elif tag == 'Multimedia': + return(( _("Multimedia"), _("View list of available multimedia extensions." ), tag, divpng )) + elif tag == 'Display': + return(( _("Display and Userinterface"), _("View list of available Display and Userinterface extensions." ), tag, divpng )) + elif tag == 'EPG': + return(( _("Electronic Program Guide"), _("View list of available EPG extensions." ), tag, divpng )) + elif tag == 'Communication': + return(( _("Communication"), _("View list of available communication extensions." ), tag, divpng )) + else: # dynamically generate non existent tags + return(( str(tag), _("View list of available ") + str(tag) + _(" extensions." ), tag, divpng )) + + def prepareInstall(self): + self.cmdList = [] + if self.available_updates > 0: + self.cmdList.append((IpkgComponent.CMD_UPGRADE, { "test_only": False })) + if self.selectedFiles and len(self.selectedFiles): + for plugin in self.selectedFiles: + detailsfile = self.directory[0] + "/" + plugin[0] + if (os_path.exists(detailsfile) == True): + self.fillPackageDetails(plugin[0]) + self.package = self.packageDetails[0] + if self.package[0].has_key("attributes"): + self.attributes = self.package[0]["attributes"] + if self.attributes.has_key("package"): + self.packagefiles = self.attributes["package"] + if plugin[1] == 'installed': + if self.packagefiles: + for package in self.packagefiles[:]: + self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package["name"] })) + else: + self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": plugin[2] })) + else: + if self.packagefiles: + for package in self.packagefiles[:]: + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package["name"] })) + else: + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": plugin[2] })) + else: + if plugin[1] == 'installed': + self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": plugin[2] })) + else: + self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": plugin[2] })) + + def runExecute(self, result): + if result: + self.session.openWithCallback(self.runExecuteFinished, Ipkg, cmdList = self.cmdList) + else: + self.close() + + def runExecuteFinished(self): + self.session.openWithCallback(self.ExecuteReboot, MessageBox, _("Install or remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def ExecuteReboot(self, result): + if result is None: + return + if result is False: + self.reloadPluginlist() + self.detailsClosed(True) + if result: + quitMainloop(3) + + def reloadPluginlist(self): + plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) + + +class PluginManagerInfo(Screen): + skin = """ + + + + + + {"template": [ - MultiContentEntryText(pos = (0, 0), size = (550, 30), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the essid - MultiContentEntryText(pos = (0, 30), size = (175, 20), font=1, flags = RT_HALIGN_LEFT, text = 5), # index 5 is the interface - MultiContentEntryText(pos = (175, 30), size = (175, 20), font=1, flags = RT_HALIGN_LEFT, text = 4), # index 0 is the encryption - MultiContentEntryText(pos = (350, 0), size = (200, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 0 is the signal - MultiContentEntryText(pos = (350, 30), size = (200, 20), font=1, flags = RT_HALIGN_LEFT, text = 3), # index 0 is the maxrate - MultiContentEntryPixmapAlphaTest(pos = (0, 52), size = (550, 2), png = 6), # index 6 is the div pixmap + MultiContentEntryText(pos = (50, 1), size = (150, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (50, 25), size = (540, 24), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the state + MultiContentEntryPixmapAlphaTest(pos = (0, 1), size = (48, 48), png = 2), # index 2 is the status pixmap + MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 3), # index 3 is the div pixmap ], - "fonts": [gFont("Regular", 28),gFont("Regular", 18)], - "itemHeight": 54 + "fonts": [gFont("Regular", 22),gFont("Regular", 18)], + "itemHeight": 52 } - - + + """ - def __init__(self, session, iface): + def __init__(self, session, plugin_path, cmdlist = None): Screen.__init__(self, session) self.session = session - self.iface = iface self.skin_path = plugin_path - self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") - self.APList = None - self.newAPList = None - self.WlanList = None - self.cleanList = None - self.oldlist = None - self.listLenght = None - self.rescanTimer = eTimer() - self.rescanTimer.callback.append(self.rescanTimerFired) - - self["info"] = StaticText() - + self.cmdlist = cmdlist + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + { + "ok": self.process, + "back": self.exit, + "red": self.exit, + "green": self.process, + }, -1) + self.list = [] self["list"] = List(self.list) - - self["key_red"] = StaticText(_("Close")) - self["key_green"] = StaticText(_("Connect")) - self["key_yellow"] = StaticText() - - self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"], + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("Continue")) + self["status"] = StaticText(_("Following tasks will be done after you press continue!")) + + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.rebuildList) + + def setWindowTitle(self): + self.setTitle(_("Plugin manager activity information")) + + def rebuildList(self): + self.list = [] + if self.cmdlist is not None: + for entry in self.cmdlist: + action = "" + info = "" + cmd = entry[0] + if cmd == 0: + action = 'install' + elif cmd == 2: + action = 'remove' + else: + action = 'upgrade' + args = entry[1] + if cmd == 0: + info = args['package'] + elif cmd == 2: + info = args['package'] + else: + info = _("Dreambox software because updates are available.") + + self.list.append(self.buildEntryComponent(action,info)) + self['list'].setList(self.list) + self['list'].updateList(self.list) + + def buildEntryComponent(self, action,info): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + upgradepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) + installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) + removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) + if action == 'install': + return(( _('Installing'), info, installpng, divpng)) + elif action == 'remove': + return(( _('Removing'), info, removepng, divpng)) + else: + return(( _('Upgrading'), info, upgradepng, divpng)) + + def exit(self): + self.close(False) + + def process(self): + self.close(True) + + +class PluginManagerHelp(Screen): + skin = """ + + + + + + {"template": [ + MultiContentEntryText(pos = (50, 1), size = (540, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (50, 25), size = (540, 24), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the state + MultiContentEntryPixmapAlphaTest(pos = (0, 1), size = (48, 48), png = 2), # index 2 is the status pixmap + MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 3), # index 3 is the div pixmap + ], + "fonts": [gFont("Regular", 22),gFont("Regular", 18)], + "itemHeight": 52 + } + + + + + """ + + def __init__(self, session, plugin_path): + Screen.__init__(self, session) + self.session = session + self.skin_path = plugin_path + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], { - "ok": self.select, - "back": self.cancel, + "back": self.exit, + "red": self.exit, }, -1) - - self["shortcuts"] = ActionMap(["ShortcutActions"], + + self.list = [] + self["list"] = List(self.list) + self["key_red"] = StaticText(_("Close")) + self["status"] = StaticText(_("A small overview of the available icon states and actions.")) + + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.rebuildList) + + def setWindowTitle(self): + self.setTitle(_("Plugin manager help")) + + def rebuildList(self): + self.list = [] + self.list.append(self.buildEntryComponent('install')) + self.list.append(self.buildEntryComponent('installable')) + self.list.append(self.buildEntryComponent('installed')) + self.list.append(self.buildEntryComponent('remove')) + self['list'].setList(self.list) + self['list'].updateList(self.list) + + def buildEntryComponent(self, state): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) + installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) + installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) + removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) + installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) + + if state == 'installed': + return(( _('This plugin is installed.'), _('You can remove this plugin.'), installedpng, divpng)) + elif state == 'installable': + return(( _('This plugin is not installed.'), _('You can install this plugin.'), installablepng, divpng)) + elif state == 'install': + return(( _('This plugin will be installed.'), _('You can cancel the installation.'), installpng, divpng)) + elif state == 'remove': + return(( _('This plugin will be removed.'), _('You can cancel the removal.'), removepng, divpng)) + + def exit(self): + self.close() + + +class PluginDetails(Screen, DreamInfoHandler): + skin = """ + + + + + + + + + + + """ + def __init__(self, session, plugin_path, packagedata = None): + Screen.__init__(self, session) + self.skin_path = plugin_path + self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" + self.attributes = None + self.translatedAttributes = None + DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, language = self.language) + self.directory = resolveFilename(SCOPE_METADIR) + if packagedata: + self.pluginname = packagedata[0] + self.details = packagedata[1] + self.pluginstate = packagedata[4] + self.statuspicinstance = packagedata[5] + self.divpicinstance = packagedata[6] + self.fillPackageDetails(self.details) + + self.thumbnail = "" + + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], { - "red": self.cancel, - "green": self.select, - }) - self.onLayoutFinish.append(self.layoutFinished) - self.getAccessPoints(refresh = False) - - def layoutFinished(self): - self.setTitle(_("Choose a wireless network")) - - def select(self): - cur = self["list"].getCurrent() - if cur is not None: - self.rescanTimer.stop() - del self.rescanTimer - if cur[1] is not None: - essid = cur[1] - self.close(essid,self.getWlanList()) - else: - self.close(None,None) - else: - self.rescanTimer.stop() - del self.rescanTimer - self.close(None,None) - - def WlanSetupClosed(self, *ret): - if ret[0] == 2: - self.rescanTimer.stop() - del self.rescanTimer - self.close(None) - - def cancel(self): - if self.oldInterfaceState is False: - iNetwork.setAdapterAttribute(self.iface, "up", False) - iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB) + "back": self.exit, + "red": self.exit, + "green": self.go, + "up": self.pageUp, + "down": self.pageDown, + "left": self.pageUp, + "right": self.pageDown, + }, -1) + + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText("") + self["author"] = StaticText() + self["statuspic"] = Pixmap() + self["divpic"] = Pixmap() + self["screenshot"] = Pixmap() + self["detailtext"] = ScrollLabel() + + self["statuspic"].hide() + self["screenshot"].hide() + self["divpic"].hide() + + self.package = self.packageDetails[0] + if self.package[0].has_key("attributes"): + self.attributes = self.package[0]["attributes"] + if self.package[0].has_key("translation"): + self.translatedAttributes = self.package[0]["translation"] + + self.cmdList = [] + self.oktext = _("\nAfter pressing OK, please wait!") + self.picload = ePicLoad() + self.picload.PictureData.get().append(self.paintScreenshotPixmapCB) + self.onShown.append(self.setWindowTitle) + self.onLayoutFinish.append(self.setInfos) + + def setWindowTitle(self): + self.setTitle(_("Package details for: " + self.pluginname)) + + def exit(self): + self.close(False) + + def pageUp(self): + self["detailtext"].pageUp() + + def pageDown(self): + self["detailtext"].pageDown() + + def statusCallback(self, status, progress): + pass + + def setInfos(self): + if self.translatedAttributes.has_key("name"): + self.pluginname = self.translatedAttributes["name"] + elif self.attributes.has_key("name"): + self.pluginname = self.attributes["name"] else: - self.rescanTimer.stop() - del self.rescanTimer - self.close(None) - - def deactivateInterfaceCB(self,data): - if data is not None: - if data is True: - self.rescanTimer.stop() - del self.rescanTimer - self.close(None) - - def rescanTimerFired(self): - self.rescanTimer.stop() - self.updateAPList() - - def buildEntryComponent(self, essid, bssid, encrypted, iface, maxrate, signal): -<<<<<<< HEAD:lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py - print "buildEntryComponent",essid - print "buildEntryComponent",bssid -======= ->>>>>>> origin/bug_203_fix_wrong_networkstate:lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) - encryption = encrypted and _("Yes") or _("No") - if bssid == 'hidden...': - return((essid, bssid, None, None, None, None, divpng)) - else: - return((essid, bssid, _("Signal: ") + str(signal), _("Max. Bitrate: ") + str(maxrate), _("Encrypted: ") + encryption, _("Interface: ") + str(iface), divpng)) - - def updateAPList(self): - self.oldlist = [] - self.oldlist = self.cleanList - self.newAPList = [] - newList = [] - tmpList = [] - newListIndex = None - currentListEntry = None - currentListIndex = None - newList = self.getAccessPoints(refresh = True) - - for oldentry in self.oldlist: - if oldentry not in newList: - newList.append(oldentry) - - for newentry in newList: - if newentry[1] == "hidden...": - continue - tmpList.append(newentry) - - if len(tmpList): - if "hidden..." not in tmpList: - tmpList.append( ( _("enter hidden network SSID"), "hidden...", True, self.iface, _("unavailable"), "" ) ) - - for entry in tmpList: - self.newAPList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) - - currentListEntry = self["list"].getCurrent() - idx = 0 - for entry in self.newAPList: - if entry == currentListEntry: - newListIndex = idx - idx +=1 - self['list'].setList(self.newAPList) - self["list"].setIndex(newListIndex) - self["list"].updateList(self.newAPList) - self.listLenght = len(self.newAPList) - self.buildWlanList() - self.setInfo() - - def getAccessPoints(self, refresh = False): - self.APList = [] - self.cleanList = [] - self.w = Wlan(self.iface) - aps = self.w.getNetworkList() - if aps is not None: - print "[NetworkWizard.py] got Accespoints!" - tmpList = [] - compList = [] - for ap in aps: - a = aps[ap] - if a['active']: - tmpList.append( (a['essid'], a['bssid']) ) - compList.append( (a['essid'], a['bssid'], a['encrypted'], a['iface'], a['maxrate'], a['signal']) ) - - for entry in tmpList: - if entry[0] == "": - for compentry in compList: - if compentry[1] == entry[1]: - compList.remove(compentry) - for entry in compList: - self.cleanList.append( ( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] ) ) - - if "hidden..." not in self.cleanList: - self.cleanList.append( ( _("enter hidden network SSID"), "hidden...", True, self.iface, _("unavailable"), "" ) ) + self.pluginname = _("unknown") - for entry in self.cleanList: - self.APList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) - - if refresh is False: - self['list'].setList(self.APList) - self.listLenght = len(self.APList) - self.setInfo() - self.rescanTimer.start(5000) - return self.cleanList - - def setInfo(self): - length = self.getLength() - if length == 0: - self["info"].setText(_("No wireless networks found! Please refresh.")) - elif length == 1: - self["info"].setText(_("1 wireless network found!")) + if self.translatedAttributes.has_key("author"): + self.author = self.translatedAttributes["author"] + elif self.attributes.has_key("author"): + self.author = self.attributes["author"] else: - self["info"].setText(str(length)+_(" wireless networks found!")) + self.author = _("unknown") - def buildWlanList(self): - self.WlanList = [] - currList = [] - currList = self['list'].list - for entry in currList: - self.WlanList.append( (entry[1], entry[0]) ) + if self.translatedAttributes.has_key("description"): + self.description = self.translatedAttributes["description"] + elif self.attributes.has_key("description"): + self.description = self.attributes["description"] + else: + self.description = _("No description available.") - def getLength(self): - return self.listLenght + if self.translatedAttributes.has_key("screenshot"): + self.loadThumbnail(self.translatedAttributes) + else: + self.loadThumbnail(self.attributes) - def getWlanList(self): - return self.WlanList + self["author"].setText(_("Author: ") + self.author) + self["detailtext"].setText(self.description.strip()) + if self.pluginstate == 'installable': + self["key_green"].setText(_("Install")) + else: + self["key_green"].setText(_("Remove")) + def loadThumbnail(self, entry): + thumbnailUrl = None + if entry.has_key("screenshot"): + thumbnailUrl = entry["screenshot"] + 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) + else: + self.setThumbnail(noScreenshot = True) -def WlanStatusScreenMain(session, iface): - session.open(WlanStatus, iface) + def setThumbnail(self, noScreenshot = False): + if not noScreenshot: + filename = self.thumbnail + else: + filename = resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/noprev.png") + sc = AVSwitch().getFramebufferScale() + self.picload.setPara((self["screenshot"].instance.size().width(), self["screenshot"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000")) + self.picload.startDecode(filename) -def callFunction(iface): - w = Wlan(iface) - i = w.getWirelessInterfaces() - if i: - if iface in i: - return WlanStatusScreenMain - return None + if self.statuspicinstance != None: + self["statuspic"].instance.setPixmap(self.statuspicinstance.__deref__()) + self["statuspic"].show() + if self.divpicinstance != None: + self["divpic"].instance.setPixmap(self.divpicinstance.__deref__()) + self["divpic"].show() + def paintScreenshotPixmapCB(self, picInfo=None): + ptr = self.picload.getData() + if ptr != None: + self["screenshot"].instance.setPixmap(ptr.__deref__()) + self["screenshot"].show() + else: + self.setThumbnail(noScreenshot = True) -def configStrings(iface): - driver = iNetwork.detectWlanModule() - print "Found WLAN-Driver:",driver - if driver in ('ralink', 'zydas'): - return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -D"+driver+"\n post-down wpa_cli terminate" - else: - if config.plugins.wlan.essid.value == "hidden...": - return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n post-down wpa_cli terminate' + def go(self): + if self.attributes.has_key("package"): + self.packagefiles = self.attributes["package"] + self.cmdList = [] + if self.pluginstate == 'installed': + if self.packagefiles: + for package in self.packagefiles[:]: + self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package["name"] })) + if len(self.cmdList): + self.session.openWithCallback(self.runRemove, MessageBox, _("Do you want to remove the package:\n") + self.pluginname + "\n" + self.oktext) else: - return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n post-down wpa_cli terminate' + 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: + self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList) + + def runUpgradeFinished(self): + self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Installation finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def UpgradeReboot(self, result): + if result is None: + return + if result is False: + self.close(True) + if result: + quitMainloop(3) + + def runRemove(self, result): + if result: + self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList) + + def runRemoveFinished(self): + self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + + def RemoveReboot(self, result): + if result is None: + return + if result is False: + self.close(True) + if result: + quitMainloop(3) + + def reloadPluginlist(self): + plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) + + def fetchFailed(self,string): + self.setThumbnail(noScreenshot = True) + print "[PluginDetails] fetch failed " + string.getErrorMessage() + + +class UpdatePlugin(Screen): + skin = """ + + + + + + """ + + def __init__(self, session, args = None): + Screen.__init__(self, session) + + self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 } + + self.slider = Slider(0, 4) + self["slider"] = self.slider + self.activityslider = Slider(0, 100) + self["activityslider"] = self.activityslider + self.status = StaticText(_("Upgrading Dreambox... Please wait")) + self["status"] = self.status + self.package = StaticText() + self["package"] = self.package + + self.packages = 0 + self.error = 0 + + self.activity = 0 + self.activityTimer = eTimer() + self.activityTimer.callback.append(self.doActivityTimer) + self.activityTimer.start(100, False) + + self.ipkg = IpkgComponent() + self.ipkg.addCallback(self.ipkgCallback) + + self.updating = True + self.package.setText(_("Package list update")) + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + + self["actions"] = ActionMap(["WizardActions"], + { + "ok": self.exit, + "back": self.exit + }, -1) + + def doActivityTimer(self): + self.activity += 1 + if self.activity == 100: + self.activity = 0 + self.activityslider.setValue(self.activity) + + def ipkgCallback(self, event, param): + if event == IpkgComponent.EVENT_DOWNLOAD: + self.status.setText(_("Downloading")) + elif event == IpkgComponent.EVENT_UPGRADE: + if self.sliderPackages.has_key(param): + self.slider.setValue(self.sliderPackages[param]) + self.package.setText(param) + self.status.setText(_("Upgrading")) + self.packages += 1 + elif event == IpkgComponent.EVENT_INSTALL: + self.package.setText(param) + self.status.setText(_("Installing")) + self.packages += 1 + elif event == IpkgComponent.EVENT_CONFIGURING: + self.package.setText(param) + self.status.setText(_("Configuring")) + elif event == IpkgComponent.EVENT_MODIFIED: + self.session.openWithCallback( + self.modificationCallback, + MessageBox, + _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param) + ) + elif event == IpkgComponent.EVENT_ERROR: + self.error += 1 + elif event == IpkgComponent.EVENT_DONE: + if self.updating: + self.updating = False + self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False}) + elif self.error == 0: + self.slider.setValue(4) + + self.activityTimer.stop() + self.activityslider.setValue(0) + + self.package.setText("") + self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages) + else: + self.activityTimer.stop() + self.activityslider.setValue(0) + error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.") + if self.packages == 0: + error = _("No packages were upgraded yet. So you can check your network and try again.") + if self.updating: + error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.") + self.status.setText(_("Error") + " - " + error) + #print event, "-", param + pass + + def modificationCallback(self, res): + self.ipkg.write(res and "N" or "Y") + + def exit(self): + if not self.ipkg.isRunning(): + if self.packages != 0 and self.error == 0: + self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?")) + else: + self.close() + + def exitAnswer(self, result): + if result is not None and result: + quitMainloop(2) + self.close() + + +class IpkgInstaller(Screen): + skin = """ + + + + + + + + + """ + + def __init__(self, session, list): + Screen.__init__(self, session) + + self.list = SelectionList() + self["list"] = self.list + for listindex in range(len(list)): + self.list.addSelection(list[listindex], list[listindex], listindex, True) + + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText(_("Install")) + self["introduction"] = StaticText(_("Press OK to toggle the selection.")) + + self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], + { + "ok": self.list.toggleSelection, + "cancel": self.close, + "red": self.close, + "green": self.install + }, -1) + + def install(self): + list = self.list.getSelectionsList() + cmdList = [] + for item in list: + cmdList.append((IpkgComponent.CMD_INSTALL, { "package": item[1] })) + self.session.open(Ipkg, cmdList = cmdList) + + +def filescan_open(list, session, **kwargs): + filelist = [x.path for x in list] + session.open(IpkgInstaller, filelist) # list + +def filescan(**kwargs): + from Components.Scanner import Scanner, ScanPath + return \ + Scanner(mimetypes = ["application/x-debian-package"], + paths_to_scan = + [ + ScanPath(path = "ipk", with_subdirs = True), + ScanPath(path = "", with_subdirs = False), + ], + name = "Ipkg", + description = _("Install extensions."), + openfnc = filescan_open, ) + + + +def UpgradeMain(session, **kwargs): + session.open(UpdatePluginMenu) + +def startSetup(menuid): + if menuid != "setup": + return [ ] + return [(_("Software manager"), UpgradeMain, "software_manager", 50)] -def Plugins(**kwargs): - return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."}) - \ No newline at end of file +def Plugins(path, **kwargs): + global plugin_path + plugin_path = path + list = [ + PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), + PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) + ] + if config.usage.setup_level.index >= 2: # expert+ + list.append(PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=UpgradeMain)) + return list -- cgit v1.2.3 From e198493e29c22e49dff1da47e83a989cdbd1d913 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Tue, 15 Dec 2009 19:35:25 +0100 Subject: fix wrong fix ;-( --- .../Plugins/SystemPlugins/WirelessLan/plugin.py | 1994 ++++---------------- 1 file changed, 328 insertions(+), 1666 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index 8aafd9a7..6873ffa4 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -1,1734 +1,396 @@ -from Plugins.Plugin import PluginDescriptor -from Screens.Console import Console -from Screens.ChoiceBox import ChoiceBox -from Screens.MessageBox import MessageBox +from enigma import eTimer from Screens.Screen import Screen -from Screens.Ipkg import Ipkg from Components.ActionMap import ActionMap, NumberActionMap -from Components.Input import Input -from Components.Ipkg import IpkgComponent +from Components.Pixmap import Pixmap,MultiPixmap +from Components.Label import Label from Components.Sources.StaticText import StaticText -from Components.ScrollLabel import ScrollLabel -from Components.Pixmap import Pixmap -from Components.MenuList import MenuList from Components.Sources.List import List -from Components.Slider import Slider -from Components.Harddisk import harddiskmanager -from Components.config import config,getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations +from Components.MenuList import MenuList +from Components.config import config, getConfigListEntry, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection, ConfigPassword +from Components.ConfigList import ConfigListScreen +from Components.Network import Network, iNetwork from Components.Console import Console -from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest -from Components.SelectionList import SelectionList -from Components.PluginComponent import plugins -from Components.About import about -from Components.DreamInfoHandler import DreamInfoHandler -from Components.Language import language -from Components.AVSwitch import AVSwitch -from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_PLUGIN, SCOPE_CURRENT_SKIN, SCOPE_METADIR +from Plugins.Plugin import PluginDescriptor +from os import system, path as os_path, listdir +from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE from Tools.LoadPixmap import LoadPixmap -from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad -from cPickle import dump, load -from os import path as os_path, system as os_system, unlink, stat, mkdir, popen, makedirs, listdir, access, rename, remove, W_OK, R_OK, F_OK -from time import time, gmtime, strftime, localtime -from stat import ST_MTIME -from datetime import date -from twisted.web import client -from twisted.internet import reactor - -from ImageWizard import ImageWizard -from BackupRestore import BackupSelection, RestoreMenu, BackupScreen, RestoreScreen, getBackupPath, getBackupFilename -#from SoftwareTools import extensions - -config.plugins.configurationbackup = ConfigSubsection() -config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) -config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) - -def write_cache(cache_file, cache_data): - #Does a cPickle dump - if not os_path.isdir( os_path.dirname(cache_file) ): - try: - mkdir( os_path.dirname(cache_file) ) - except OSError: - print os_path.dirname(cache_file), 'is a file' - fd = open(cache_file, 'w') - dump(cache_data, fd, -1) - fd.close() - -def valid_cache(cache_file, cache_ttl): - #See if the cache file exists and is still living - try: - mtime = stat(cache_file)[ST_MTIME] - except: - return 0 - curr_time = time() - if (curr_time - mtime) > cache_ttl: - return 0 - else: - return 1 - -def load_cache(cache_file): - #Does a cPickle load - fd = open(cache_file) - cache_data = load(fd) - fd.close() - return cache_data - - -class UpdatePluginMenu(Screen): - skin = """ - - - - - - - {"template": [ - MultiContentEntryText(pos = (2, 2), size = (290, 22), flags = RT_HALIGN_LEFT, text = 1), # index 0 is the MenuText, - ], - "fonts": [gFont("Regular", 20)], - "itemHeight": 25 - } - - - - - {"template": [ - MultiContentEntryText(pos = (2, 2), size = (240, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 2 is the Description, - ], - "fonts": [gFont("Regular", 20)], - "itemHeight": 300 - } - - - """ - - def __init__(self, session, args = 0): - Screen.__init__(self, session) - self.skin_path = plugin_path - self.menu = args - self.list = [] - self.oktext = _("\nPress OK on your remote control to continue.") - self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) - if self.menu == 0: - self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + self.oktext, None)) - self.list.append(("install-plugins", _("Install extensions"), _("\nInstall new Extensions or Plugins to your dreambox" ) + self.oktext, None)) - self.list.append(("software-restore", _("Software restore"), _("\nRestore your Dreambox with a new firmware." ) + self.oktext, None)) - self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext, None)) - self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext, None)) - self.list.append(("ipkg-install", _("Install local extension"), _("\nScan for local packages and install them." ) + self.oktext, None)) - for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER): - if p.__call__.has_key("SoftwareSupported"): - callFnc = p.__call__["SoftwareSupported"](None) - if callFnc is not None: - if p.__call__.has_key("menuEntryName"): - menuEntryName = p.__call__["menuEntryName"](None) - else: - menuEntryName = _('Extended Software') - if p.__call__.has_key("menuEntryDescription"): - menuEntryDescription = p.__call__["menuEntryDescription"](None) - else: - menuEntryDescription = _('Extended Software Plugin') - self.list.append(('default-plugin', menuEntryName, menuEntryDescription + self.oktext, callFnc)) - if config.usage.setup_level.index >= 2: # expert+ - self.list.append(("advanced", _("Advanced Options"), _("\nAdvanced options and settings." ) + self.oktext, None)) - elif self.menu == 1: - self.list.append(("advancedrestore", _("Advanced restore"), _("\nRestore your backups by date." ) + self.oktext, None)) - self.list.append(("backuplocation", _("Choose backup location"), _("\nSelect your backup device.\nCurrent device: " ) + config.plugins.configurationbackup.backuplocation.value + self.oktext, None)) - self.list.append(("backupfiles", _("Choose backup files"), _("Select files for backup. Currently selected:\n" ) + self.backupdirs + self.oktext, None)) - if config.usage.setup_level.index >= 2: # expert+ - self.list.append(("ipkg-manager", _("Packet management"), _("\nView, install and remove available or installed packages." ) + self.oktext, None)) - self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext, None)) - for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER): - if p.__call__.has_key("AdvancedSoftwareSupported"): - callFnc = p.__call__["AdvancedSoftwareSupported"](None) - if callFnc is not None: - if p.__call__.has_key("menuEntryName"): - menuEntryName = p.__call__["menuEntryName"](None) - else: - menuEntryName = _('Advanced Software') - if p.__call__.has_key("menuEntryDescription"): - menuEntryDescription = p.__call__["menuEntryDescription"](None) - else: - menuEntryDescription = _('Advanced Software Plugin') - self.list.append(('advanced-plugin', menuEntryName, menuEntryDescription + self.oktext, callFnc)) - - self["menu"] = List(self.list) - self["key_red"] = StaticText(_("Close")) - - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], - { - "ok": self.go, - "back": self.close, - "red": self.close, - }, -1) - - self.onLayoutFinish.append(self.layoutFinished) - self.backuppath = getBackupPath() - self.backupfile = getBackupFilename() - self.fullbackupfilename = self.backuppath + "/" + self.backupfile - self.onShown.append(self.setWindowTitle) - - def layoutFinished(self): - idx = 0 - self["menu"].index = idx - - def setWindowTitle(self): - self.setTitle(_("Software manager")) +from Wlan import Wlan, wpaSupplicant, iStatus - def go(self): - current = self["menu"].getCurrent() - if current: - currentEntry = current[0] - if self.menu == 0: - if (currentEntry == "software-update"): - self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to update your Dreambox?")+"\n"+_("\nAfter pressing OK, please wait!")) - elif (currentEntry == "software-restore"): - self.session.open(ImageWizard) - elif (currentEntry == "install-plugins"): - self.session.open(PluginManager, self.skin_path) - elif (currentEntry == "system-backup"): - self.session.openWithCallback(self.backupDone,BackupScreen, runBackup = True) - elif (currentEntry == "system-restore"): - if os_path.exists(self.fullbackupfilename): - self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore your Enigma2 backup?\nEnigma2 will restart after the restore")) - else: - self.session.open(MessageBox, _("Sorry no backups found!"), MessageBox.TYPE_INFO, timeout = 10) - elif (currentEntry == "ipkg-install"): - try: - from Plugins.Extensions.MediaScanner.plugin import main - main(self.session) - except: - self.session.open(MessageBox, _("Sorry MediaScanner is not installed!"), MessageBox.TYPE_INFO, timeout = 10) - elif (currentEntry == "default-plugin"): - self.extended = current[3] - self.extended(self.session, None) - elif (currentEntry == "advanced"): - self.session.open(UpdatePluginMenu, 1) - elif self.menu == 1: - if (currentEntry == "ipkg-manager"): - self.session.open(PacketManager, self.skin_path) - elif (currentEntry == "backuplocation"): - parts = [ (r.description, r.mountpoint, self.session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)] - for x in parts: - if not access(x[1], F_OK|R_OK|W_OK) or x[1] == '/': - parts.remove(x) - for x in parts: - if x[1].startswith('/autofs/'): - parts.remove(x) - if len(parts): - self.session.openWithCallback(self.backuplocation_choosen, ChoiceBox, title = _("Please select medium to use as backup location"), list = parts) - elif (currentEntry == "backupfiles"): - self.session.openWithCallback(self.backupfiles_choosen,BackupSelection) - elif (currentEntry == "advancedrestore"): - self.session.open(RestoreMenu, self.skin_path) - elif (currentEntry == "ipkg-source"): - self.session.open(IPKGMenu, self.skin_path) - elif (currentEntry == "advanced-plugin"): - self.extended = current[3] - self.extended(self.session, None) +plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan" - def backupfiles_choosen(self, ret): - self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) +list = [] +list.append("WEP") +list.append("WPA") +list.append("WPA2") +list.append("WPA/WPA2") - def backuplocation_choosen(self, option): - if option is not None: - config.plugins.configurationbackup.backuplocation.value = str(option[1]) - config.plugins.configurationbackup.backuplocation.save() - config.plugins.configurationbackup.save() - config.save() - self.createBackupfolders() +weplist = [] +weplist.append("ASCII") +weplist.append("HEX") - def runUpgrade(self, result): - if result: - self.session.open(UpdatePlugin, self.skin_path) +config.plugins.wlan = ConfigSubsection() +config.plugins.wlan.essid = NoSave(ConfigText(default = "home", fixed_size = False)) +config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = "home", fixed_size = False)) - def createBackupfolders(self): - print "Creating backup folder if not already there..." - self.backuppath = getBackupPath() - try: - if (os_path.exists(self.backuppath) == False): - makedirs(self.backuppath) - except OSError: - self.session.open(MessageBox, _("Sorry, your backup destination is not writeable.\n\nPlease choose another one."), MessageBox.TYPE_INFO, timeout = 10) +config.plugins.wlan.encryption = ConfigSubsection() +config.plugins.wlan.encryption.enabled = NoSave(ConfigYesNo(default = False)) +config.plugins.wlan.encryption.type = NoSave(ConfigSelection(list, default = "WPA/WPA2" )) +config.plugins.wlan.encryption.wepkeytype = NoSave(ConfigSelection(weplist, default = "ASCII")) +config.plugins.wlan.encryption.psk = NoSave(ConfigPassword(default = "mysecurewlan", fixed_size = False)) - def backupDone(self,retval = None): - if retval is True: - self.session.open(MessageBox, _("Backup done."), MessageBox.TYPE_INFO, timeout = 10) - else: - self.session.open(MessageBox, _("Backup failed."), MessageBox.TYPE_INFO, timeout = 10) - - def startRestore(self, ret = False): - if (ret == True): - self.exe = True - self.session.open(RestoreScreen, runRestore = True) -class IPKGMenu(Screen): +class WlanStatus(Screen): skin = """ - + - - - - """ - - def __init__(self, session, plugin_path): - Screen.__init__(self, session) - self.skin_path = plugin_path - - self["key_red"] = StaticText(_("Close")) - self["key_green"] = StaticText(_("Edit")) - - self.sel = [] - self.val = [] - self.entry = False - self.exe = False - - self.path = "" - - self["actions"] = NumberActionMap(["SetupActions"], - { - "ok": self.KeyOk, - "cancel": self.keyCancel - }, -1) - - self["shortcuts"] = ActionMap(["ShortcutActions"], - { - "red": self.keyCancel, - "green": self.KeyOk, - }) - self.flist = [] - self["filelist"] = MenuList(self.flist) - self.fill_list() - self.onLayoutFinish.append(self.layoutFinished) - - def layoutFinished(self): - self.setWindowTitle() - - def setWindowTitle(self): - self.setTitle(_("Select upgrade source to edit.")) - - def fill_list(self): - self.flist = [] - self.path = '/etc/ipkg/' - if (os_path.exists(self.path) == False): - self.entry = False - return - for file in listdir(self.path): - if (file.endswith(".conf")): - if file != 'arch.conf': - self.flist.append((file)) - self.entry = True - self["filelist"].l.setList(self.flist) - - def KeyOk(self): - if (self.exe == False) and (self.entry == True): - self.sel = self["filelist"].getCurrent() - self.val = self.path + self.sel - self.session.open(IPKGSource, self.val) - - def keyCancel(self): - self.close() - - def Exit(self): - self.close() - - -class IPKGSource(Screen): - skin = """ - - - - - - - """ - - def __init__(self, session, configfile = None): - Screen.__init__(self, session) - self.session = session - self.configfile = configfile - text = "" - if self.configfile: - try: - fp = file(configfile, 'r') - sources = fp.readlines() - if sources: - text = sources[0] - fp.close() - except IOError: - pass - - desk = getDesktop(0) - x= int(desk.size().width()) - y= int(desk.size().height()) - - self["key_red"] = StaticText(_("Cancel")) - self["key_green"] = StaticText(_("Save")) - - if (y>=720): - self["text"] = Input(text, maxSize=False, type=Input.TEXT) - else: - self["text"] = Input(text, maxSize=False, visible_width = 55, type=Input.TEXT) - - self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"], - { - "ok": self.go, - "back": self.close, - "red": self.close, - "green": self.go, - "left": self.keyLeft, - "right": self.keyRight, - "home": self.keyHome, - "end": self.keyEnd, - "deleteForward": self.keyDeleteForward, - "deleteBackward": self.keyDeleteBackward, - "1": self.keyNumberGlobal, - "2": self.keyNumberGlobal, - "3": self.keyNumberGlobal, - "4": self.keyNumberGlobal, - "5": self.keyNumberGlobal, - "6": self.keyNumberGlobal, - "7": self.keyNumberGlobal, - "8": self.keyNumberGlobal, - "9": self.keyNumberGlobal, - "0": self.keyNumberGlobal - }, -1) - - self.onLayoutFinish.append(self.layoutFinished) - - def layoutFinished(self): - self.setWindowTitle() - self["text"].right() - - def setWindowTitle(self): - self.setTitle(_("Edit upgrade source url.")) - - def go(self): - text = self["text"].getText() - if text: - fp = file(self.configfile, 'w') - fp.write(text) - fp.write("\n") - fp.close() - self.close() - - def keyLeft(self): - self["text"].left() - - def keyRight(self): - self["text"].right() - def keyHome(self): - self["text"].home() - - def keyEnd(self): - self["text"].end() - - def keyDeleteForward(self): - self["text"].delete() - - def keyDeleteBackward(self): - self["text"].deleteBackward() + + + + + + + + + + + + + - def keyNumberGlobal(self, number): - self["text"].number(number) - - -class PacketManager(Screen): - skin = """ - - - - - - - - {"template": [ - MultiContentEntryText(pos = (5, 1), size = (440, 28), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (5, 26), size = (440, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description - MultiContentEntryPixmapAlphaTest(pos = (445, 2), size = (48, 48), png = 4), # index 4 is the status pixmap - MultiContentEntryPixmapAlphaTest(pos = (5, 50), size = (510, 2), png = 5), # index 4 is the div pixmap - ], - "fonts": [gFont("Regular", 22),gFont("Regular", 14)], - "itemHeight": 52 - } - - + + + + + """ - - def __init__(self, session, plugin_path, args = None): + + def __init__(self, session, iface): Screen.__init__(self, session) self.session = session - self.skin_path = plugin_path - - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], - { - "ok": self.go, - "back": self.exit, - "red": self.exit, - "green": self.reload, - }, -1) - - self.list = [] - self.statuslist = [] - self["list"] = List(self.list) - self["key_red"] = StaticText(_("Close")) - self["key_green"] = StaticText(_("Reload")) - - self.list_updating = True - self.packetlist = [] - self.installed_packetlist = {} - self.Console = Console() - self.cmdList = [] - self.cachelist = [] - self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid (24h should be ok for caching ipkgs) - self.cache_file = '/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/packetmanager.cache' #Path to cache directory - self.oktext = _("\nAfter pressing OK, please wait!") - self.unwanted_extensions = ('-dbg', '-dev', '-doc', 'busybox') - - self.ipkg = IpkgComponent() - self.ipkg.addCallback(self.ipkgCallback) - self.onShown.append(self.setWindowTitle) - self.onLayoutFinish.append(self.rebuildList) - - def exit(self): - self.ipkg.stop() - if self.Console is not None: - if len(self.Console.appContainers): - for name in self.Console.appContainers.keys(): - self.Console.kill(name) - self.close() - - def reload(self): - if (os_path.exists(self.cache_file) == True): - remove(self.cache_file) - self.list_updating = True - self.rebuildList() + self.iface = iface + + self["LabelBSSID"] = StaticText(_('Accesspoint:')) + self["LabelESSID"] = StaticText(_('SSID:')) + self["LabelQuality"] = StaticText(_('Link Quality:')) + self["LabelSignal"] = StaticText(_('Signal Strength:')) + self["LabelBitrate"] = StaticText(_('Bitrate:')) + self["LabelEnc"] = StaticText(_('Encryption:')) - def setWindowTitle(self): - self.setTitle(_("Packet manager")) - - def setStatus(self,status = None): - if status: - self.statuslist = [] - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) - if status == 'update': - statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) - self.statuslist.append(( _("Package list update"), '', _("Trying to download a new packetlist. Please wait..." ),'',statuspng, divpng )) - self['list'].setList(self.statuslist) - elif status == 'error': - 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 )) - self['list'].setList(self.statuslist) - - def rebuildList(self): - self.setStatus('update') - self.inv_cache = 0 - self.vc = valid_cache(self.cache_file, self.cache_ttl) - if self.cache_ttl > 0 and self.vc != 0: - try: - self.buildPacketList() - except: - self.inv_cache = 1 - if self.cache_ttl == 0 or self.inv_cache == 1 or self.vc == 0: - self.run = 0 - self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) - - def go(self, returnValue = None): - cur = self["list"].getCurrent() - if cur: - status = cur[3] - package = cur[0] - self.cmdList = [] - if status == 'installed': - self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package })) - if len(self.cmdList): - self.session.openWithCallback(self.runRemove, MessageBox, _("Do you want to remove the package:\n") + package + "\n" + self.oktext) - elif status == 'upgradeable': - self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package })) - if len(self.cmdList): - self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to upgrade the package:\n") + package + "\n" + self.oktext) - elif status == "installable": - self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package })) - if len(self.cmdList): - self.session.openWithCallback(self.runUpgrade, MessageBox, _("Do you want to install the package:\n") + package + "\n" + self.oktext) - - def runRemove(self, result): - if result: - self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList) - - def runRemoveFinished(self): - self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) - - def RemoveReboot(self, result): - if result is None: - return - if result is False: - cur = self["list"].getCurrent() - if cur: - item = self['list'].getIndex() - self.list[item] = self.buildEntryComponent(cur[0], cur[1], cur[2], 'installable') - self.cachelist[item] = [cur[0], cur[1], cur[2], 'installable'] - self['list'].setList(self.list) - write_cache(self.cache_file, self.cachelist) - self.reloadPluginlist() - if result: - quitMainloop(3) - - def runUpgrade(self, result): - if result: - self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList) + self["BSSID"] = StaticText() + self["ESSID"] = StaticText() + self["quality"] = StaticText() + self["signal"] = StaticText() + self["bitrate"] = StaticText() + self["enc"] = StaticText() + + self["IFtext"] = StaticText() + self["IF"] = StaticText() + self["Statustext"] = StaticText() + self["statuspic"] = MultiPixmap() + self["statuspic"].hide() + self["key_red"] = StaticText(_("Close")) - def runUpgradeFinished(self): - self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) + self.resetList() + self.updateStatusbar() - def UpgradeReboot(self, result): - if result is None: - return - if result is False: - cur = self["list"].getCurrent() - if cur: - item = self['list'].getIndex() - self.list[item] = self.buildEntryComponent(cur[0], cur[1], cur[2], 'installed') - self.cachelist[item] = [cur[0], cur[1], cur[2], 'installed'] - self['list'].setList(self.list) - write_cache(self.cache_file, self.cachelist) - self.reloadPluginlist() - if result: - quitMainloop(3) - - def ipkgCallback(self, event, param): - if event == IpkgComponent.EVENT_ERROR: - self.list_updating = False - self.setStatus('error') - elif event == IpkgComponent.EVENT_DONE: - if self.list_updating: - self.list_updating = False - if not self.Console: - self.Console = Console() - cmd = "ipkg list" - self.Console.ePopen(cmd, self.IpkgList_Finished) - #print event, "-", param - pass - - def IpkgList_Finished(self, result, retval, extra_args = None): - if len(result): - self.packetlist = [] - for x in result.splitlines(): - split = x.split(' - ') #self.blacklisted_packages - if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): - self.packetlist.append([split[0].strip(), split[1].strip(),split[2].strip()]) - if not self.Console: - self.Console = Console() - cmd = "ipkg list_installed" - self.Console.ePopen(cmd, self.IpkgListInstalled_Finished) - - def IpkgListInstalled_Finished(self, result, retval, extra_args = None): - if len(result): - self.installed_packetlist = {} - for x in result.splitlines(): - split = x.split(' - ') - if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): - self.installed_packetlist[split[0].strip()] = split[1].strip() - self.buildPacketList() - - def buildEntryComponent(self, name, version, description, state): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) - if state == 'installed': - installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) - return((name, version, description, state, installedpng, divpng)) - elif state == 'upgradeable': - upgradeablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgradeable.png")) - return((name, version, description, state, upgradeablepng, divpng)) - else: - installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) - return((name, version, description, state, installablepng, divpng)) - - def buildPacketList(self): - self.list = [] - self.cachelist = [] - - if self.cache_ttl > 0 and self.vc != 0: - print 'Loading packagelist cache from ',self.cache_file - try: - self.cachelist = load_cache(self.cache_file) - if len(self.cachelist) > 0: - for x in self.cachelist: - self.list.append(self.buildEntryComponent(x[0], x[1], x[2], x[3])) - self['list'].setList(self.list) - except: - self.inv_cache = 1 - - if self.cache_ttl == 0 or self.inv_cache == 1 or self.vc == 0: - print 'rebuilding fresh package list' - for x in self.packetlist: - status = "" - if self.installed_packetlist.has_key(x[0].strip()): - if self.installed_packetlist[x[0].strip()] == x[1].strip(): - status = "installed" - self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status)) - else: - status = "upgradeable" - self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status)) - else: - status = "installable" - self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), status)) - if not any(x[0].strip().endswith(x) for x in self.unwanted_extensions): - self.cachelist.append([x[0].strip(), x[1].strip(), x[2].strip(), status]) - write_cache(self.cache_file, self.cachelist) - self['list'].setList(self.list) - - def reloadPluginlist(self): - plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) - - -class PluginManager(Screen, DreamInfoHandler): - - lastDownloadDate = None - - skin = """ - - - - - - - - - - - - {"templates": - {"default": (51,[ - MultiContentEntryText(pos = (30, 1), size = (470, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (30, 25), size = (470, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description - MultiContentEntryPixmapAlphaTest(pos = (475, 0), size = (48, 48), png = 5), # index 5 is the status pixmap - MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 6), # index 6 is the div pixmap - ]), - "category": (40,[ - MultiContentEntryText(pos = (30, 0), size = (500, 22), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (30, 22), size = (500, 16), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the description - MultiContentEntryPixmapAlphaTest(pos = (0, 38), size = (550, 2), png = 3), # index 3 is the div pixmap - ]) - }, - "fonts": [gFont("Regular", 22),gFont("Regular", 16)], - "itemHeight": 52 - } - - - - """ - - def __init__(self, session, plugin_path, args = None): - Screen.__init__(self, session) - self.session = session - self.skin_path = plugin_path - aboutInfo = about.getImageVersionString() - if aboutInfo.startswith("dev-"): - self.ImageVersion = 'Experimental' - else: - self.ImageVersion = 'Stable' - self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" - - DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, neededTag = 'ALL_TAGS', neededFlag = self.ImageVersion, language = self.language) - self.directory = resolveFilename(SCOPE_METADIR) - - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions", "InfobarEPGActions", "HelpActions" ], + self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions", "ShortcutActions"], { - "ok": self.handleCurrent, + "ok": self.exit, "back": self.exit, "red": self.exit, - "green": self.handleCurrent, - "yellow": self.handleSelected, - "showEventInfo": self.handleSelected, - "displayHelp": self.handleHelp, }, -1) + self.timer = eTimer() + self.timer.timeout.get().append(self.resetList) + self.onShown.append(lambda: self.timer.start(5000)) + self.onLayoutFinish.append(self.layoutFinished) + self.onClose.append(self.cleanup) - self.list = [] - self.statuslist = [] - self.selectedFiles = [] - self.categoryList = [] - self["list"] = List(self.list) - self["key_red"] = StaticText(_("Close")) - self["key_green"] = StaticText("") - self["key_yellow"] = StaticText("") - self["key_blue"] = StaticText("") - self["status"] = StaticText("") - - self.list_updating = True - self.packetlist = [] - self.installed_packetlist = {} - self.available_packetlist = [] - self.available_updates = 0 - self.Console = Console() - self.cmdList = [] - self.oktext = _("\nAfter pressing OK, please wait!") - self.unwanted_extensions = ('-dbg', '-dev', '-doc') - - self.ipkg = IpkgComponent() - self.ipkg.addCallback(self.ipkgCallback) - if not self.selectionChanged in self["list"].onSelectionChanged: - self["list"].onSelectionChanged.append(self.selectionChanged) - - self.currList = "" - self.currentSelectedTag = None - self.currentSelectedIndex = None - - self.onShown.append(self.setWindowTitle) - self.onLayoutFinish.append(self.rebuildList) - - def setWindowTitle(self): - self.setTitle(_("Plugin manager")) + def cleanup(self): + iStatus.stopWlanConsole() + + def layoutFinished(self): + self.setTitle(_("Wireless Network State")) + + def resetList(self): + iStatus.getDataForInterface(self.iface,self.getInfoCB) + + def getInfoCB(self,data,status): + if data is not None: + if data is True: + if status is not None: + self["BSSID"].setText(status[self.iface]["acesspoint"]) + self["ESSID"].setText(status[self.iface]["essid"]) + self["quality"].setText(status[self.iface]["quality"]+"%") + self["signal"].setText(status[self.iface]["signal"]) + self["bitrate"].setText(status[self.iface]["bitrate"]) + self["enc"].setText(status[self.iface]["encryption"]) + self.updateStatusLink(status) def exit(self): - if self.currList == "packages": - self.currList = "category" - self.currentSelectedTag = None - self["list"].style = "category" - self['list'].setList(self.categoryList) - self["list"].setIndex(self.currentSelectedIndex) - self["list"].updateList(self.categoryList) - self.selectionChanged() - else: - self.ipkg.stop() - if self.Console is not None: - if len(self.Console.appContainers): - for name in self.Console.appContainers.keys(): - self.Console.kill(name) - self.prepareInstall() - if len(self.cmdList): - self.session.openWithCallback(self.runExecute, PluginManagerInfo, self.skin_path, self.cmdList) + self.timer.stop() + self.close(True) + + def updateStatusbar(self): + self["BSSID"].setText(_("Please wait...")) + self["ESSID"].setText(_("Please wait...")) + self["quality"].setText(_("Please wait...")) + self["signal"].setText(_("Please wait...")) + self["bitrate"].setText(_("Please wait...")) + self["enc"].setText(_("Please wait...")) + self["IFtext"].setText(_("Network:")) + self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface)) + self["Statustext"].setText(_("Link:")) + + def updateStatusLink(self,status): + if status is not None: + if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False: + self["statuspic"].setPixmapNum(1) else: - self.close() - - def handleHelp(self): - if self.currList != "status": - self.session.open(PluginManagerHelp, self.skin_path) - - def setState(self,status = None): - if status: - self.currList = "status" - self.statuslist = [] - self["key_green"].setText("") - self["key_blue"].setText("") - self["key_yellow"].setText("") - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) - if status == 'update': - statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) - self.statuslist.append(( _("Package list update"), '', _("Trying to download a new packetlist. Please wait..." ),'', '', statuspng, divpng, None, '' )) - self["list"].style = "default" - self['list'].setList(self.statuslist) - elif status == 'sync': - 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, '' )) - self["list"].style = "default" - self['list'].setList(self.statuslist) - elif status == 'error': - 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" - self['list'].setList(self.statuslist) - - def statusCallback(self, status, progress): - pass + self["statuspic"].setPixmapNum(0) + self["statuspic"].show() - def selectionChanged(self): - current = self["list"].getCurrent() - self["status"].setText("") - if current: - if self.currList == "packages": - self["key_red"].setText(_("Back")) - if current[4] == 'installed': - self["key_green"].setText(_("Remove")) - elif current[4] == 'installable': - self["key_green"].setText(_("Install")) - elif current[4] == 'remove': - self["key_green"].setText(_("Undo\nRemove")) - elif current[4] == 'install': - self["key_green"].setText(_("Undo\nInstall")) - self["key_yellow"].setText(_("View details")) - self["key_blue"].setText("") - if len(self.selectedFiles) == 0 and self.available_updates is not 0: - self["status"].setText(_("There are at least ") + str(self.available_updates) + _(" updates available.")) - elif len(self.selectedFiles) is not 0: - self["status"].setText(str(len(self.selectedFiles)) + _(" packages selected.")) - else: - self["status"].setText(_("There is nothing to be done.")) - elif self.currList == "category": - self["key_red"].setText(_("Close")) - self["key_green"].setText("") - self["key_yellow"].setText("") - self["key_blue"].setText("") - if len(self.selectedFiles) == 0 and self.available_updates is not 0: - self["status"].setText(_("There are at least ") + str(self.available_updates) + _(" updates available.")) - self["key_yellow"].setText(_("Update")) - elif len(self.selectedFiles) is not 0: - self["status"].setText(str(len(self.selectedFiles)) + _(" packages selected.")) - self["key_yellow"].setText(_("Process")) - else: - self["status"].setText(_("There is nothing to be done.")) - - def getSelectionState(self, detailsFile): - for entry in self.selectedFiles: - if entry[0] == detailsFile: - return True - return False - - def rebuildList(self): - self.setState('update') - if not PluginManager.lastDownloadDate or (time() - PluginManager.lastDownloadDate) > 3600: - # Only update from internet once per hour - PluginManager.lastDownloadDate = time() - print "last update time > 1h" - self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) - else: - print "last update time < 1h" - self.startIpkgList() - - def ipkgCallback(self, event, param): - if event == IpkgComponent.EVENT_ERROR: - self.list_updating = False - self.setState('error') - elif event == IpkgComponent.EVENT_DONE: - self.startIpkgList() - pass - - def startIpkgList(self): - if self.list_updating: - if not self.Console: - self.Console = Console() - cmd = "ipkg list" - self.Console.ePopen(cmd, self.IpkgList_Finished) - - def IpkgList_Finished(self, result, retval, extra_args = None): - if len(result): - self.available_packetlist = [] - for x in result.splitlines(): - split = x.split(' - ') - if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): - self.available_packetlist.append([split[0].strip(), split[1].strip(), split[2].strip()]) - self.startInstallMetaPackage() - - def startInstallMetaPackage(self): - if self.list_updating: - self.list_updating = False - if not self.Console: - self.Console = Console() - cmd = "ipkg install enigma2-meta enigma2-plugins-meta enigma2-skins-meta" - self.Console.ePopen(cmd, self.InstallMetaPackage_Finished) - - def InstallMetaPackage_Finished(self, result, retval, extra_args = None): - if len(result): - self.fillPackagesIndexList() - if not self.Console: - self.Console = Console() - self.setState('sync') - cmd = "ipkg list_installed" - self.Console.ePopen(cmd, self.IpkgListInstalled_Finished) - - def IpkgListInstalled_Finished(self, result, retval, extra_args = None): - if len(result): - self.installed_packetlist = {} - for x in result.splitlines(): - split = x.split(' - ') - if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): - self.installed_packetlist[split[0].strip()] = split[1].strip() - self.countUpdates() - if self.currentSelectedTag is None: - self.buildCategoryList() - else: - self.buildPacketList(self.currentSelectedTag) - - def countUpdates(self): - self.available_updates = 0 - for package in self.packagesIndexlist[:]: - attributes = package[0]["attributes"] - packagename = attributes["packagename"] - for x in self.available_packetlist: - if x[0].strip() == packagename: - if self.installed_packetlist.has_key(packagename): - if self.installed_packetlist[packagename] != x[1].strip(): - self.available_updates +=1 - - def handleCurrent(self): - current = self["list"].getCurrent() - if current: - if self.currList == "category": - self.currentSelectedIndex = self["list"].index - selectedTag = current[2] - self.buildPacketList(selectedTag) - elif self.currList == "packages": - if current[7] is not '': - idx = self["list"].getIndex() - detailsFile = self.list[idx][1] - if self.list[idx][7] == True: - for entry in self.selectedFiles: - if entry[0] == detailsFile: - self.selectedFiles.remove(entry) - else: - alreadyinList = False - for entry in self.selectedFiles: - if entry[0] == detailsFile: - alreadyinList = True - if not alreadyinList: - self.selectedFiles.append((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) - 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) - self["list"].setList(self.list) - self["list"].setIndex(idx) - self["list"].updateList(self.list) - self.selectionChanged() - - def handleSelected(self): - current = self["list"].getCurrent() - if current: - if self.currList == "packages": - if current[7] is not '': - detailsfile = self.directory[0] + "/" + current[1] - if (os_path.exists(detailsfile) == True): - self.session.openWithCallback(self.detailsClosed, PluginDetails, self.skin_path, current) - else: - self.session.open(MessageBox, _("Sorry, no Details available!"), MessageBox.TYPE_INFO, timeout = 10) - elif self.currList == "category": - self.prepareInstall() - if len(self.cmdList): - self.session.openWithCallback(self.runExecute, PluginManagerInfo, self.skin_path, self.cmdList) - - def detailsClosed(self, result): - if result: - if not self.Console: - self.Console = Console() - self.setState('sync') - PluginManager.lastDownloadDate = time() - self.selectedFiles = [] - cmd = "ipkg update" - self.Console.ePopen(cmd, self.InstallMetaPackage_Finished) - - def buildEntryComponent(self, name, details, description, packagename, state, selected = False): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) - if state == 'installed': - installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) - return((name, details, description, packagename, state, installedpng, divpng, selected)) - elif state == 'installable': - installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) - return((name, details, description, packagename, state, installablepng, divpng, selected)) - elif state == 'remove': - removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) - return((name, details, description, packagename, state, removepng, divpng, selected)) - elif state == 'install': - installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) - return((name, details, description, packagename, state, installpng, divpng, selected)) - - def buildPacketList(self, categorytag = None): - if categorytag is not None: - self.currList = "packages" - self.currentSelectedTag = categorytag - self.packetlist = [] - for package in self.packagesIndexlist[:]: - prerequisites = package[0]["prerequisites"] - if prerequisites.has_key("tag"): - for foundtag in prerequisites["tag"]: - if categorytag == foundtag: - attributes = package[0]["attributes"] - if attributes.has_key("packagetype"): - if attributes["packagetype"] == "internal": - continue - self.packetlist.append([attributes["name"], attributes["details"], attributes["shortdescription"], attributes["packagename"]]) - else: - self.packetlist.append([attributes["name"], attributes["details"], attributes["shortdescription"], attributes["packagename"]]) - self.list = [] - for x in self.packetlist: - status = "" - selectState = self.getSelectionState(x[1].strip()) - if self.installed_packetlist.has_key(x[3].strip()): - if selectState == True: - status = "remove" - else: - status = "installed" - self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = selectState)) - else: - if selectState == True: - status = "install" - else: - status = "installable" - self.list.append(self.buildEntryComponent(x[0].strip(), x[1].strip(), x[2].strip(), x[3].strip(), status, selected = selectState)) - if len(self.list): - self.list.sort(key=lambda x: x[0]) - self["list"].style = "default" - self['list'].setList(self.list) - self["list"].updateList(self.list) - self.selectionChanged() - - def buildCategoryList(self): - self.currList = "category" - self.categories = [] - self.categoryList = [] - for package in self.packagesIndexlist[:]: - prerequisites = package[0]["prerequisites"] - if prerequisites.has_key("tag"): - for foundtag in prerequisites["tag"]: - attributes = package[0]["attributes"] - if foundtag not in self.categories: - self.categories.append(foundtag) - self.categoryList.append(self.buildCategoryComponent(foundtag)) - self.categoryList.sort(key=lambda x: x[0]) - self["list"].style = "category" - self['list'].setList(self.categoryList) - self["list"].updateList(self.categoryList) - self.selectionChanged() - - def buildCategoryComponent(self, tag = None): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) - if tag is not None: - if tag == 'System': - return(( _("System"), _("View list of available system extensions" ), tag, divpng )) - elif tag == 'Skin': - return(( _("Skins"), _("View list of available skins" ), tag, divpng )) - elif tag == 'Recording': - return(( _("Recordings"), _("View list of available recording extensions" ), tag, divpng )) - elif tag == 'Network': - return(( _("Network"), _("View list of available networking extensions" ), tag, divpng )) - elif tag == 'CI': - return(( _("CommonInterface"), _("View list of available CommonInterface extensions" ), tag, divpng )) - elif tag == 'Default': - return(( _("Default Settings"), _("View list of available default settings" ), tag, divpng )) - elif tag == 'SAT': - return(( _("Satteliteequipment"), _("View list of available Satteliteequipment extensions." ), tag, divpng )) - elif tag == 'Software': - return(( _("Software"), _("View list of available software extensions" ), tag, divpng )) - elif tag == 'Multimedia': - return(( _("Multimedia"), _("View list of available multimedia extensions." ), tag, divpng )) - elif tag == 'Display': - return(( _("Display and Userinterface"), _("View list of available Display and Userinterface extensions." ), tag, divpng )) - elif tag == 'EPG': - return(( _("Electronic Program Guide"), _("View list of available EPG extensions." ), tag, divpng )) - elif tag == 'Communication': - return(( _("Communication"), _("View list of available communication extensions." ), tag, divpng )) - else: # dynamically generate non existent tags - return(( str(tag), _("View list of available ") + str(tag) + _(" extensions." ), tag, divpng )) - - def prepareInstall(self): - self.cmdList = [] - if self.available_updates > 0: - self.cmdList.append((IpkgComponent.CMD_UPGRADE, { "test_only": False })) - if self.selectedFiles and len(self.selectedFiles): - for plugin in self.selectedFiles: - detailsfile = self.directory[0] + "/" + plugin[0] - if (os_path.exists(detailsfile) == True): - self.fillPackageDetails(plugin[0]) - self.package = self.packageDetails[0] - if self.package[0].has_key("attributes"): - self.attributes = self.package[0]["attributes"] - if self.attributes.has_key("package"): - self.packagefiles = self.attributes["package"] - if plugin[1] == 'installed': - if self.packagefiles: - for package in self.packagefiles[:]: - self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package["name"] })) - else: - self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": plugin[2] })) - else: - if self.packagefiles: - for package in self.packagefiles[:]: - self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": package["name"] })) - else: - self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": plugin[2] })) - else: - if plugin[1] == 'installed': - self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": plugin[2] })) - else: - self.cmdList.append((IpkgComponent.CMD_INSTALL, { "package": plugin[2] })) - - def runExecute(self, result): - if result: - self.session.openWithCallback(self.runExecuteFinished, Ipkg, cmdList = self.cmdList) - else: - self.close() - - def runExecuteFinished(self): - self.session.openWithCallback(self.ExecuteReboot, MessageBox, _("Install or remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) - - def ExecuteReboot(self, result): - if result is None: - return - if result is False: - self.reloadPluginlist() - self.detailsClosed(True) - if result: - quitMainloop(3) - - def reloadPluginlist(self): - plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) - - -class PluginManagerInfo(Screen): +class WlanScan(Screen): skin = """ - + + - - - {"template": [ - MultiContentEntryText(pos = (50, 1), size = (150, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (50, 25), size = (540, 24), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the state - MultiContentEntryPixmapAlphaTest(pos = (0, 1), size = (48, 48), png = 2), # index 2 is the status pixmap - MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 3), # index 3 is the div pixmap - ], - "fonts": [gFont("Regular", 22),gFont("Regular", 18)], - "itemHeight": 52 - } - - - - - """ - - def __init__(self, session, plugin_path, cmdlist = None): - Screen.__init__(self, session) - self.session = session - self.skin_path = plugin_path - self.cmdlist = cmdlist - - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], - { - "ok": self.process, - "back": self.exit, - "red": self.exit, - "green": self.process, - }, -1) - - self.list = [] - self["list"] = List(self.list) - self["key_red"] = StaticText(_("Cancel")) - self["key_green"] = StaticText(_("Continue")) - self["status"] = StaticText(_("Following tasks will be done after you press continue!")) - - self.onShown.append(self.setWindowTitle) - self.onLayoutFinish.append(self.rebuildList) - - def setWindowTitle(self): - self.setTitle(_("Plugin manager activity information")) - - def rebuildList(self): - self.list = [] - if self.cmdlist is not None: - for entry in self.cmdlist: - action = "" - info = "" - cmd = entry[0] - if cmd == 0: - action = 'install' - elif cmd == 2: - action = 'remove' - else: - action = 'upgrade' - args = entry[1] - if cmd == 0: - info = args['package'] - elif cmd == 2: - info = args['package'] - else: - info = _("Dreambox software because updates are available.") - - self.list.append(self.buildEntryComponent(action,info)) - self['list'].setList(self.list) - self['list'].updateList(self.list) - - def buildEntryComponent(self, action,info): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) - upgradepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) - installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) - removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) - if action == 'install': - return(( _('Installing'), info, installpng, divpng)) - elif action == 'remove': - return(( _('Removing'), info, removepng, divpng)) - else: - return(( _('Upgrading'), info, upgradepng, divpng)) - - def exit(self): - self.close(False) - - def process(self): - self.close(True) - - -class PluginManagerHelp(Screen): - skin = """ - - - - + + {"template": [ - MultiContentEntryText(pos = (50, 1), size = (540, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (50, 25), size = (540, 24), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the state - MultiContentEntryPixmapAlphaTest(pos = (0, 1), size = (48, 48), png = 2), # index 2 is the status pixmap - MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 3), # index 3 is the div pixmap + MultiContentEntryText(pos = (0, 0), size = (550, 30), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the essid + MultiContentEntryText(pos = (0, 30), size = (175, 20), font=1, flags = RT_HALIGN_LEFT, text = 5), # index 5 is the interface + MultiContentEntryText(pos = (175, 30), size = (175, 20), font=1, flags = RT_HALIGN_LEFT, text = 4), # index 0 is the encryption + MultiContentEntryText(pos = (350, 0), size = (200, 20), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 0 is the signal + MultiContentEntryText(pos = (350, 30), size = (200, 20), font=1, flags = RT_HALIGN_LEFT, text = 3), # index 0 is the maxrate + MultiContentEntryPixmapAlphaTest(pos = (0, 52), size = (550, 2), png = 6), # index 6 is the div pixmap ], - "fonts": [gFont("Regular", 22),gFont("Regular", 18)], - "itemHeight": 52 + "fonts": [gFont("Regular", 28),gFont("Regular", 18)], + "itemHeight": 54 } - - + + """ - def __init__(self, session, plugin_path): + def __init__(self, session, iface): Screen.__init__(self, session) self.session = session + self.iface = iface self.skin_path = plugin_path - - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], - { - "back": self.exit, - "red": self.exit, - }, -1) - + self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") + self.APList = None + self.newAPList = None + self.WlanList = None + self.cleanList = None + self.oldlist = None + self.listLenght = None + self.rescanTimer = eTimer() + self.rescanTimer.callback.append(self.rescanTimerFired) + + self["info"] = StaticText() + self.list = [] self["list"] = List(self.list) + self["key_red"] = StaticText(_("Close")) - self["status"] = StaticText(_("A small overview of the available icon states and actions.")) - - self.onShown.append(self.setWindowTitle) - self.onLayoutFinish.append(self.rebuildList) - - def setWindowTitle(self): - self.setTitle(_("Plugin manager help")) - - def rebuildList(self): - self.list = [] - self.list.append(self.buildEntryComponent('install')) - self.list.append(self.buildEntryComponent('installable')) - self.list.append(self.buildEntryComponent('installed')) - self.list.append(self.buildEntryComponent('remove')) - self['list'].setList(self.list) - self['list'].updateList(self.list) - - def buildEntryComponent(self, state): - divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png")) - installedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installed.png")) - installablepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/installable.png")) - removepng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/remove.png")) - installpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/install.png")) - - if state == 'installed': - return(( _('This plugin is installed.'), _('You can remove this plugin.'), installedpng, divpng)) - elif state == 'installable': - return(( _('This plugin is not installed.'), _('You can install this plugin.'), installablepng, divpng)) - elif state == 'install': - return(( _('This plugin will be installed.'), _('You can cancel the installation.'), installpng, divpng)) - elif state == 'remove': - return(( _('This plugin will be removed.'), _('You can cancel the removal.'), removepng, divpng)) - - def exit(self): - self.close() - - -class PluginDetails(Screen, DreamInfoHandler): - skin = """ - - - - - - - - - - - """ - def __init__(self, session, plugin_path, packagedata = None): - Screen.__init__(self, session) - self.skin_path = plugin_path - self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" - self.attributes = None - self.translatedAttributes = None - DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, language = self.language) - self.directory = resolveFilename(SCOPE_METADIR) - if packagedata: - self.pluginname = packagedata[0] - self.details = packagedata[1] - self.pluginstate = packagedata[4] - self.statuspicinstance = packagedata[5] - self.divpicinstance = packagedata[6] - self.fillPackageDetails(self.details) - - self.thumbnail = "" - - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + self["key_green"] = StaticText(_("Connect")) + self["key_yellow"] = StaticText() + + self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"], { - "back": self.exit, - "red": self.exit, - "green": self.go, - "up": self.pageUp, - "down": self.pageDown, - "left": self.pageUp, - "right": self.pageDown, + "ok": self.select, + "back": self.cancel, }, -1) - - self["key_red"] = StaticText(_("Close")) - self["key_green"] = StaticText("") - self["author"] = StaticText() - self["statuspic"] = Pixmap() - self["divpic"] = Pixmap() - self["screenshot"] = Pixmap() - self["detailtext"] = ScrollLabel() - - self["statuspic"].hide() - self["screenshot"].hide() - self["divpic"].hide() - - self.package = self.packageDetails[0] - if self.package[0].has_key("attributes"): - self.attributes = self.package[0]["attributes"] - if self.package[0].has_key("translation"): - self.translatedAttributes = self.package[0]["translation"] - - self.cmdList = [] - self.oktext = _("\nAfter pressing OK, please wait!") - self.picload = ePicLoad() - self.picload.PictureData.get().append(self.paintScreenshotPixmapCB) - self.onShown.append(self.setWindowTitle) - self.onLayoutFinish.append(self.setInfos) - - def setWindowTitle(self): - self.setTitle(_("Package details for: " + self.pluginname)) - - def exit(self): - self.close(False) - - def pageUp(self): - self["detailtext"].pageUp() - - def pageDown(self): - self["detailtext"].pageDown() - - def statusCallback(self, status, progress): - pass - - def setInfos(self): - if self.translatedAttributes.has_key("name"): - self.pluginname = self.translatedAttributes["name"] - elif self.attributes.has_key("name"): - self.pluginname = self.attributes["name"] - else: - self.pluginname = _("unknown") - - if self.translatedAttributes.has_key("author"): - self.author = self.translatedAttributes["author"] - elif self.attributes.has_key("author"): - self.author = self.attributes["author"] - else: - self.author = _("unknown") - - if self.translatedAttributes.has_key("description"): - self.description = self.translatedAttributes["description"] - elif self.attributes.has_key("description"): - self.description = self.attributes["description"] - else: - self.description = _("No description available.") - - if self.translatedAttributes.has_key("screenshot"): - self.loadThumbnail(self.translatedAttributes) - else: - self.loadThumbnail(self.attributes) - - self["author"].setText(_("Author: ") + self.author) - self["detailtext"].setText(self.description.strip()) - if self.pluginstate == 'installable': - self["key_green"].setText(_("Install")) - else: - self["key_green"].setText(_("Remove")) - - def loadThumbnail(self, entry): - thumbnailUrl = None - if entry.has_key("screenshot"): - thumbnailUrl = entry["screenshot"] - 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) - else: - self.setThumbnail(noScreenshot = True) - - def setThumbnail(self, noScreenshot = False): - if not noScreenshot: - filename = self.thumbnail - else: - filename = resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/noprev.png") - - sc = AVSwitch().getFramebufferScale() - self.picload.setPara((self["screenshot"].instance.size().width(), self["screenshot"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000")) - self.picload.startDecode(filename) - - if self.statuspicinstance != None: - self["statuspic"].instance.setPixmap(self.statuspicinstance.__deref__()) - self["statuspic"].show() - if self.divpicinstance != None: - self["divpic"].instance.setPixmap(self.divpicinstance.__deref__()) - self["divpic"].show() - - def paintScreenshotPixmapCB(self, picInfo=None): - ptr = self.picload.getData() - if ptr != None: - self["screenshot"].instance.setPixmap(ptr.__deref__()) - self["screenshot"].show() - else: - self.setThumbnail(noScreenshot = True) - - def go(self): - if self.attributes.has_key("package"): - self.packagefiles = self.attributes["package"] - self.cmdList = [] - if self.pluginstate == 'installed': - if self.packagefiles: - for package in self.packagefiles[:]: - self.cmdList.append((IpkgComponent.CMD_REMOVE, { "package": package["name"] })) - 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) - - def runUpgrade(self, result): - if result: - self.session.openWithCallback(self.runUpgradeFinished, Ipkg, cmdList = self.cmdList) - - def runUpgradeFinished(self): - self.session.openWithCallback(self.UpgradeReboot, MessageBox, _("Installation finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) - - def UpgradeReboot(self, result): - if result is None: - return - if result is False: - self.close(True) - if result: - quitMainloop(3) - - def runRemove(self, result): - if result: - self.session.openWithCallback(self.runRemoveFinished, Ipkg, cmdList = self.cmdList) - - def runRemoveFinished(self): - self.session.openWithCallback(self.RemoveReboot, MessageBox, _("Remove finished.") +" "+_("Do you want to reboot your Dreambox?"), MessageBox.TYPE_YESNO) - - def RemoveReboot(self, result): - if result is None: - return - if result is False: - self.close(True) - if result: - quitMainloop(3) - - def reloadPluginlist(self): - plugins.readPluginList(resolveFilename(SCOPE_PLUGINS)) - - def fetchFailed(self,string): - self.setThumbnail(noScreenshot = True) - print "[PluginDetails] fetch failed " + string.getErrorMessage() - - -class UpdatePlugin(Screen): - skin = """ - - - - - - """ - - def __init__(self, session, args = None): - Screen.__init__(self, session) - - self.sliderPackages = { "dreambox-dvb-modules": 1, "enigma2": 2, "tuxbox-image-info": 3 } - - self.slider = Slider(0, 4) - self["slider"] = self.slider - self.activityslider = Slider(0, 100) - self["activityslider"] = self.activityslider - self.status = StaticText(_("Upgrading Dreambox... Please wait")) - self["status"] = self.status - self.package = StaticText() - self["package"] = self.package - - self.packages = 0 - self.error = 0 - - self.activity = 0 - self.activityTimer = eTimer() - self.activityTimer.callback.append(self.doActivityTimer) - self.activityTimer.start(100, False) - - self.ipkg = IpkgComponent() - self.ipkg.addCallback(self.ipkgCallback) - - self.updating = True - self.package.setText(_("Package list update")) - self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) - - self["actions"] = ActionMap(["WizardActions"], + + self["shortcuts"] = ActionMap(["ShortcutActions"], { - "ok": self.exit, - "back": self.exit - }, -1) - - def doActivityTimer(self): - self.activity += 1 - if self.activity == 100: - self.activity = 0 - self.activityslider.setValue(self.activity) - - def ipkgCallback(self, event, param): - if event == IpkgComponent.EVENT_DOWNLOAD: - self.status.setText(_("Downloading")) - elif event == IpkgComponent.EVENT_UPGRADE: - if self.sliderPackages.has_key(param): - self.slider.setValue(self.sliderPackages[param]) - self.package.setText(param) - self.status.setText(_("Upgrading")) - self.packages += 1 - elif event == IpkgComponent.EVENT_INSTALL: - self.package.setText(param) - self.status.setText(_("Installing")) - self.packages += 1 - elif event == IpkgComponent.EVENT_CONFIGURING: - self.package.setText(param) - self.status.setText(_("Configuring")) - elif event == IpkgComponent.EVENT_MODIFIED: - self.session.openWithCallback( - self.modificationCallback, - MessageBox, - _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param) - ) - elif event == IpkgComponent.EVENT_ERROR: - self.error += 1 - elif event == IpkgComponent.EVENT_DONE: - if self.updating: - self.updating = False - self.ipkg.startCmd(IpkgComponent.CMD_UPGRADE, args = {'test_only': False}) - elif self.error == 0: - self.slider.setValue(4) - - self.activityTimer.stop() - self.activityslider.setValue(0) - - self.package.setText("") - self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages) - else: - self.activityTimer.stop() - self.activityslider.setValue(0) - error = _("your dreambox might be unusable now. Please consult the manual for further assistance before rebooting your dreambox.") - if self.packages == 0: - error = _("No packages were upgraded yet. So you can check your network and try again.") - if self.updating: - error = _("Your dreambox isn't connected to the internet properly. Please check it and try again.") - self.status.setText(_("Error") + " - " + error) - #print event, "-", param - pass - - def modificationCallback(self, res): - self.ipkg.write(res and "N" or "Y") - - def exit(self): - if not self.ipkg.isRunning(): - if self.packages != 0 and self.error == 0: - self.session.openWithCallback(self.exitAnswer, MessageBox, _("Upgrade finished.") +" "+_("Do you want to reboot your Dreambox?")) + "red": self.cancel, + "green": self.select, + }) + self.onLayoutFinish.append(self.layoutFinished) + self.getAccessPoints(refresh = False) + + def layoutFinished(self): + self.setTitle(_("Choose a wireless network")) + + def select(self): + cur = self["list"].getCurrent() + if cur is not None: + self.rescanTimer.stop() + del self.rescanTimer + if cur[1] is not None: + essid = cur[1] + self.close(essid,self.getWlanList()) else: - self.close() - - def exitAnswer(self, result): - if result is not None and result: - quitMainloop(2) - self.close() - - -class IpkgInstaller(Screen): - skin = """ - - - - - - - - - """ + self.close(None,None) + else: + self.rescanTimer.stop() + del self.rescanTimer + self.close(None,None) - def __init__(self, session, list): - Screen.__init__(self, session) - - self.list = SelectionList() - self["list"] = self.list - for listindex in range(len(list)): - self.list.addSelection(list[listindex], list[listindex], listindex, True) + def WlanSetupClosed(self, *ret): + if ret[0] == 2: + self.rescanTimer.stop() + del self.rescanTimer + self.close(None) + + def cancel(self): + if self.oldInterfaceState is False: + iNetwork.setAdapterAttribute(self.iface, "up", False) + iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB) + else: + self.rescanTimer.stop() + del self.rescanTimer + self.close(None) + + def deactivateInterfaceCB(self,data): + if data is not None: + if data is True: + self.rescanTimer.stop() + del self.rescanTimer + self.close(None) + + def rescanTimerFired(self): + self.rescanTimer.stop() + self.updateAPList() + + def buildEntryComponent(self, essid, bssid, encrypted, iface, maxrate, signal): + divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/div-h.png")) + encryption = encrypted and _("Yes") or _("No") + if bssid == 'hidden...': + return((essid, bssid, None, None, None, None, divpng)) + else: + return((essid, bssid, _("Signal: ") + str(signal), _("Max. Bitrate: ") + str(maxrate), _("Encrypted: ") + encryption, _("Interface: ") + str(iface), divpng)) + + def updateAPList(self): + self.oldlist = [] + self.oldlist = self.cleanList + self.newAPList = [] + newList = [] + tmpList = [] + newListIndex = None + currentListEntry = None + currentListIndex = None + newList = self.getAccessPoints(refresh = True) + + for oldentry in self.oldlist: + if oldentry not in newList: + newList.append(oldentry) + + for newentry in newList: + if newentry[1] == "hidden...": + continue + tmpList.append(newentry) + + if len(tmpList): + if "hidden..." not in tmpList: + tmpList.append( ( _("enter hidden network SSID"), "hidden...", True, self.iface, _("unavailable"), "" ) ) + + for entry in tmpList: + self.newAPList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) + + currentListEntry = self["list"].getCurrent() + idx = 0 + for entry in self.newAPList: + if entry == currentListEntry: + newListIndex = idx + idx +=1 + self['list'].setList(self.newAPList) + self["list"].setIndex(newListIndex) + self["list"].updateList(self.newAPList) + self.listLenght = len(self.newAPList) + self.buildWlanList() + self.setInfo() + + def getAccessPoints(self, refresh = False): + self.APList = [] + self.cleanList = [] + self.w = Wlan(self.iface) + aps = self.w.getNetworkList() + if aps is not None: + print "[NetworkWizard.py] got Accespoints!" + tmpList = [] + compList = [] + for ap in aps: + a = aps[ap] + if a['active']: + tmpList.append( (a['essid'], a['bssid']) ) + compList.append( (a['essid'], a['bssid'], a['encrypted'], a['iface'], a['maxrate'], a['signal']) ) + + for entry in tmpList: + if entry[0] == "": + for compentry in compList: + if compentry[1] == entry[1]: + compList.remove(compentry) + for entry in compList: + self.cleanList.append( ( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] ) ) + + if "hidden..." not in self.cleanList: + self.cleanList.append( ( _("enter hidden network SSID"), "hidden...", True, self.iface, _("unavailable"), "" ) ) - self["key_red"] = StaticText(_("Close")) - self["key_green"] = StaticText(_("Install")) - self["introduction"] = StaticText(_("Press OK to toggle the selection.")) + for entry in self.cleanList: + self.APList.append(self.buildEntryComponent( entry[0], entry[1], entry[2], entry[3], entry[4], entry[5] )) - self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], - { - "ok": self.list.toggleSelection, - "cancel": self.close, - "red": self.close, - "green": self.install - }, -1) + if refresh is False: + self['list'].setList(self.APList) + self.listLenght = len(self.APList) + self.setInfo() + self.rescanTimer.start(5000) + return self.cleanList + + def setInfo(self): + length = self.getLength() + if length == 0: + self["info"].setText(_("No wireless networks found! Please refresh.")) + elif length == 1: + self["info"].setText(_("1 wireless network found!")) + else: + self["info"].setText(str(length)+_(" wireless networks found!")) + + def buildWlanList(self): + self.WlanList = [] + currList = [] + currList = self['list'].list + for entry in currList: + self.WlanList.append( (entry[1], entry[0]) ) - def install(self): - list = self.list.getSelectionsList() - cmdList = [] - for item in list: - cmdList.append((IpkgComponent.CMD_INSTALL, { "package": item[1] })) - self.session.open(Ipkg, cmdList = cmdList) + def getLength(self): + return self.listLenght + def getWlanList(self): + return self.WlanList -def filescan_open(list, session, **kwargs): - filelist = [x.path for x in list] - session.open(IpkgInstaller, filelist) # list -def filescan(**kwargs): - from Components.Scanner import Scanner, ScanPath - return \ - Scanner(mimetypes = ["application/x-debian-package"], - paths_to_scan = - [ - ScanPath(path = "ipk", with_subdirs = True), - ScanPath(path = "", with_subdirs = False), - ], - name = "Ipkg", - description = _("Install extensions."), - openfnc = filescan_open, ) +def WlanStatusScreenMain(session, iface): + session.open(WlanStatus, iface) +def callFunction(iface): + w = Wlan(iface) + i = w.getWirelessInterfaces() + if i: + if iface in i: + return WlanStatusScreenMain + return None -def UpgradeMain(session, **kwargs): - session.open(UpdatePluginMenu) -def startSetup(menuid): - if menuid != "setup": - return [ ] - return [(_("Software manager"), UpgradeMain, "software_manager", 50)] +def configStrings(iface): + driver = iNetwork.detectWlanModule() + print "Found WLAN-Driver:",driver + if driver in ('ralink', 'zydas'): + return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -D"+driver+"\n post-down wpa_cli terminate" + else: + if config.plugins.wlan.essid.value == "hidden...": + return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.hiddenessid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n post-down wpa_cli terminate' + else: + return ' pre-up iwconfig '+iface+' essid "'+config.plugins.wlan.essid.value+'"\n pre-up /usr/sbin/wpa_supplicant -i'+iface+' -c/etc/wpa_supplicant.conf -B -dd -D'+driver+'\n post-down wpa_cli terminate' -def Plugins(path, **kwargs): - global plugin_path - plugin_path = path - list = [ - PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), - PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) - ] - if config.usage.setup_level.index >= 2: # expert+ - list.append(PluginDescriptor(name=_("Software manager"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=UpgradeMain)) - return list +def Plugins(**kwargs): + return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "WlanPluginEntry": lambda x: "Wireless Network Configuartion..."}) -- cgit v1.2.3 From d9d9b21f1b6dae099a07cb50e7fcbbb4a4d3f2ee Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 13 Dec 2009 12:35:54 +0100 Subject: CutListEditor: always restart service on cutlist editor close --- lib/python/Plugins/Extensions/CutListEditor/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/CutListEditor/plugin.py b/lib/python/Plugins/Extensions/CutListEditor/plugin.py index efe9f761..abd606d6 100644 --- a/lib/python/Plugins/Extensions/CutListEditor/plugin.py +++ b/lib/python/Plugins/Extensions/CutListEditor/plugin.py @@ -195,7 +195,7 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He self.onClose.append(self.__onClose) def __onClose(self): - self.session.nav.playService(self.old_service) + self.session.nav.playService(self.old_service, forceRestart=True) def updateStateLabel(self, state): self["SeekState"].setText(state[3].strip()) -- cgit v1.2.3 From df11647105be3033f3f6222ed83f69b0a1c3c3df Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 30 Dec 2009 11:13:26 +0100 Subject: no more ask for 50hz in videowizzard when 720p/1080i is selected.. and now multi is used as default for 720p and 1080i this fixes bug #262 --- lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py | 7 +++++-- lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index cd1529aa..49b5d53d 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -131,8 +131,11 @@ class VideoWizard(WizardLanguage, Rc): def modeSelect(self, mode): ratesList = self.listRates(mode) print "ratesList:", ratesList - self.hw.setMode(port = self.port, mode = mode, rate = ratesList[0][0]) - + if self.port == "DVI" and mode in ("720p", "1080i"): + self.hw.setMode(port = self.port, mode = mode, rate = "multi") + else: + self.hw.setMode(port = self.port, mode = mode, rate = ratesList[0][0]) + def listRates(self, querymode = None): if querymode is None: querymode = self.mode diff --git a/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml b/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml index 29ac4297..5dea661d 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml +++ b/lib/python/Plugins/SystemPlugins/Videomode/videowizard.xml @@ -20,7 +20,7 @@ self.selectKey("DOWN") self["portpic"].hide() - + self.condition = (self.port != "DVI" or self.mode == "PC") @@ -33,7 +33,7 @@ self.selectKey("UP") self.selectKey("DOWN") - + self.hw.saveMode(self.port, self.mode, self.rate) -- cgit v1.2.3 From 7c30efab7f3c66c8cf259d6926d4ed1312cb456c Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 30 Dec 2009 17:53:10 +0100 Subject: save multi framerate even to configfile --- lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index 49b5d53d..512bcec3 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -132,6 +132,7 @@ class VideoWizard(WizardLanguage, Rc): ratesList = self.listRates(mode) print "ratesList:", ratesList if self.port == "DVI" and mode in ("720p", "1080i"): + self.rate = "multi" self.hw.setMode(port = self.port, mode = mode, rate = "multi") else: self.hw.setMode(port = self.port, mode = mode, rate = ratesList[0][0]) -- cgit v1.2.3 From 547ecaf9bfda061aca736aefb04ca0743a6395cc Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Thu, 14 Jan 2010 14:11:20 +0100 Subject: fixes bug #393 change DVI picture to HDMI picture for dm500hd --- lib/python/Plugins/SystemPlugins/Videomode/HDMI.png | Bin 0 -> 4098 bytes lib/python/Plugins/SystemPlugins/Videomode/Makefile.am | 4 +++- .../Plugins/SystemPlugins/Videomode/VideoWizard.py | 5 ++++- lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png | Bin 0 -> 261 bytes 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 lib/python/Plugins/SystemPlugins/Videomode/HDMI.png create mode 100644 lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/Videomode/HDMI.png b/lib/python/Plugins/SystemPlugins/Videomode/HDMI.png new file mode 100644 index 00000000..5aa83047 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/Videomode/HDMI.png differ diff --git a/lib/python/Plugins/SystemPlugins/Videomode/Makefile.am b/lib/python/Plugins/SystemPlugins/Videomode/Makefile.am index 2ec0b335..1ac1d5dd 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Videomode/Makefile.am @@ -16,4 +16,6 @@ dist_install_DATA = \ LICENSE \ Scart.png \ videowizard.xml \ - YPbPr.png + YPbPr.png \ + HDMI.png \ + lcd_HDMI.png diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index 512bcec3..15f4d516 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -99,7 +99,10 @@ class VideoWizard(WizardLanguage, Rc): print "input selection moved:", self.selection self.inputSelect(self.selection) if self["portpic"].instance is not None: - self["portpic"].instance.setPixmapFromFile(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/" + self.selection + ".png")) + picname = self.selection + if picname == "DVI" and HardwareInfo().get_device_name() == "dm500hd": + picname = "HDMI" + self["portpic"].instance.setPixmapFromFile(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/" + picname + ".png")) def inputSelect(self, port): print "inputSelect:", port diff --git a/lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png b/lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png new file mode 100644 index 00000000..425da5c3 Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/Videomode/lcd_HDMI.png differ -- cgit v1.2.3 From 0f01de80dad98af94f07fe4d912791831eacff6a Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 21 Jan 2010 11:32:40 +0100 Subject: fix cutlist editor for HD skins --- lib/python/Plugins/Extensions/CutListEditor/plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/CutListEditor/plugin.py b/lib/python/Plugins/Extensions/CutListEditor/plugin.py index abd606d6..0627df3b 100644 --- a/lib/python/Plugins/Extensions/CutListEditor/plugin.py +++ b/lib/python/Plugins/Extensions/CutListEditor/plugin.py @@ -10,7 +10,7 @@ from Components.VideoWindow import VideoWindow from Components.Label import Label from Screens.InfoBarGenerics import InfoBarSeek, InfoBarCueSheetSupport from Components.GUIComponent import GUIComponent -from enigma import eListboxPythonMultiContent, eListbox, gFont, iPlayableService, RT_HALIGN_RIGHT +from enigma import eListboxPythonMultiContent, eListbox, getDesktop, gFont, iPlayableService, RT_HALIGN_RIGHT from Screens.FixedMenu import FixedMenu from Screens.HelpMenu import HelpableScreen from ServiceReference import ServiceReference @@ -167,7 +167,8 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He self.onPlayStateChanged.append(self.updateStateLabel) self.updateStateLabel(self.seekstate) - self["Video"] = VideoWindow(decoder = 0) + desktopSize = getDesktop(0).size() + self["Video"] = VideoWindow(decoder = 0, fb_width=desktopSize.width(), fb_height=desktopSize.height()) self["actions"] = HelpableActionMap(self, "CutListEditorActions", { -- cgit v1.2.3 From 1ff71d24c512a57686d8cdbef41bc0112ca9be72 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 29 Jan 2010 00:49:43 +0100 Subject: don't use string concatenation within translation brackets --- lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py index d9ccab57..dcff3ca2 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -252,7 +252,7 @@ class RestoreMenu(Screen): if (self.exe == False) and (self.entry == True): self.sel = self["filelist"].getCurrent() self.val = self.path + "/" + self.sel - self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore\nfollowing backup:\n" + self.sel + "\nSystem will restart after the restore!")) + self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore\nfollowing backup:\n") + self.sel + _("\nSystem will restart after the restore!")) def keyCancel(self): self.close() -- cgit v1.2.3 From 07546e9555132554de255826213f52e456b5ee1e Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 9 Feb 2010 14:26:01 +0100 Subject: lib/python/Plugins/Extensions/DVDPlayer/plugin.py: also check with upper case --- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index e895a141..6e4d9cc6 100755 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -736,6 +736,7 @@ def filescan(**kwargs): paths_to_scan = [ ScanPath(path = "video_ts", with_subdirs = False), + ScanPath(path = "VIDEO_TS", with_subdirs = False), ScanPath(path = "", with_subdirs = False), ], name = "DVD", -- cgit v1.2.3 From e50f482422a4d0f1d08f0970dc7988e2e3ebc78e Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 9 Feb 2010 19:45:42 +0100 Subject: lib/python/Plugins/SystemPlugins/SoftwareManager: more robust code this i.e. fixes: Traceback (most recent call last): File "/usr/lib/enigma2/python/Tools/BoundFunction.py", line 9, in __call__ return self.fnc(*self.args + args, **newkwargs) File "/usr/lib/enigma2/python/Components/Console.py", line 56, in finishedCB self.callbacks[name](data,retval,extra_args) File "/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py", line 108, in IpkgListAvailableCB SoftwareTools.available_packetlist.append([name, split[1].strip(), split[2].strip()]) File "/usr/lib/enigma2/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py", line 108, in IpkgListAvailableCB SoftwareTools.available_packetlist.append([name, split[1].strip(), split[2].strip()]) ref bug #383 --- .../SystemPlugins/SoftwareManager/SoftwareTools.py | 25 +++++++++++++--------- .../SystemPlugins/SoftwareManager/plugin.py | 25 ++++++++++++++-------- 2 files changed, 31 insertions(+), 19 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py index 4e7591ef..e8cf6dc2 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py @@ -94,14 +94,17 @@ class SoftwareTools(DreamInfoHandler): def IpkgListAvailableCB(self, result, retval, extra_args = None): (callback) = extra_args - if len(result): + if result: if SoftwareTools.list_updating: SoftwareTools.available_packetlist = [] for x in result.splitlines(): - split = x.split(' - ') - name = split[0].strip() + tokens = x.split(' - ') + name = tokens[0].strip() if not any(name.endswith(x) for x in self.unwanted_extensions): - SoftwareTools.available_packetlist.append([name, split[1].strip(), split[2].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]) if callback is None: self.startInstallMetaPackage() else: @@ -126,7 +129,7 @@ class SoftwareTools(DreamInfoHandler): def InstallMetaPackageCB(self, result, retval, extra_args = None): (callback) = extra_args - if len(result): + if result: self.fillPackagesIndexList() if callback is None: self.startIpkgListInstalled() @@ -152,13 +155,15 @@ class SoftwareTools(DreamInfoHandler): def IpkgListInstalledCB(self, result, retval, extra_args = None): (callback) = extra_args - if len(result): + if result: SoftwareTools.installed_packetlist = {} for x in result.splitlines(): - split = x.split(' - ') - name = split[0].strip() + tokens = x.split(' - ') + name = tokens[0].strip() if not any(name.endswith(x) for x in self.unwanted_extensions): - SoftwareTools.installed_packetlist[name] = split[1].strip() + l = len(tokens) + version = l > 1 and tokens[1].strip() or "" + SoftwareTools.installed_packetlist[name] = version if callback is None: self.countUpdates() else: @@ -203,7 +208,7 @@ class SoftwareTools(DreamInfoHandler): def IpkgUpdateCB(self, result, retval, extra_args = None): (callback) = extra_args - if len(result): + if result: if self.Console: if len(self.Console.appContainers) == 0: if callback is not None: diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index b20ba51e..4dbe7f70 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -1558,24 +1558,31 @@ class PacketManager(Screen): pass def IpkgList_Finished(self, result, retval, extra_args = None): - if len(result): + if result: self.packetlist = [] for x in result.splitlines(): - split = x.split(' - ') #self.blacklisted_packages - if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): - self.packetlist.append([split[0].strip(), split[1].strip(),split[2].strip()]) + tokens = x.split(' - ') #self.blacklisted_packages + 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 "" + descr = l > 2 and tokens[2].strip() or "" + self.packetlist.append([name, version, descr]) if not self.Console: self.Console = Console() cmd = "ipkg list_installed" self.Console.ePopen(cmd, self.IpkgListInstalled_Finished) def IpkgListInstalled_Finished(self, result, retval, extra_args = None): - if len(result): + if result: self.installed_packetlist = {} for x in result.splitlines(): - split = x.split(' - ') - if not any(split[0].strip().endswith(x) for x in self.unwanted_extensions): - self.installed_packetlist[split[0].strip()] = split[1].strip() + tokens = x.split(' - ') #self.blacklisted_packages + 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 "" + self.installed_packetlist[name] = version self.buildPacketList() def buildEntryComponent(self, name, version, description, state): @@ -1703,7 +1710,7 @@ def Plugins(path, **kwargs): plugin_path = path list = [ PluginDescriptor(where = [PluginDescriptor.WHERE_NETWORKCONFIG_READ], fnc = autostart), - PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), + PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) ] if config.usage.setup_level.index >= 2: # expert+ -- cgit v1.2.3 From 30eb05e6ba834df51db97db306bfb1cab94c9b20 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Thu, 11 Feb 2010 14:15:33 +0100 Subject: NetworkWizard/NetworkWizard.py: * fix automatic interface selection if only one network adapter is available in some situations. refs #218 --- lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py index 150dba9d..a8b34acd 100755 --- a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py @@ -104,6 +104,9 @@ class NetworkWizard(WizardLanguage, Rc): self.rescanTimer.stop() self.Adapterlist = iNetwork.getAdapterList() self.InstalledInterfaceCount = len(self.Adapterlist) + if self.Adapterlist is not None: + if self.InstalledInterfaceCount == 1 and self.selectedInterface is None: + self.selectedInterface = self.Adapterlist[0] self.originalAth0State = iNetwork.getAdapterAttribute('ath0', 'up') self.originalEth0State = iNetwork.getAdapterAttribute('eth0', 'up') self.originalWlan0State = iNetwork.getAdapterAttribute('wlan0', 'up') -- cgit v1.2.3 From e058cb26c1fe4a6352ac5987c94694c0ecc1ff98 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Thu, 11 Feb 2010 14:27:16 +0100 Subject: WirelessLan/plugin.py: * fix sometimes not correctly returned ssid name from wlanscan screen. * don't count the hidden network helper entry as found network. * some small optimizations. refs #204 --- .../Plugins/SystemPlugins/WirelessLan/plugin.py | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index 6873ffa4..a3f5d225 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -151,6 +151,7 @@ class WlanStatus(Screen): self["statuspic"].setPixmapNum(0) self["statuspic"].show() + class WlanScan(Screen): skin = """ @@ -190,7 +191,7 @@ class WlanScan(Screen): self.WlanList = None self.cleanList = None self.oldlist = None - self.listLenght = None + self.listLength = None self.rescanTimer = eTimer() self.rescanTimer.callback.append(self.rescanTimerFired) @@ -226,7 +227,10 @@ class WlanScan(Screen): self.rescanTimer.stop() del self.rescanTimer if cur[1] is not None: - essid = cur[1] + if cur[1] == 'hidden...': + essid = cur[1] + else: + essid = cur[0] self.close(essid,self.getWlanList()) else: self.close(None,None) @@ -305,7 +309,7 @@ class WlanScan(Screen): self['list'].setList(self.newAPList) self["list"].setIndex(newListIndex) self["list"].updateList(self.newAPList) - self.listLenght = len(self.newAPList) + self.listLength = len(self.newAPList) self.buildWlanList() self.setInfo() @@ -315,7 +319,7 @@ class WlanScan(Screen): self.w = Wlan(self.iface) aps = self.w.getNetworkList() if aps is not None: - print "[NetworkWizard.py] got Accespoints!" + print "[WirelessLan.py] got Accespoints!" tmpList = [] compList = [] for ap in aps: @@ -340,31 +344,34 @@ class WlanScan(Screen): if refresh is False: self['list'].setList(self.APList) - self.listLenght = len(self.APList) + self.listLength = len(self.APList) self.setInfo() self.rescanTimer.start(5000) return self.cleanList def setInfo(self): length = self.getLength() - if length == 0: + if length <= 1: self["info"].setText(_("No wireless networks found! Please refresh.")) - elif length == 1: + elif length == 2: self["info"].setText(_("1 wireless network found!")) else: - self["info"].setText(str(length)+_(" wireless networks found!")) + self["info"].setText(str(length-1)+_(" wireless networks found!")) def buildWlanList(self): self.WlanList = [] - currList = [] - currList = self['list'].list - for entry in currList: - self.WlanList.append( (entry[1], entry[0]) ) + for entry in self['list'].list: + if entry[1] == "hidden...": + self.WlanList.append(( "hidden...",_("enter hidden network SSID") ))#continue + else: + self.WlanList.append( (entry[0], entry[0]) ) def getLength(self): - return self.listLenght + return self.listLength def getWlanList(self): + if self.WlanList is None: + self.buildWlanList() return self.WlanList -- cgit v1.2.3 From f9ebb7117c782cd7687523abc8bdccfe8153290e Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 1 Mar 2010 19:37:57 +0100 Subject: fix no more turning positioner after leave positioner setup in some cases this fixes bug #321 --- lib/dvb/frontend.cpp | 19 +++++++++++++++++-- lib/dvb/frontend.h | 1 + lib/dvb/sec.cpp | 5 +++++ lib/python/Components/TuneTest.py | 5 +++-- .../Plugins/SystemPlugins/PositionerSetup/plugin.py | 2 +- 5 files changed, 27 insertions(+), 5 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index c0263fb4..f85a37fe 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -455,7 +455,7 @@ int eDVBFrontend::PriorityOrder=0; eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok, bool simulate) :m_simulate(simulate), m_enabled(false), m_type(-1), m_dvbid(fe), m_slotid(fe) - ,m_fd(-1), m_need_rotor_workaround(false), m_can_handle_dvbs2(false) + ,m_fd(-1), m_rotor_mode(false), m_need_rotor_workaround(false), m_can_handle_dvbs2(false) ,m_state(stateClosed), m_timeout(0), m_tuneTimer(0) #if HAVE_DVB_API_VERSION < 3 ,m_secfd(-1) @@ -692,7 +692,8 @@ void eDVBFrontend::feEvent(int w) { eDebug("stateLostLock"); state = stateLostLock; - sec_fe->m_data[CSW] = sec_fe->m_data[UCSW] = sec_fe->m_data[TONEBURST] = -1; // reset diseqc + if (!m_rotor_mode) + sec_fe->m_data[CSW] = sec_fe->m_data[UCSW] = sec_fe->m_data[TONEBURST] = -1; // reset diseqc } } if (m_state != state) @@ -2343,6 +2344,20 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where) res = -EINVAL; goto tune_error; } + if (m_rotor_mode != feparm.no_rotor_command_on_tune && !feparm.no_rotor_command_on_tune) + { + eDVBFrontend *sec_fe = this; + long tmp = m_data[LINKED_PREV_PTR]; + while (tmp != -1) + { + eDVBRegisteredFrontend *linked_fe = (eDVBRegisteredFrontend*)tmp; + sec_fe = linked_fe->m_frontend; + sec_fe->getData(LINKED_NEXT_PTR, tmp); + } + eDebug("(fe%d) reset diseqc after leave rotor mode!", m_dvbid); + sec_fe->m_data[CSW] = sec_fe->m_data[UCSW] = sec_fe->m_data[TONEBURST] = sec_fe->m_data[ROTOR_CMD] = sec_fe->m_data[ROTOR_POS] = -1; // reset diseqc + } + m_rotor_mode = feparm.no_rotor_command_on_tune; if (!m_simulate) m_sec->setRotorMoving(m_slotid, false); res=prepare_sat(feparm, timeout); diff --git a/lib/dvb/frontend.h b/lib/dvb/frontend.h index bac27539..4cf05081 100644 --- a/lib/dvb/frontend.h +++ b/lib/dvb/frontend.h @@ -75,6 +75,7 @@ private: int m_dvbid; int m_slotid; int m_fd; + bool m_rotor_mode; bool m_need_rotor_workaround; bool m_can_handle_dvbs2; char m_filename[128]; diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index 91246889..44cbe709 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -156,6 +156,11 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite ret = 15000; } + if (sat.no_rotor_command_on_tune && !rotor) { + eSecDebugNoSimulate("no rotor but no_rotor_command_on_tune is set.. ignore lnb %d", idx); + continue; + } + eSecDebugNoSimulate("ret1 %d", ret); if (linked_in_use) diff --git a/lib/python/Components/TuneTest.py b/lib/python/Components/TuneTest.py index f9ab3edb..44b19091 100644 --- a/lib/python/Components/TuneTest.py +++ b/lib/python/Components/TuneTest.py @@ -1,8 +1,9 @@ from enigma import eDVBFrontendParametersSatellite, eDVBFrontendParameters, eDVBResourceManager, eTimer class Tuner: - def __init__(self, frontend): + def __init__(self, frontend, ignore_rotor=False): self.frontend = frontend + self.ignore_rotor = ignore_rotor # transponder = (frequency, symbolrate, polarisation, fec, inversion, orbpos, system, modulation, rolloff, pilot, tsid, onid) # 0 1 2 3 4 5 6 7 8 9 10 11 @@ -21,7 +22,7 @@ class Tuner: parm.rolloff = transponder[8] parm.pilot = transponder[9] feparm = eDVBFrontendParameters() - feparm.setDVBS(parm) + feparm.setDVBS(parm, self.ignore_rotor) self.lastparm = feparm self.frontend.tune(feparm) diff --git a/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py b/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py index fa533c0b..3cc9e751 100644 --- a/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py +++ b/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py @@ -77,7 +77,7 @@ class PositionerSetup(Screen): self.frontendStatus = { } self.diseqc = Diseqc(self.frontend) - self.tuner = Tuner(self.frontend) + self.tuner = Tuner(self.frontend, True) #True means we dont like that the normal sec stuff sends commands to the rotor! tp = ( cur.get("frequency", 0) / 1000, cur.get("symbol_rate", 0) / 1000, -- cgit v1.2.3 From 678d4adc636ce6effe3e4c7442dd1b19e868e570 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 8 Mar 2010 13:33:36 +0100 Subject: fixes bug #465 don't install sub directory files --- lib/python/Plugins/Extensions/DVDPlayer/Makefile.am | 1 - lib/python/Plugins/Extensions/DVDPlayer/src/Makefile.am | 5 +++++ lib/python/Plugins/Extensions/SocketMMI/Makefile.am | 1 - lib/python/Plugins/Extensions/SocketMMI/src/Makefile.am | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/Makefile.am b/lib/python/Plugins/Extensions/DVDPlayer/Makefile.am index d1a995ca..71ea7142 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/Makefile.am +++ b/lib/python/Plugins/Extensions/DVDPlayer/Makefile.am @@ -4,7 +4,6 @@ SUBDIRS = src meta installdir = $(pkglibdir)/python/Plugins/Extensions/DVDPlayer install_PYTHON = \ - src/servicedvd.so \ __init__.py \ plugin.py \ keymap.xml \ diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/Makefile.am b/lib/python/Plugins/Extensions/DVDPlayer/src/Makefile.am index 774871e8..27c751cf 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/Makefile.am +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/Makefile.am @@ -2,6 +2,11 @@ OBJS := servicedvd.cpp -include $(OBJS:.cpp=.d) +installdir = $(pkglibdir)/python/Plugins/Extensions/DVDPlayer + +install_PYTHON = \ + servicedvd.so + servicedvd.so: $(CXX) $(CPPFLAGS) -MD $(CXXFLAGS) $(DEFS) -I$(top_srcdir)/include \ -Wall -W $(OBJS) -shared -fPIC -Wl,-soname,servicedvd.so -o servicedvd.so \ diff --git a/lib/python/Plugins/Extensions/SocketMMI/Makefile.am b/lib/python/Plugins/Extensions/SocketMMI/Makefile.am index 808d8520..2af2c39b 100644 --- a/lib/python/Plugins/Extensions/SocketMMI/Makefile.am +++ b/lib/python/Plugins/Extensions/SocketMMI/Makefile.am @@ -3,7 +3,6 @@ SUBDIRS = src meta installdir = $(pkglibdir)/python/Plugins/Extensions/SocketMMI install_PYTHON = \ - src/socketmmi.so \ __init__.py \ plugin.py \ SocketMMI.py diff --git a/lib/python/Plugins/Extensions/SocketMMI/src/Makefile.am b/lib/python/Plugins/Extensions/SocketMMI/src/Makefile.am index ad97d672..8e80e183 100644 --- a/lib/python/Plugins/Extensions/SocketMMI/src/Makefile.am +++ b/lib/python/Plugins/Extensions/SocketMMI/src/Makefile.am @@ -2,6 +2,11 @@ OBJS = socket_mmi.cpp -include $(OBJS:.cpp=.d) +installdir = $(pkglibdir)/python/Plugins/Extensions/SocketMMI + +install_PYTHON = \ + socketmmi.so + socketmmi.so: socket_mmi.cpp socket_mmi.h $(CXX) $(CPPFLAGS) -MD $(CXXFLAGS) $(DEFS) -I$(top_srcdir)/include \ -Wall -W $(OBJS) -shared -fPIC -Wl,-soname,socketmmi.so -o socketmmi.so \ -- cgit v1.2.3 From 46987d3de4111d3ccdbfe615b9f3f9f489941b23 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 8 Mar 2010 16:18:50 +0100 Subject: fixes bug #429 remove some absolute paths --- lib/python/Components/Network.py | 2 +- lib/python/Plugins/Extensions/DVDBurn/Process.py | 36 ++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py index 29491cb0..b9da48d8 100755 --- a/lib/python/Components/Network.py +++ b/lib/python/Components/Network.py @@ -14,7 +14,7 @@ class Network: self.NetworkState = 0 self.DnsState = 0 self.nameservers = [] - self.ethtool_bin = "/usr/sbin/ethtool" + self.ethtool_bin = "ethtool" self.container = eConsoleAppContainer() self.Console = Console() self.LinkConsole = Console() diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index 642a898d..f7f44db6 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -5,7 +5,7 @@ from Screens.MessageBox import MessageBox class png2yuvTask(Task): def __init__(self, job, inputfile, outputfile): Task.__init__(self, job, "Creating menu video") - self.setTool("/usr/bin/png2yuv") + self.setTool("png2yuv") self.args += ["-n1", "-Ip", "-f25", "-j", inputfile] self.dumpFile = outputfile self.weighting = 15 @@ -21,7 +21,7 @@ class png2yuvTask(Task): class mpeg2encTask(Task): def __init__(self, job, inputfile, outputfile): Task.__init__(self, job, "Encoding menu video") - self.setTool("/usr/bin/mpeg2enc") + self.setTool("mpeg2enc") self.args += ["-f8", "-np", "-a2", "-o", outputfile] self.inputFile = inputfile self.weighting = 25 @@ -36,7 +36,7 @@ class mpeg2encTask(Task): class spumuxTask(Task): def __init__(self, job, xmlfile, inputfile, outputfile): Task.__init__(self, job, "Muxing buttons into menu") - self.setTool("/usr/bin/spumux") + self.setTool("spumux") self.args += [xmlfile] self.inputFile = inputfile self.dumpFile = outputfile @@ -54,7 +54,7 @@ class spumuxTask(Task): class MakeFifoNode(Task): def __init__(self, job, number): Task.__init__(self, job, "Make FIFO nodes") - self.setTool("/bin/mknod") + self.setTool("mknod") nodename = self.job.workspace + "/dvd_title_%d" % number + ".mpg" self.args += [nodename, "p"] self.weighting = 10 @@ -62,14 +62,14 @@ class MakeFifoNode(Task): class LinkTS(Task): def __init__(self, job, sourcefile, link_name): Task.__init__(self, job, "Creating symlink for source titles") - self.setTool("/bin/ln") + self.setTool("ln") self.args += ["-s", sourcefile, link_name] self.weighting = 10 class CopyMeta(Task): def __init__(self, job, sourcefile): Task.__init__(self, job, "Copy title meta files") - self.setTool("/bin/cp") + self.setTool("cp") from os import listdir path, filename = sourcefile.rstrip("/").rsplit("/",1) tsfiles = listdir(path) @@ -84,7 +84,7 @@ class DemuxTask(Task): Task.__init__(self, job, "Demux video into ES") title = job.project.titles[job.i] self.global_preconditions.append(DiskspacePrecondition(title.estimatedDiskspace)) - self.setTool("/usr/bin/projectx") + self.setTool("projectx") self.args += [inputfile, "-demux", "-out", self.job.workspace ] self.end = 300 self.prog_state = 0 @@ -194,7 +194,7 @@ class MplexTask(Task): self.weighting = weighting self.demux_task = demux_task self.postconditions.append(MplexTaskPostcondition()) - self.setTool("/usr/bin/mplex") + self.setTool("mplex") self.args += ["-f8", "-o", outputfile, "-v1"] if inputfiles: self.args += inputfiles @@ -222,7 +222,7 @@ class RemoveESFiles(Task): def __init__(self, job, demux_task): Task.__init__(self, job, "Remove temp. files") self.demux_task = demux_task - self.setTool("/bin/rm") + self.setTool("rm") self.weighting = 10 def prepare(self): @@ -234,7 +234,7 @@ class DVDAuthorTask(Task): def __init__(self, job): Task.__init__(self, job, "Authoring DVD") self.weighting = 20 - self.setTool("/usr/bin/dvdauthor") + self.setTool("dvdauthor") self.CWD = self.job.workspace self.args += ["-x", self.job.workspace+"/dvdauthor.xml"] self.menupreview = job.menupreview @@ -255,7 +255,7 @@ class DVDAuthorTask(Task): class DVDAuthorFinalTask(Task): def __init__(self, job): Task.__init__(self, job, "dvdauthor finalize") - self.setTool("/usr/bin/dvdauthor") + self.setTool("dvdauthor") self.args += ["-T", "-o", self.job.workspace + "/dvd"] class WaitForResidentTasks(Task): @@ -292,7 +292,7 @@ class BurnTaskPostcondition(Condition): class BurnTask(Task): ERROR_NOTWRITEABLE, ERROR_LOAD, ERROR_SIZE, ERROR_WRITE_FAILED, ERROR_DVDROM, ERROR_ISOFS, ERROR_FILETOOLARGE, ERROR_ISOTOOLARGE, ERROR_MINUSRWBUG, ERROR_UNKNOWN = range(10) - def __init__(self, job, extra_args=[], tool="/bin/growisofs"): + def __init__(self, job, extra_args=[], tool="growisofs"): Task.__init__(self, job, job.name) self.weighting = 500 self.end = 120 # 100 for writing, 10 for buffer flush, 10 for closing disc @@ -357,7 +357,7 @@ class BurnTask(Task): class RemoveDVDFolder(Task): def __init__(self, job): Task.__init__(self, job, "Remove temp. files") - self.setTool("/bin/rm") + self.setTool("rm") self.args += ["-rf", self.job.workspace] self.weighting = 10 @@ -882,13 +882,13 @@ class DVDJob(Job): volName = self.project.settings.name.getValue() if output == "dvd": self.name = _("Burn DVD") - tool = "/bin/growisofs" + tool = "growisofs" burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD(), "-dvd-compat" ] if self.project.size/(1024*1024) > self.project.MAX_SL: burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ] elif output == "iso": self.name = _("Create DVD-ISO") - tool = "/usr/bin/mkisofs" + tool = "mkisofs" isopathfile = getISOfilename(self.project.settings.isopath.getValue(), volName) burnargs = [ "-o", isopathfile ] burnargs += [ "-dvd-video", "-publisher", "Dreambox", "-V", volName, self.workspace + "/dvd" ] @@ -920,14 +920,14 @@ class DVDdataJob(Job): output = self.project.settings.output.getValue() volName = self.project.settings.name.getValue() - tool = "/bin/growisofs" + tool = "growisofs" if output == "dvd": self.name = _("Burn DVD") burnargs = [ "-Z", "/dev/" + harddiskmanager.getCD(), "-dvd-compat" ] if self.project.size/(1024*1024) > self.project.MAX_SL: burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ] elif output == "iso": - tool = "/usr/bin/mkisofs" + tool = "mkisofs" self.name = _("Create DVD-ISO") isopathfile = getISOfilename(self.project.settings.isopath.getValue(), volName) burnargs = [ "-o", isopathfile ] @@ -959,5 +959,5 @@ class DVDisoJob(Job): if getSize(imagepath)/(1024*1024) > self.project.MAX_SL: burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ] burnargs += [ "-dvd-video", "-publisher", "Dreambox", "-V", volName, imagepath ] - tool = "/bin/growisofs" + tool = "growisofs" BurnTask(self, burnargs, tool) -- cgit v1.2.3 From a6f88303d6efb4e6669a6a491bec4cf3e751337a Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 11 Mar 2010 13:54:33 +0100 Subject: lib/python/Plugins/Extensions/DVDPlayer/plugin.py: smaller fontsize for "DVD Player" text in LCD/Oled display --- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 6e4d9cc6..e092e82f 100755 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -93,7 +93,7 @@ class DVDSummary(Screen): Name - + Position -- cgit v1.2.3 From bb61a8a6ff402b248d1af83d138996259fb4641f Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Thu, 11 Mar 2010 14:29:43 +0100 Subject: refs bug #429 change "mkisofs" to "genisoimage" since it is only a link to genisoimage in oe 1.5 and the link is'n set in oe 1.6 --- lib/python/Plugins/Extensions/DVDBurn/Process.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/Process.py b/lib/python/Plugins/Extensions/DVDBurn/Process.py index f7f44db6..b64541b6 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/Process.py +++ b/lib/python/Plugins/Extensions/DVDBurn/Process.py @@ -888,7 +888,7 @@ class DVDJob(Job): burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ] elif output == "iso": self.name = _("Create DVD-ISO") - tool = "mkisofs" + tool = "genisoimage" isopathfile = getISOfilename(self.project.settings.isopath.getValue(), volName) burnargs = [ "-o", isopathfile ] burnargs += [ "-dvd-video", "-publisher", "Dreambox", "-V", volName, self.workspace + "/dvd" ] @@ -927,7 +927,7 @@ class DVDdataJob(Job): if self.project.size/(1024*1024) > self.project.MAX_SL: burnargs += [ "-use-the-force-luke=4gms", "-speed=1", "-R" ] elif output == "iso": - tool = "mkisofs" + tool = "genisoimage" self.name = _("Create DVD-ISO") isopathfile = getISOfilename(self.project.settings.isopath.getValue(), volName) burnargs = [ "-o", isopathfile ] -- cgit v1.2.3 From 20894cf99fd0ab6ecd6e3cf0aebc5b02c4193903 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 15 Mar 2010 12:14:19 +0100 Subject: [DVDBurn] allow burning of recordings that are currently playing in the background, fixes bug 367 --- lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py b/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py index 61152e8a..06ed1bab 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py @@ -52,6 +52,8 @@ class TitleCutter(CutListEditor): CutListEditor.grabFrame(self) def exit(self): + if self.t.VideoType == -1: + self.getPMTInfo() self.checkAndGrabThumb() self.session.nav.stopService() self.close(self.cut_list[:]) -- cgit v1.2.3 From 4d01a8b971e7631cf999d4773891cce657b9aa27 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 24 Mar 2010 11:29:50 +0100 Subject: add possibility to separately set fan voltage and fan pwm for standby and normal run when a recording starts in standby switch to normal mode and vice versa this fixes bug #430 (thx to Dr.Best) --- lib/python/Components/FanControl.py | 43 ++++++++++++++++++---- .../Plugins/SystemPlugins/TempFanControl/plugin.py | 22 +++++++---- 2 files changed, 50 insertions(+), 15 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Components/FanControl.py b/lib/python/Components/FanControl.py index cee0523e..a993c396 100644 --- a/lib/python/Components/FanControl.py +++ b/lib/python/Components/FanControl.py @@ -3,6 +3,9 @@ import os from Components.config import config, ConfigSubList, ConfigSubsection, ConfigSlider from Tools.BoundFunction import boundFunction +import NavigationInstance +from enigma import iRecordableService + class FanControl: # ATM there's only support for one fan def __init__(self): @@ -13,18 +16,42 @@ class FanControl: self.createConfig() config.misc.standbyCounter.addNotifier(self.standbyCounterChanged, initial_call = False) - def leaveStandby(self): + def setVoltage_PWM(self): for fanid in range(self.getFanCount()): cfg = self.getConfig(fanid) self.setVoltage(fanid, cfg.vlt.value) self.setPWM(fanid, cfg.pwm.value) + print "[FanControl]: setting fan values: fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt.value, cfg.pwm.value) + + def setVoltage_PWM_Standby(self): + for fanid in range(self.getFanCount()): + cfg = self.getConfig(fanid) + self.setVoltage(fanid, cfg.vlt_standby.value) + self.setPWM(fanid, cfg.pwm_standby.value) + print "[FanControl]: setting fan values (standby mode): fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt_standby.value, cfg.pwm_standby.value) + + def getRecordEvent(self, recservice, event): + recordings = len(NavigationInstance.instance.getRecordings()) + if event == iRecordableService.evEnd: + if recordings == 0: + self.setVoltage_PWM_Standby() + elif event == iRecordableService.evStart: + if recordings == 1: + self.setVoltage_PWM() + + def leaveStandby(self): + NavigationInstance.instance.record_event.remove(self.getRecordEvent) + recordings = NavigationInstance.instance.getRecordings() + if not recordings: + self.setVoltage_PWM() def standbyCounterChanged(self, configElement): from Screens.Standby import inStandby inStandby.onClose.append(self.leaveStandby) - for fanid in range(self.getFanCount()): - self.setVoltage(fanid, 0) - self.setPWM(fanid, 0) + recordings = NavigationInstance.instance.getRecordings() + NavigationInstance.instance.record_event.append(self.getRecordEvent) + if not recordings: + self.setVoltage_PWM_Standby() def createConfig(self): def setVlt(fancontrol, fanid, configElement): @@ -35,12 +62,14 @@ class FanControl: config.fans = ConfigSubList() for fanid in range(self.getFanCount()): fan = ConfigSubsection() - fan.vlt = ConfigSlider(default = 16, increment = 5, limits = (0, 255)) + fan.vlt = ConfigSlider(default = 15, increment = 5, limits = (0, 255)) fan.pwm = ConfigSlider(default = 0, increment = 5, limits = (0, 255)) + fan.vlt_standby = ConfigSlider(default = 5, increment = 5, limits = (0, 255)) + fan.pwm_standby = ConfigSlider(default = 0, increment = 5, limits = (0, 255)) fan.vlt.addNotifier(boundFunction(setVlt, self, fanid)) fan.pwm.addNotifier(boundFunction(setPWM, self, fanid)) config.fans.append(fan) - + def getConfig(self, fanid): return config.fans[fanid] @@ -85,4 +114,4 @@ class FanControl: f.write("%x" % value) f.close() -fancontrol = FanControl() \ No newline at end of file +fancontrol = FanControl() diff --git a/lib/python/Plugins/SystemPlugins/TempFanControl/plugin.py b/lib/python/Plugins/SystemPlugins/TempFanControl/plugin.py index 38e343f9..c8af9cdd 100644 --- a/lib/python/Plugins/SystemPlugins/TempFanControl/plugin.py +++ b/lib/python/Plugins/SystemPlugins/TempFanControl/plugin.py @@ -12,7 +12,7 @@ from Components.FanControl import fancontrol class TempFanControl(Screen, ConfigListScreen): skin = """ - + @@ -22,7 +22,7 @@ class TempFanControl(Screen, ConfigListScreen): - + @@ -90,7 +90,7 @@ class TempFanControl(Screen, ConfigListScreen): """ - + def __init__(self, session, args = None): Screen.__init__(self, session) @@ -125,6 +125,9 @@ class TempFanControl(Screen, ConfigListScreen): for count in range(fancontrol.getFanCount()): self.list.append(getConfigListEntry(_("Fan %d Voltage") % (count + 1), fancontrol.getConfig(count).vlt)) self.list.append(getConfigListEntry(_("Fan %d PWM") % (count + 1), fancontrol.getConfig(count).pwm)) + self.list.append(getConfigListEntry(_("Standby Fan %d Voltage") % (count + 1), fancontrol.getConfig(count).vlt_standby)) + self.list.append(getConfigListEntry(_("Standby Fan %d PWM") % (count + 1), fancontrol.getConfig(count).pwm_standby)) + ConfigListScreen.__init__(self, self.list, session = self.session) #self["config"].list = self.list #self["config"].setList(self.list) @@ -136,28 +139,31 @@ class TempFanControl(Screen, ConfigListScreen): "red": self.revert, "green": self.save }, -1) - + def save(self): for count in range(fancontrol.getFanCount()): fancontrol.getConfig(count).vlt.save() fancontrol.getConfig(count).pwm.save() + fancontrol.getConfig(count).vlt_standby.save() + fancontrol.getConfig(count).pwm_standby.save() self.close() - + def revert(self): for count in range(fancontrol.getFanCount()): fancontrol.getConfig(count).vlt.load() fancontrol.getConfig(count).pwm.load() + fancontrol.getConfig(count).vlt_standby.load() + fancontrol.getConfig(count).pwm_standby.load() self.close() - + def main(session, **kwargs): session.open(TempFanControl) def startMenu(menuid): if menuid != "system": return [] - return [(_("Temperature and Fan control"), main, "tempfancontrol", 80)] def Plugins(**kwargs): return PluginDescriptor(name = "Temperature and Fan control", description = _("Temperature and Fan control"), where = PluginDescriptor.WHERE_MENU, fnc = startMenu) - \ No newline at end of file + -- cgit v1.2.3 From a031db45bbf074b66ee62da2d5ecad8785b5b156 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 29 Mar 2010 19:02:03 +0200 Subject: lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.h/cpp: add support for autoresolution plugins (needs new libdreamdvd) this fixes bug #302 --- .../Extensions/DVDPlayer/src/servicedvd.cpp | 47 +++++++++++++++++++--- .../Plugins/Extensions/DVDPlayer/src/servicedvd.h | 2 + 2 files changed, 43 insertions(+), 6 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp index 0372c497..2ba53927 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp +++ b/lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp @@ -85,12 +85,9 @@ RESULT eServiceFactoryDVD::offlineOperations(const eServiceReference &, ePtr Date: Tue, 30 Mar 2010 10:43:54 +0200 Subject: * disable PluginManagers ipkg update on e2 start, better do it when needed. This fixes #494 --- lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 4dbe7f70..4917855f 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -420,7 +420,7 @@ class PluginManager(Screen, DreamInfoHandler): def getUpdateInfos(self): self.setState('update') - iSoftwareTools.getUpdates(self.getUpdateInfosCB) + iSoftwareTools.startSoftwareTools(self.getUpdateInfosCB) def getUpdateInfosCB(self, retval = None): if retval is not None: @@ -429,9 +429,10 @@ class PluginManager(Screen, DreamInfoHandler): self["status"].setText(_("There are at least ") + str(iSoftwareTools.available_updates) + _(" updates available.")) else: self["status"].setText(_("There are no updates available.")) + self.rebuildList() elif retval is False: + self.setState('error') self["status"].setText(_("No network connection available.")) - self.rebuildList() def rebuildList(self, retval = None): if self.currentSelectedTag is None: @@ -1701,15 +1702,11 @@ def startSetup(menuid): return [ ] return [(_("Software management"), UpgradeMain, "software_manager", 50)] -def autostart(reason, **kwargs): - if reason is True: - iSoftwareTools.startSoftwareTools() def Plugins(path, **kwargs): global plugin_path plugin_path = path list = [ - PluginDescriptor(where = [PluginDescriptor.WHERE_NETWORKCONFIG_READ], fnc = autostart), PluginDescriptor(name=_("Software management"), description=_("Manage your receiver's software"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup), PluginDescriptor(name=_("Ipkg"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan) ] -- cgit v1.2.3 From aa7e54fc4db217a7732f208af6f3e5a2e0bd6773 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 30 Mar 2010 15:37:07 +0200 Subject: [DVDBurn] usability improvements: title list layout, bottom info area, consistency of user interface, implement restoring of saved collections from xml (fixes #316) --- .../Plugins/Extensions/DVDBurn/DVDProject.py | 102 +++++++++++++------- lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py | 28 ++++-- .../Plugins/Extensions/DVDBurn/ProjectSettings.py | 23 +++-- .../Plugins/Extensions/DVDBurn/TitleCutter.py | 20 ++++ lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 105 +++++++++++++-------- .../Plugins/Extensions/DVDBurn/TitleProperties.py | 13 ++- 6 files changed, 201 insertions(+), 90 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py index 83672460..7f755db4 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDProject.py @@ -1,5 +1,7 @@ from Tools.Directories import fileExists from Components.config import config, ConfigSubsection, ConfigInteger, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence, ConfigSubList +import DVDTitle +import xml.dom.minidom class ConfigColor(ConfigSequence): def __init__(self, default = [128,128,128]): @@ -10,7 +12,10 @@ class ConfigFilename(ConfigText): ConfigText.__init__(self, default = "", fixed_size = True, visible_width = False) def getMulti(self, selected): - filename = (self.text.rstrip("/").rsplit("/",1))[1].encode("utf-8")[:40] + " " + if self.text == "": + return ("mtext"[1-selected:], "", 0) + cut_len = min(len(self.text),40) + filename = (self.text.rstrip("/").rsplit("/",1))[1].encode("utf-8")[:cut_len] + " " if self.allmarked: mark = range(0, len(filename)) else: @@ -34,10 +39,11 @@ class DVDProject: self.settings.vmgm = ConfigFilename() self.filekeys = ["vmgm", "isopath", "menutemplate"] self.menutemplate = MenuTemplate() + self.error = "" + self.session = None def addService(self, service): - import DVDTitle - title = DVDTitle.DVDTitle() + title = DVDTitle.DVDTitle(self) title.addService(service) self.titles.append(title) return title @@ -100,47 +106,78 @@ class DVDProject: return ret def loadProject(self, filename): - import xml.dom.minidom - try: + #try: if not fileExists(filename): self.error = "xml file not found!" - raise AttributeError - else: - self.error = "" + #raise AttributeError file = open(filename, "r") data = file.read().decode("utf-8").replace('&',"&").encode("ascii",'xmlcharrefreplace') file.close() projectfiledom = xml.dom.minidom.parseString(data) - for project in projectfiledom.childNodes[0].childNodes: - if project.nodeType == xml.dom.minidom.Element.nodeType: - if project.tagName == 'settings': - i = 0 - if project.attributes.length < len(self.settings.dict())-1: - self.error = "project attributes missing" - raise AttributeError - while i < project.attributes.length: - item = project.attributes.item(i) - key = item.name.encode("utf-8") - try: - val = eval(item.nodeValue) - except (NameError, SyntaxError): - val = item.nodeValue.encode("utf-8") - try: - self.settings.dict()[key].setValue(val) - except (KeyError): - self.error = "unknown attribute '%s'" % (key) - raise AttributeError - i += 1 + for node in projectfiledom.childNodes[0].childNodes: + print "node:", node + if node.nodeType == xml.dom.minidom.Element.nodeType: + if node.tagName == 'settings': + self.xmlAttributesToConfig(node, self.settings) + elif node.tagName == 'titles': + self.xmlGetTitleNodeRecursive(node) + for key in self.filekeys: val = self.settings.dict()[key].getValue() if not fileExists(val): self.error += "\n%s '%s' not found" % (key, val) - if len(self.error): - raise AttributeError + #except AttributeError: + #print "loadProject AttributeError", self.error + #self.error += (" in project '%s'") % (filename) + #return False + return True + + def xmlAttributesToConfig(self, node, config): + try: + i = 0 + #if node.attributes.length < len(config.dict())-1: + #self.error = "project attributes missing" + #raise AttributeError + while i < node.attributes.length: + item = node.attributes.item(i) + key = item.name.encode("utf-8") + try: + val = eval(item.nodeValue) + except (NameError, SyntaxError): + val = item.nodeValue.encode("utf-8") + try: + print "config[%s].setValue(%s)" % (key, val) + config.dict()[key].setValue(val) + except (KeyError): + self.error = "unknown attribute '%s'" % (key) + print "KeyError", self.error + raise AttributeError + i += 1 except AttributeError: - self.error += (" in project '%s'") % (filename) + self.error += (" XML attribute error '%s'") % node.toxml() return False - return True + + def xmlGetTitleNodeRecursive(self, node, title_idx = -1): + print "[xmlGetTitleNodeRecursive]", title_idx, node + print node.childNodes + for subnode in node.childNodes: + print "xmlGetTitleNodeRecursive subnode:", subnode + if subnode.nodeType == xml.dom.minidom.Element.nodeType: + if subnode.tagName == 'title': + title_idx += 1 + title = DVDTitle.DVDTitle(self) + self.titles.append(title) + self.xmlGetTitleNodeRecursive(subnode, title_idx) + if subnode.tagName == 'path': + print "path:", subnode.firstChild.data + filename = subnode.firstChild.data + self.titles[title_idx].addFile(filename.encode("utf-8")) + if subnode.tagName == 'properties': + self.xmlAttributesToConfig(node, self.titles[title_idx].properties) + if subnode.tagName == 'audiotracks': + self.xmlGetTitleNodeRecursive(subnode, title_idx) + if subnode.tagName == 'audiotrack': + print "audiotrack...", subnode.toxml() def getSize(self): totalsize = 0 @@ -187,6 +224,7 @@ class MenuTemplate(DVDProject): self.filekeys = ["menubg", "menuaudio", "fontface_headline", "fontface_title", "fontface_subtitle"] from TitleProperties import languageChoices self.settings.menulang = ConfigSelection(choices = languageChoices.choices, default=languageChoices.choices[1][0]) + self.error = "" def loadTemplate(self, filename): ret = DVDProject.loadProject(self, filename) diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py b/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py index 660005e6..6dff00d6 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py @@ -1,4 +1,5 @@ from Components.config import config, ConfigSubsection, ConfigSubList, ConfigInteger, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence, ConfigYesNo +import TitleCutter class ConfigFixedText(ConfigText): def __init__(self, text, visible_width=60): @@ -7,17 +8,17 @@ class ConfigFixedText(ConfigText): pass class DVDTitle: - def __init__(self): + def __init__(self, project): self.properties = ConfigSubsection() self.properties.menutitle = ConfigText(fixed_size = False, visible_width = 80) self.properties.menusubtitle = ConfigText(fixed_size = False, visible_width = 80) - self.DVBname = _("Title") - self.DVBdescr = _("Description") - self.DVBchannel = _("Channel") self.properties.aspect = ConfigSelection(choices = [("4:3", _("4:3")), ("16:9", _("16:9"))]) self.properties.widescreen = ConfigSelection(choices = [("nopanscan", "nopanscan"), ("noletterbox", "noletterbox")]) self.properties.autochapter = ConfigInteger(default = 0, limits = (0, 60)) self.properties.audiotracks = ConfigSubList() + self.DVBname = _("Title") + self.DVBdescr = _("Description") + self.DVBchannel = _("Channel") self.cuesheet = [ ] self.source = None self.filesize = 0 @@ -27,6 +28,8 @@ class DVDTitle: self.chaptermarks = [ ] self.timeCreate = None self.VideoType = -1 + self.project = project + self.length = 0 def addService(self, service): from os import path @@ -36,7 +39,7 @@ class DVDTitle: self.source = service serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(service) - sDescr = info and " " + info.getInfoString(service, iServiceInformation.sDescription) or "" + sDescr = info and info.getInfoString(service, iServiceInformation.sDescription) or "" self.DVBdescr = sDescr sTimeCreate = info.getInfo(service, iServiceInformation.sTimeCreate) if sTimeCreate > 1: @@ -49,9 +52,20 @@ class DVDTitle: self.filesize = path.getsize(self.inputfile) self.estimatedDiskspace = self.filesize self.length = info.getLength(service) + + def addFile(self, filename): + from enigma import eServiceReference + ref = eServiceReference(1, 0, filename) + self.addService(ref) + self.project.session.openWithCallback(self.titleEditDone, TitleCutter.CutlistReader, self) + + def titleEditDone(self, cutlist): + self.initDVDmenuText(len(self.project.titles)) + self.cuesheet = cutlist + self.produceFinalCuesheet() - def initDVDmenuText(self, project, track): - s = project.menutemplate.settings + def initDVDmenuText(self, track): + s = self.project.menutemplate.settings self.properties.menutitle.setValue(self.formatDVDmenuText(s.titleformat.getValue(), track)) self.properties.menusubtitle.setValue(self.formatDVDmenuText(s.subtitleformat.getValue(), track)) diff --git a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py index a1c38842..39d7277e 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py +++ b/lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py @@ -92,10 +92,10 @@ class ProjectSettings(Screen,ConfigListScreen): - - - - + + + + @@ -233,10 +233,19 @@ class ProjectSettings(Screen,ConfigListScreen): else: self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) elif scope == "project": - if self.project.loadProject(path): - self.initConfigList() + self.path = path + print "len(self.titles)", len(self.project.titles) + if len(self.project.titles): + self.session.openWithCallback(self.askLoadCB, MessageBox,text = _("Your current collection will get lost!") + "\n" + _("Do you want to restore your settings?"), type = MessageBox.TYPE_YESNO) else: - self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) + self.askLoadCB(True) elif scope: configRef.setValue(path) self.initConfigList() + + def askLoadCB(self, answer): + if answer is not None and answer: + if self.project.loadProject(self.path): + self.initConfigList() + else: + self.session.open(MessageBox,self.project.error,MessageBox.TYPE_ERROR) \ No newline at end of file diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py b/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py index 06ed1bab..a52fad9f 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py @@ -59,8 +59,28 @@ class TitleCutter(CutListEditor): self.close(self.cut_list[:]) class CutlistReader(TitleCutter): + skin = """ + + + + + + + {"template": [ + MultiContentEntryText(text = 1), + MultiContentEntryText(text = 2) + ], + "fonts": [gFont("Regular", 18)], + "itemHeight": 20 + } + + + + """ + def __init__(self, session, t): TitleCutter.__init__(self, session, t) + self.skin = CutlistReader.skin def getPMTInfo(self): TitleCutter.getPMTInfo(self) diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index dbc988b1..35a95d52 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -16,33 +16,40 @@ from Tools.Directories import resolveFilename, SCOPE_PLUGINS class TitleList(Screen, HelpableScreen): skin = """ - + - - - - + + + + - - + + {"template": [ MultiContentEntryText(pos = (0, 0), size = (420, 20), font = 0, flags = RT_HALIGN_LEFT, text = 1), # index 1 Title, MultiContentEntryText(pos = (0, 20), size = (328, 17), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 description, - MultiContentEntryText(pos = (420, 6), size = (120, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 3), # index 3 begin time, - MultiContentEntryText(pos = (328, 20), size = (154, 17), font = 1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 channel, - MultiContentEntryText(pos = (482, 20), size = (58, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # index 4 channel, + MultiContentEntryText(pos = (418, 6), size = (120, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 3), # index 3 channel, + MultiContentEntryText(pos = (326, 20), size = (154, 17), font = 1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 begin time, + MultiContentEntryText(pos = (480, 20), size = (58, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # index 5 duration, ], "fonts": [gFont("Regular", 20), gFont("Regular", 14)], "itemHeight": 37 } - - + + + + + + + + + """ def __init__(self, session, project = None): @@ -75,17 +82,19 @@ class TitleList(Screen, HelpableScreen): self["title_label"] = StaticText() self["error_label"] = StaticText() - self["space_label"] = StaticText() - self["space_bar"] = Progress() + self["space_label_single"] = StaticText() + self["space_label_dual"] = StaticText() + self["hint"] = StaticText(_("Advanced Options")) + self["medium"] = StaticText() + self["space_bar_single"] = Progress() + self["space_bar_dual"] = Progress() + self["titles"] = List([]) + self.previous_size = 0 if project is not None: self.project = project else: self.newProject() - - self["titles"] = List([]) - self.updateTitleList() - self.previous_size = 0 self.onLayoutFinish.append(self.layoutFinished) def layoutFinished(self): @@ -107,15 +116,16 @@ class TitleList(Screen, HelpableScreen): j = self.backgroundJob menu.append(("%s: %s (%d%%)" % (j.getStatustext(), j.name, int(100*j.progress/float(j.end))), self.showBackgroundJob)) menu.append((_("DVD media toolbox"), self.toolbox)) - menu.append((_("Preview menu"), self.previewMenu)) if self.project.settings.output.getValue() == "dvd": if len(self["titles"].list): menu.append((_("Burn DVD"), self.burnProject)) elif self.project.settings.output.getValue() == "iso": menu.append((_("Create DVD-ISO"), self.burnProject)) menu.append((_("Burn existing image to DVD"), self.selectImage)) - menu.append((_("Edit chapters of current title"), self.editTitle)) - menu.append((_("Reset and renumerate title names"), self.resetTitles)) + if len(self["titles"].list): + menu.append((_("Preview menu"), self.previewMenu)) + menu.append((_("Edit chapters of current title"), self.editTitle)) + menu.append((_("Reset and renumerate title names"), self.resetTitles)) menu.append((_("Exit"), self.leave)) self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu) @@ -149,9 +159,9 @@ class TitleList(Screen, HelpableScreen): - - - + + + @@ -197,7 +207,7 @@ class TitleList(Screen, HelpableScreen): self.close(current) self.session.openWithCallback(self.selectedSource, DVDMovieSelection) - def selectedSource(self, source): + def selectedSource(self, source = None): if source is None: return None if not source.getPath().endswith(".ts"): @@ -228,7 +238,7 @@ class TitleList(Screen, HelpableScreen): def settingsCB(self, update=True): if not update: return - self["title_label"].text = _("Table of content for collection") + " \"" + self.project.settings.name.getValue() + "\":" + self.updateTitleList() def loadTemplate(self): filename = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/DreamboxDVD.ddvdp.xml" @@ -281,9 +291,11 @@ class TitleList(Screen, HelpableScreen): if len(list): self["key_red"].text = _("Remove title") self["key_yellow"].text = _("Title properties") + self["title_label"].text = _("Table of content for collection") + " \"" + self.project.settings.name.getValue() + "\":" else: self["key_red"].text = "" self["key_yellow"].text = "" + self["title_label"].text = _("Please add titles to the compilation") def updateSize(self): size = self.project.size/(1024*1024) @@ -292,20 +304,29 @@ class TitleList(Screen, HelpableScreen): print "updateSize:", size, "MAX_DL:", MAX_DL, "MAX_SL:", MAX_SL if size > MAX_DL: percent = 100 * size / float(MAX_DL) - self["space_label"].text = "%d MB - " % size + _("exceeds dual layer medium!") + " (%.2f%% " % (100-percent) + _("free") + ")" - self["space_bar"].value = int(percent) + self["space_label_dual"].text = "%d MB (%.2f%%)" % (size, percent) + self["space_bar_dual"].value = int(percent) + self["space_bar_single"].value = 100 + self["space_label_single"].text = "" + self["medium"].text = _("exceeds dual layer medium!") if self.previous_size < MAX_DL: self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR) elif size > MAX_SL: percent = 100 * size / float(MAX_DL) - self["space_label"].text = "%d MB " % size + _("of a DUAL layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")" - self["space_bar"].value = int(percent) + self["space_label_dual"].text = "%d MB (%.2f%%)" % (size, percent) + self["space_bar_dual"].value = int(percent) + self["space_bar_single"].value = 100 + self["space_label_single"].text = "" + self["medium"].text = _("required medium type:") + " " + _("DUAL LAYER DVD") + ", %d MB " % (MAX_DL - size) + _("free") if self.previous_size < MAX_SL: - self.session.open(MessageBox,text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), type = MessageBox.TYPE_INFO) + self.session.open(MessageBox, text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), timeout = 10, type = MessageBox.TYPE_INFO) elif size < MAX_SL: percent = 100 * size / float(MAX_SL) - self["space_label"].text = "%d MB " % size + _("of a SINGLE layer medium used.") + " (%.2f%% " % (100-percent) + _("free") + ")" - self["space_bar"].value = int(percent) + self["space_label_single"].text = "%d MB (%.2f%%)" % (size, percent) + self["space_bar_single"].value = int(percent) + self["space_bar_dual"].value = 0 + self["space_label_dual"].text = "" + self["medium"].text = _("required medium type:") + " " + _("SINGLE LAYER DVD") + ", %d MB " % (MAX_SL - size) + _("free") self.previous_size = size def getCurrentTitle(self): @@ -323,9 +344,7 @@ class TitleList(Screen, HelpableScreen): def titleEditDone(self, cutlist): t = self.current_edit_title - t.initDVDmenuText(self.project,len(self.project.titles)) - t.cuesheet = cutlist - t.produceFinalCuesheet() + t.titleEditDone(cutlist) if t.VideoType != 0: self.session.openWithCallback(self.DVDformatCB,MessageBox,text = _("The DVD standard doesn't support H.264 (HDTV) video streams. Do you want to create a Dreambox format data DVD (which will not play in stand-alone DVD players) instead?"), type = MessageBox.TYPE_YESNO) else: @@ -335,7 +354,7 @@ class TitleList(Screen, HelpableScreen): count = 0 for title in self.project.titles: count += 1 - title.initDVDmenuText(self.project,count) + title.initDVDmenuText(count) self.updateTitleList() def DVDformatCB(self, answer): @@ -346,5 +365,13 @@ class TitleList(Screen, HelpableScreen): else: self.removeTitle(t) - def leave(self): - self.close() + def leave(self, close = False): + if not len(self["titles"].list) or close: + self.close() + else: + self.session.openWithCallback(self.exitCB, MessageBox,text = _("Your current collection will get lost!") + "\n" + _("Do you really want to exit?"), type = MessageBox.TYPE_YESNO) + + def exitCB(self, answer): + print "exitCB", answer + if answer is not None and answer: + self.close() \ No newline at end of file diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py index 0a664eba..956f054d 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py @@ -21,10 +21,12 @@ class TitleProperties(Screen,ConfigListScreen): + - - - + + + + @@ -38,7 +40,8 @@ class TitleProperties(Screen,ConfigListScreen): self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) - self["key_blue"] = StaticText(_("Edit Title")) + self["key_yellow"] = StaticText(_("Edit Title")) + self["key_blue"] = StaticText() self["serviceinfo"] = StaticText() self["thumbnail"] = Pixmap() @@ -57,7 +60,7 @@ class TitleProperties(Screen,ConfigListScreen): { "green": self.exit, "red": self.cancel, - "blue": self.editTitle, + "yellow": self.editTitle, "cancel": self.cancel, "ok": self.ok, }, -2) -- cgit v1.2.3 From c15fe7a4031395509b94140764a79adc5ac678da Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 30 Mar 2010 17:40:35 +0200 Subject: [DVDBurn] use multicolor lable for required medium type (add #316) --- lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index 35a95d52..ac60906b 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -11,6 +11,7 @@ from Components.Sources.List import List from Components.Sources.StaticText import StaticText from Components.Sources.Progress import Progress from Components.MultiContent import MultiContentEntryText +from Components.Label import MultiColorLabel from enigma import gFont, RT_HALIGN_LEFT, RT_HALIGN_RIGHT from Tools.Directories import resolveFilename, SCOPE_PLUGINS @@ -44,7 +45,7 @@ class TitleList(Screen, HelpableScreen): - + @@ -85,7 +86,7 @@ class TitleList(Screen, HelpableScreen): self["space_label_single"] = StaticText() self["space_label_dual"] = StaticText() self["hint"] = StaticText(_("Advanced Options")) - self["medium"] = StaticText() + self["medium_label"] = MultiColorLabel() self["space_bar_single"] = Progress() self["space_bar_dual"] = Progress() @@ -308,7 +309,8 @@ class TitleList(Screen, HelpableScreen): self["space_bar_dual"].value = int(percent) self["space_bar_single"].value = 100 self["space_label_single"].text = "" - self["medium"].text = _("exceeds dual layer medium!") + self["medium_label"].setText(_("exceeds dual layer medium!")) + self["medium_label"].setForegroundColorNum(2) if self.previous_size < MAX_DL: self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR) elif size > MAX_SL: @@ -317,7 +319,8 @@ class TitleList(Screen, HelpableScreen): self["space_bar_dual"].value = int(percent) self["space_bar_single"].value = 100 self["space_label_single"].text = "" - self["medium"].text = _("required medium type:") + " " + _("DUAL LAYER DVD") + ", %d MB " % (MAX_DL - size) + _("free") + self["medium_label"].setText(_("required medium type:") + " " + _("DUAL LAYER DVD") + ", %d MB " % (MAX_DL - size) + _("free")) + self["medium_label"].setForegroundColorNum(1) if self.previous_size < MAX_SL: self.session.open(MessageBox, text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), timeout = 10, type = MessageBox.TYPE_INFO) elif size < MAX_SL: @@ -326,7 +329,8 @@ class TitleList(Screen, HelpableScreen): self["space_bar_single"].value = int(percent) self["space_bar_dual"].value = 0 self["space_label_dual"].text = "" - self["medium"].text = _("required medium type:") + " " + _("SINGLE LAYER DVD") + ", %d MB " % (MAX_SL - size) + _("free") + self["medium_label"].setText(_("required medium type:") + " " + _("SINGLE LAYER DVD") + ", %d MB " % (MAX_SL - size) + _("free")) + self["medium_label"].setForegroundColorNum(0) self.previous_size = size def getCurrentTitle(self): -- cgit v1.2.3 From 469203620ff992decefb8942a79eb4ebfacf32d1 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 30 Mar 2010 17:18:07 +0200 Subject: [DVDBurn] remove "..." at menu entry string --- lib/python/Plugins/Extensions/DVDBurn/plugin.py | 2 +- po/de.po | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/plugin.py b/lib/python/Plugins/Extensions/DVDBurn/plugin.py index 45f438da..bd856b47 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/plugin.py +++ b/lib/python/Plugins/Extensions/DVDBurn/plugin.py @@ -12,6 +12,6 @@ def main_add(session, service, **kwargs): dvdburn.selectedSource(service) def Plugins(**kwargs): - descr = _("Burn to DVD...") + descr = _("Burn to DVD") return [PluginDescriptor(name="DVD Burn", description=descr, where = PluginDescriptor.WHERE_MOVIELIST, fnc=main_add, icon="dvdburn.png"), PluginDescriptor(name="DVD Burn", description=descr, where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main, icon="dvdburn.png") ] diff --git a/po/de.po b/po/de.po index 90170425..4de23c16 100755 --- a/po/de.po +++ b/po/de.po @@ -725,8 +725,8 @@ msgstr "Brenne DVD" msgid "Burn existing image to DVD" msgstr "Vorhandenes Image auf DVD brennen" -msgid "Burn to DVD..." -msgstr "Auf DVD brennen..." +msgid "Burn to DVD" +msgstr "Auf DVD brennen" msgid "Bus: " msgstr "Bus:" -- cgit v1.2.3 From 04d23246dd5c88df949d523e0c149be8070a0a96 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 1 Feb 2010 23:30:36 +0100 Subject: fix screen layout, add configuration restore wizard code in flasher and fix crash when trying to use wizard with no .nfo file present, fixes bug #394 --- .../Plugins/SystemPlugins/NFIFlash/flasher.py | 84 ++++++++++++++++++---- 1 file changed, 71 insertions(+), 13 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py index 860efc02..8986560b 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py @@ -63,10 +63,10 @@ class NFIFlash(Screen): - - - - + + + + @@ -95,6 +95,7 @@ class NFIFlash(Screen): { "green": self.ok, "yellow": self.reboot, + "blue": self.runWizard, "ok": self.ok, "left": self.left, "right": self.right, @@ -109,6 +110,43 @@ class NFIFlash(Screen): self.md5sum = "" self.job = None self.box = HardwareInfo().get_device_name() + self.configuration_restorable = None + self.wizard_mode = False + from enigma import eTimer + self.delayTimer = eTimer() + self.delayTimer.callback.append(self.runWizard) + self.delayTimer.start(50,1) + + def check_for_wizard(self): + if self["filelist"].getCurrentDirectory() is not None and fileExists(self["filelist"].getCurrentDirectory()+"wizard.nfo"): + self["key_blue"].text = _("USB stick wizard") + return True + else: + self["key_blue"].text = "" + return False + + def runWizard(self): + if not self.check_for_wizard(): + self.wizard_mode = False + return + wizardcontent = open(self["filelist"].getCurrentDirectory()+"/wizard.nfo", "r").readlines() + nfifile = None + for line in wizardcontent: + line = line.strip() + if line.startswith("image: "): + nfifile = self["filelist"].getCurrentDirectory()+line[7:] + if line.startswith("configuration: "): + backupfile = self["filelist"].getCurrentDirectory()+line[15:] + if fileExists(backupfile): + print "wizard configuration:", backupfile + self.configuration_restorable = backupfile + else: + self.configuration_restorable = None + if nfifile and fileExists(nfifile): + self.wizard_mode = True + print "wizard image:", nfifile + self.check_for_NFO(nfifile) + self.queryFlash() def closeCB(self): if ( self.job is None or self.job.status is not self.job.IN_PROGRESS ) and not self.no_autostart: @@ -133,12 +171,16 @@ class NFIFlash(Screen): self["filelist"].pageUp() self.check_for_NFO() - def check_for_NFO(self): + def check_for_NFO(self, nfifile=None): self.session.summary.setText(self["filelist"].getFilename()) - if self["filelist"].getFilename() is None: - return - if self["filelist"].getCurrentDirectory() is not None: - self.nfifile = self["filelist"].getCurrentDirectory()+self["filelist"].getFilename() + if nfifile is None: + self.session.summary.setText(self["filelist"].getFilename()) + if self["filelist"].getFilename() is None: + return + if self["filelist"].getCurrentDirectory() is not None: + self.nfifile = self["filelist"].getCurrentDirectory()+self["filelist"].getFilename() + else: + self.nfifile = nfifile if self.nfifile.upper().endswith(".NFI"): self["key_green"].text = _("Flash") @@ -152,7 +194,7 @@ class NFIFlash(Screen): else: self.md5sum = "" else: - self["infolabel"].text = _("No details for this image file") + ":\n" + self["filelist"].getFilename() + self["infolabel"].text = _("No details for this image file") + (self["filelist"].getFilename() or "") self.md5sum = "" else: self["infolabel"].text = "" @@ -164,6 +206,7 @@ class NFIFlash(Screen): self["filelist"].descent() self.session.summary.setText(self["filelist"].getFilename()) self.check_for_NFO() + self.check_for_wizard() else: self.queryFlash() @@ -192,7 +235,10 @@ class NFIFlash(Screen): def md5finished(self, retval): if retval==0: - self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file has a valid md5 signature. Continue programming this image to flash memory?"), MessageBox.TYPE_YESNO) + if self.wizard_mode: + self.session.openWithCallback(self.queryCB, MessageBox, _("Shall the USB stick wizard proceed and program the image file %s into flash memory?" % self.nfifile.rsplit('/',1)[-1]), MessageBox.TYPE_YESNO) + else: + self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file has a valid md5 signature. Continue programming this image to flash memory?"), MessageBox.TYPE_YESNO) else: self.session.openWithCallback(self.queryCB, MessageBox, _("The md5sum validation failed, the file may be corrupted! Are you sure that you want to burn this image to flash memory? You are doing this at your own risk!"), MessageBox.TYPE_YESNO) @@ -201,6 +247,7 @@ class NFIFlash(Screen): self.createJob() else: self["statusbar"].text = _("Please select .NFI flash image file from medium") + self.wizard_mode = False def createJob(self): self.job = Job("Image flashing job") @@ -240,6 +287,8 @@ class NFIFlash(Screen): elif j.status == j.FINISHED: self["statusbar"].text = _("Writing NFI image file to flash completed") self.session.summary.setText(_("NFI image flashing completed. Press Yellow to Reboot!")) + if self.wizard_mode: + self.restoreConfiguration() self["key_yellow"].text = _("Reboot") elif j.status == j.FAILED: @@ -250,10 +299,19 @@ class NFIFlash(Screen): print "[jobcb] %s %s %s" % (jobref, fasel, blubber) self["key_green"].text = _("Flash") - def reboot(self): + def reboot(self, ret=None): if self.job.status == self.job.FINISHED: self["statusbar"].text = ("rebooting...") TryQuitMainloop(self.session,2) - + + def restoreConfiguration(self): + if self.configuration_restorable: + from Screens.Console import Console + cmdlist = [ "mount /dev/mtdblock/3 /mnt/realroot -t jffs2", "tar -xzvf " + self.configuration_restorable + " -C /mnt/realroot/" ] + self.session.open(Console, title = "Restore running", cmdlist = cmdlist, finishedCallback = self.restore_finished, closeOnSuccess = True) + + def restore_finished(self): + self.session.openWithCallback(self.reboot, MessageBox, _("USB stick wizard finished. Your dreambox will now restart with your new image!"), MessageBox.TYPE_INFO) + def createSummary(self): return NFISummary -- cgit v1.2.3 From 16e2662171701ce64bf2e789168e8cee54dc8588 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 31 Mar 2010 15:26:23 +0200 Subject: [DVDBurn] fix up title list layout and change some more strings (add #316) --- lib/python/Plugins/Extensions/DVDBurn/TitleList.py | 20 ++++++++++---------- po/de.po | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py index ac60906b..2cbeb633 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleList.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleList.py @@ -31,11 +31,11 @@ class TitleList(Screen, HelpableScreen): {"template": [ - MultiContentEntryText(pos = (0, 0), size = (420, 20), font = 0, flags = RT_HALIGN_LEFT, text = 1), # index 1 Title, - MultiContentEntryText(pos = (0, 20), size = (328, 17), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 description, - MultiContentEntryText(pos = (418, 6), size = (120, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 3), # index 3 channel, - MultiContentEntryText(pos = (326, 20), size = (154, 17), font = 1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 begin time, - MultiContentEntryText(pos = (480, 20), size = (58, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # index 5 duration, + MultiContentEntryText(pos = (0, 0), size = (360, 20), font = 0, flags = RT_HALIGN_LEFT, text = 1), # index 1 Title, + MultiContentEntryText(pos = (0, 20), size = (360, 17), font = 1, flags = RT_HALIGN_LEFT, text = 2), # index 2 description, + MultiContentEntryText(pos = (366, 6), size = (152, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 3), # index 3 channel, + MultiContentEntryText(pos = (366, 20), size = (102, 17), font = 1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 begin time, + MultiContentEntryText(pos = (470, 20), size = (48, 20), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # index 5 duration, ], "fonts": [gFont("Regular", 20), gFont("Regular", 14)], "itemHeight": 37 @@ -296,7 +296,7 @@ class TitleList(Screen, HelpableScreen): else: self["key_red"].text = "" self["key_yellow"].text = "" - self["title_label"].text = _("Please add titles to the compilation") + self["title_label"].text = _("Please add titles to the compilation.") def updateSize(self): size = self.project.size/(1024*1024) @@ -309,17 +309,17 @@ class TitleList(Screen, HelpableScreen): self["space_bar_dual"].value = int(percent) self["space_bar_single"].value = 100 self["space_label_single"].text = "" - self["medium_label"].setText(_("exceeds dual layer medium!")) + self["medium_label"].setText(_("Exceeds dual layer medium!")) self["medium_label"].setForegroundColorNum(2) if self.previous_size < MAX_DL: - self.session.open(MessageBox,text = _("exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR) + self.session.open(MessageBox,text = _("Exceeds dual layer medium!"), type = MessageBox.TYPE_ERROR) elif size > MAX_SL: percent = 100 * size / float(MAX_DL) self["space_label_dual"].text = "%d MB (%.2f%%)" % (size, percent) self["space_bar_dual"].value = int(percent) self["space_bar_single"].value = 100 self["space_label_single"].text = "" - self["medium_label"].setText(_("required medium type:") + " " + _("DUAL LAYER DVD") + ", %d MB " % (MAX_DL - size) + _("free")) + self["medium_label"].setText(_("Required medium type:") + " " + _("DUAL LAYER DVD") + ", %d MB " % (MAX_DL - size) + _("free")) self["medium_label"].setForegroundColorNum(1) if self.previous_size < MAX_SL: self.session.open(MessageBox, text = _("Your collection exceeds the size of a single layer medium, you will need a blank dual layer DVD!"), timeout = 10, type = MessageBox.TYPE_INFO) @@ -329,7 +329,7 @@ class TitleList(Screen, HelpableScreen): self["space_bar_single"].value = int(percent) self["space_bar_dual"].value = 0 self["space_label_dual"].text = "" - self["medium_label"].setText(_("required medium type:") + " " + _("SINGLE LAYER DVD") + ", %d MB " % (MAX_SL - size) + _("free")) + self["medium_label"].setText(_("Required medium type:") + " " + _("SINGLE LAYER DVD") + ", %d MB " % (MAX_SL - size) + _("free")) self["medium_label"].setForegroundColorNum(0) self.previous_size = size diff --git a/po/de.po b/po/de.po index 4de23c16..b83d5597 100755 --- a/po/de.po +++ b/po/de.po @@ -2957,7 +2957,7 @@ msgid "Process" msgstr "Aktivitätsanzeige" msgid "Properties of current title" -msgstr "Eigenschaften des ausgewählten Titels" +msgstr "Details zum ausgewählten Titel" msgid "Protect services" msgstr "Kanäle schützen" @@ -4173,7 +4173,7 @@ msgid "Title" msgstr "Titel" msgid "Title properties" -msgstr "Titeleigensch." +msgstr "Titeldetails" msgid "Titleset mode" msgstr "Titleset" @@ -5191,8 +5191,8 @@ msgstr "Versteckte Netzwerk SSID eingeben" msgid "equal to" msgstr "Gleich wie" -msgid "exceeds dual layer medium!" -msgstr "übersteigt Größe eines Dual-Layer-Mediums!" +msgid "Exceeds dual layer medium!" +msgstr "Übersteigt die Größe eines Dual-Layer-Mediums!" msgid "exit DVD player or return to file browser" msgstr "DVD Player verlassen oder zurück zum Dateimanager" @@ -5541,7 +5541,7 @@ msgstr "Wiederholung der Wiedergabeliste" msgid "repeated" msgstr "wiederholend" -msgid "required medium type:" +msgid "Required medium type:" msgstr "Benötigte Rohlingsorte:" msgid "rewind to the previous chapter" -- cgit v1.2.3 From b10d0e67edef01beaae1504ddffa691fe69eec4a Mon Sep 17 00:00:00 2001 From: acid-burn Date: Mon, 5 Apr 2010 21:24:13 +0200 Subject: Softwaremanager: * notify if updatefeed is not available and also verify HardwarePrerequisites. Fixes #503 --- .../SystemPlugins/SoftwareManager/SoftwareTools.py | 22 ++++++++++++++++++++++ .../SystemPlugins/SoftwareManager/plugin.py | 18 +++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py index e8cf6dc2..a7c88c95 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py @@ -7,6 +7,7 @@ from Components.Sources.List import List from Components.Ipkg import IpkgComponent from Components.Network import iNetwork from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_METADIR +from Tools.HardwareInfo import HardwareInfo from time import time @@ -78,9 +79,12 @@ class SoftwareTools(DreamInfoHandler): def ipkgCallback(self, event, param): if event == IpkgComponent.EVENT_ERROR: SoftwareTools.list_updating = False + if self.NotifierCallback is not None: + self.NotifierCallback(False) elif event == IpkgComponent.EVENT_DONE: if SoftwareTools.list_updating: self.startIpkgListAvailable() + #print event, "-", param pass def startIpkgListAvailable(self, callback = None): @@ -164,6 +168,14 @@ class SoftwareTools(DreamInfoHandler): l = len(tokens) version = l > 1 and tokens[1].strip() or "" SoftwareTools.installed_packetlist[name] = version + for package in self.packagesIndexlist[:]: + if not self.verifyPrerequisites(package[0]["prerequisites"]): + self.packagesIndexlist.remove(package) + for package in self.packagesIndexlist[:]: + attributes = package[0]["attributes"] + if attributes.has_key("packagetype"): + if attributes["packagetype"] == "internal": + self.packagesIndexlist.remove(package) if callback is None: self.countUpdates() else: @@ -228,4 +240,14 @@ class SoftwareTools(DreamInfoHandler): for name in self.UpdateConsole.appContainers.keys(): self.UpdateConsole.kill(name) + def verifyPrerequisites(self, prerequisites): + if prerequisites.has_key("hardware"): + hardware_found = False + for hardware in prerequisites["hardware"]: + if hardware == self.hardware_info.device_name: + hardware_found = True + if not hardware_found: + return False + return True + iSoftwareTools = SoftwareTools() \ No newline at end of file diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 4917855f..1e0ed4d5 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -307,8 +307,8 @@ class PluginManager(Screen, DreamInfoHandler): {"templates": {"default": (51,[ - MultiContentEntryText(pos = (30, 1), size = (470, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name - MultiContentEntryText(pos = (30, 25), size = (470, 24), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description + MultiContentEntryText(pos = (0, 1), size = (470, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name + MultiContentEntryText(pos = (0, 25), size = (470, 24), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the description MultiContentEntryPixmapAlphaTest(pos = (475, 0), size = (48, 48), png = 5), # index 5 is the status pixmap MultiContentEntryPixmapAlphaTest(pos = (0, 49), size = (550, 2), png = 6), # index 6 is the div pixmap ]), @@ -405,18 +405,15 @@ class PluginManager(Screen, DreamInfoHandler): if status == 'update': statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager/upgrade.png")) self.statuslist.append(( _("Updating software catalog"), '', _("Searching for available updates. Please wait..." ),'', '', statuspng, divpng, None, '' )) - self["list"].style = "default" - self['list'].setList(self.statuslist) elif status == 'sync': 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, '' )) - self["list"].style = "default" - self['list'].setList(self.statuslist) elif status == 'error': 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" - self['list'].setList(self.statuslist) + self["list"].style = "default" + self['list'].setList(self.statuslist) + def getUpdateInfos(self): self.setState('update') @@ -432,7 +429,10 @@ class PluginManager(Screen, DreamInfoHandler): self.rebuildList() elif retval is False: self.setState('error') - self["status"].setText(_("No network connection available.")) + if iSoftwareTools.NetworkConnectionAvailable: + self["status"].setText(_("Updatefeed not available.")) + else: + self["status"].setText(_("No network connection available.")) def rebuildList(self, retval = None): if self.currentSelectedTag is None: -- cgit v1.2.3 From 4b510799c728bca6d85823978d693c41d34bdc53 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Mon, 5 Apr 2010 22:26:29 +0200 Subject: Softwaremanager: *add missing define. refs #503 --- lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py index a7c88c95..d4653cca 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py @@ -30,6 +30,7 @@ class SoftwareTools(DreamInfoHandler): self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, neededTag = 'ALL_TAGS', neededFlag = self.ImageVersion, language = self.language) self.directory = resolveFilename(SCOPE_METADIR) + self.hardware_info = HardwareInfo() self.list = List([]) self.NotifierCallback = None self.Console = Console() -- cgit v1.2.3 From 4007630dac238cccbfddd2ededa484f8fb14eb7c Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 9 Apr 2010 15:21:13 +0200 Subject: fixes bug #467 add tpm interface to enigma 2 introduce a demo plugin for tpm usage in plugins to validate running on dream multimedia hardware to be used in plugins (see doc/TPM for further information) --- configure.ac | 1 + doc/TPM | 24 +++ lib/base/Makefile.am | 2 +- lib/base/etpm.cpp | 161 +++++++++++++++++++++ lib/base/etpm.h | 46 ++++++ lib/python/Plugins/DemoPlugins/Makefile.am | 6 +- lib/python/Plugins/DemoPlugins/TPMDemo/Makefile.am | 5 + lib/python/Plugins/DemoPlugins/TPMDemo/README | 1 + lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py | 82 +++++++++++ lib/python/Plugins/Makefile.am | 1 + lib/python/enigma_python.i | 2 + 11 files changed, 328 insertions(+), 3 deletions(-) create mode 100644 doc/TPM create mode 100644 lib/base/etpm.cpp create mode 100644 lib/base/etpm.h create mode 100644 lib/python/Plugins/DemoPlugins/TPMDemo/Makefile.am create mode 100644 lib/python/Plugins/DemoPlugins/TPMDemo/README create mode 100644 lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py (limited to 'lib/python/Plugins') diff --git a/configure.ac b/configure.ac index d1b1d279..05c3a8eb 100755 --- a/configure.ac +++ b/configure.ac @@ -118,6 +118,7 @@ lib/python/Components/Sources/Makefile lib/python/Screens/Makefile lib/python/Plugins/Makefile lib/python/Plugins/DemoPlugins/Makefile +lib/python/Plugins/DemoPlugins/TPMDemo/Makefile lib/python/Plugins/DemoPlugins/TestPlugin/Makefile lib/python/Plugins/Extensions/CutListEditor/Makefile lib/python/Plugins/Extensions/CutListEditor/meta/Makefile diff --git a/doc/TPM b/doc/TPM new file mode 100644 index 00000000..2b2b2062 --- /dev/null +++ b/doc/TPM @@ -0,0 +1,24 @@ +If you'd like to write your own plugins and honor the efforts, Dream Multimedia +puts into developing Enigma 2, you can protect your plugin against execution +on Non-Dream Multimedia Hardware by implementing a TPM (Trusted Platform Module) +check into your plugin. +For ease of use we provide a demo plugin in lib/python/Plugins/DemoPlugins/TPMDemo. + +The main TPM check is implemented into the "main" function. You need to provide +this code yourself in your plugin. So copy&paste the code into your own as well +as the needed functions +- bin2long +- long2bin +- rsa_pub1024 +- decrypt_block +- validate_cert +- read_random +Importing the functions from somewhere else would spoil the security model. So +you need to provide the code with your plugin. + +You can either use the given method using the main function (which will run the +TPM check each time the plugin is called) or directly use it in the +Plugins(**kwargs) function and not return the Plugins-list if the TPM check failes +(which will prevent the plugin from showing up at all). You can also implement +a warning message for all possible TPM failure scenarios. + \ No newline at end of file diff --git a/lib/base/Makefile.am b/lib/base/Makefile.am index 6ea9d03f..05085632 100644 --- a/lib/base/Makefile.am +++ b/lib/base/Makefile.am @@ -8,5 +8,5 @@ libenigma_base_a_SOURCES = \ init.cpp message.cpp thread.cpp \ smartptr.cpp estring.cpp connection.cpp \ filepush.cpp encoding.cpp console.cpp rawfile.cpp \ - nconfig.cpp ioprio.cpp + nconfig.cpp ioprio.cpp etpm.cpp diff --git a/lib/base/etpm.cpp b/lib/base/etpm.cpp new file mode 100644 index 00000000..f1ac07ba --- /dev/null +++ b/lib/base/etpm.cpp @@ -0,0 +1,161 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_REF(eTPM); + +eTPM::eTPM() +{ + struct sockaddr_un addr; + unsigned char buf[8]; + unsigned int tag, len; + unsigned char *val; + + level2_cert_read = level3_cert_read = false; + + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, TPMD_SOCKET); + + fd = socket(PF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + eDebug("[eTPM] socket error"); + return; + } + + if (connect(fd, (const struct sockaddr *)&addr, SUN_LEN(&addr)) < 0) { + eDebug("[eTPM] connect error"); + return; + } + + buf[0] = TPMD_DT_LEVEL2_CERT; + buf[1] = TPMD_DT_LEVEL3_CERT; + if (!send_cmd(TPMD_CMD_GET_DATA, buf, 2)) + { + return; + } + + val = (unsigned char*)recv_cmd(&tag, &len); + if (val == NULL) + { + return; + } + + parse_data(val, len); + free(val); +} + +eTPM::~eTPM() +{ + +} + +bool eTPM::send_cmd(enum tpmd_cmd cmd, const void *data, unsigned int len) +{ + unsigned char buf[len + 4]; + + buf[0] = (cmd >> 8) & 0xff; + buf[1] = (cmd >> 0) & 0xff; + buf[2] = (len >> 8) & 0xff; + buf[3] = (len >> 0) & 0xff; + memcpy(&buf[4], data, len); + + if (write(fd, buf, sizeof(buf)) != (ssize_t)sizeof(buf)) { + fprintf(stderr, "%s: incomplete write\n", __func__); + return false; + } + + return true; +} + +void* eTPM::recv_cmd(unsigned int *tag, unsigned int *len) +{ + unsigned char buf[4]; + void *val; + + if (read(fd, buf, 4) != 4) { + fprintf(stderr, "%s: incomplete read\n", __func__); + return NULL; + } + + *tag = (buf[0] << 8) | buf[1]; + *len = (buf[2] << 8) | buf[3]; + + val = malloc(*len); + if (val == NULL) + return NULL; + + if (read(fd, val, *len) != (ssize_t)*len) { + fprintf(stderr, "%s: incomplete read\n", __func__); + free(val); + return NULL; + } + + return val; +} + +void eTPM::parse_data(const unsigned char *data, unsigned int datalen) +{ + unsigned int i, j; + unsigned int tag; + unsigned int len; + const unsigned char *val; + + for (i = 0; i < datalen; i += len) { + tag = data[i++]; + len = data[i++]; + val = &data[i]; + + switch (tag) { + case TPMD_DT_LEVEL2_CERT: + if (len != 210) + break; + memcpy(level2_cert, val, 210); + level2_cert_read = true; + break; + case TPMD_DT_LEVEL3_CERT: + if (len != 210) + break; + memcpy(level3_cert, val, 210); + level3_cert_read = true; + break; + } + } +} + +PyObject *eTPM::getCert(cert_type type) +{ + if (type == TPMD_DT_LEVEL2_CERT && level2_cert_read) + return PyBuffer_FromMemory(level2_cert, 210); + else if (type == TPMD_DT_LEVEL3_CERT && level3_cert_read) + return PyBuffer_FromMemory(level3_cert, 210); + return Py_None; + +} + +PyObject *eTPM::challenge(PyObject* rnd) +{ + if (PyString_Check(rnd) && PyString_Size(rnd) == 8) + { + char* buf = PyString_AsString(rnd); + if (!send_cmd(TPMD_CMD_COMPUTE_SIGNATURE, buf, 8)) + return Py_None; + + unsigned int tag, len; + unsigned char *val = (unsigned char*)recv_cmd(&tag, &len); + + if (tag != TPMD_CMD_COMPUTE_SIGNATURE) + return Py_None; + + return PyBuffer_FromMemory(val, len); + } + else + return Py_None; +} diff --git a/lib/base/etpm.h b/lib/base/etpm.h new file mode 100644 index 00000000..3728249b --- /dev/null +++ b/lib/base/etpm.h @@ -0,0 +1,46 @@ +#ifndef __lib_base_etpm_h +#define __lib_base_etpm_h + +#include +#include + +#ifndef SWIG +#define TPMD_SOCKET "/var/run/tpmd_socket" +#endif + +class eTPM: public Object, public iObject +{ + DECLARE_REF(eTPM); +#ifndef SWIG + int fd; + unsigned char level2_cert[210]; + unsigned char level3_cert[210]; + bool level2_cert_read; + bool level3_cert_read; + + enum tpmd_cmd { + TPMD_CMD_RESERVED = 0x0000, + TPMD_CMD_GET_DATA = 0x0001, + TPMD_CMD_APDU = 0x0002, + TPMD_CMD_COMPUTE_SIGNATURE = 0x0003, + TPMD_CMD_APP_CERT = 0x0004, + }; + + bool send_cmd(enum tpmd_cmd cmd, const void *data, unsigned int len); + void *recv_cmd(unsigned int *tag, unsigned int *len); + void parse_data(const unsigned char *data, unsigned int datalen); + +#endif +public: + eTPM(); + ~eTPM(); + + enum cert_type { + TPMD_DT_LEVEL2_CERT = 0x04, + TPMD_DT_LEVEL3_CERT = 0x05 + }; + PyObject *getCert(cert_type type); + PyObject *challenge(PyObject *rnd); +}; + +#endif // __lib_base_etpm_h diff --git a/lib/python/Plugins/DemoPlugins/Makefile.am b/lib/python/Plugins/DemoPlugins/Makefile.am index aace17cc..9e16bfc1 100755 --- a/lib/python/Plugins/DemoPlugins/Makefile.am +++ b/lib/python/Plugins/DemoPlugins/Makefile.am @@ -1,6 +1,8 @@ installdir = $(pkglibdir)/python/Plugins/DemoPlugins -SUBDIRS = TestPlugin +SUBDIRS = TestPlugin TPMDemo install_PYTHON = \ - __init__.py \ No newline at end of file + __init__.py + + \ No newline at end of file diff --git a/lib/python/Plugins/DemoPlugins/TPMDemo/Makefile.am b/lib/python/Plugins/DemoPlugins/TPMDemo/Makefile.am new file mode 100644 index 00000000..3ccca98e --- /dev/null +++ b/lib/python/Plugins/DemoPlugins/TPMDemo/Makefile.am @@ -0,0 +1,5 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/DemoPlugins/TPMDemo + +install_PYTHON = \ + __init__.py \ + plugin.py diff --git a/lib/python/Plugins/DemoPlugins/TPMDemo/README b/lib/python/Plugins/DemoPlugins/TPMDemo/README new file mode 100644 index 00000000..89a972aa --- /dev/null +++ b/lib/python/Plugins/DemoPlugins/TPMDemo/README @@ -0,0 +1 @@ +Please read enigma2/doc/TPM for further instructions on how to integrate this into your own plugins. \ No newline at end of file diff --git a/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py b/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py new file mode 100644 index 00000000..dafb2837 --- /dev/null +++ b/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py @@ -0,0 +1,82 @@ +from Screens.Screen import Screen +from Plugins.Plugin import PluginDescriptor +from enigma import eTPM +import sha + +def bin2long(s): + return reduce( lambda x,y:(x<<8L)+y, map(ord, s)) + +def long2bin(l): + res = "" + for byte in range(128): + res += chr((l >> (1024 - (byte + 1) * 8)) & 0xff) + return res + +def rsa_pub1024(src, mod): + return long2bin(pow(bin2long(src), 65537, bin2long(mod))) + +def decrypt_block(src, mod): + if len(src) != 128 and len(src) != 202: + return None + dest = rsa_pub1024(src[:128], mod) + hash = sha.new(dest[1:107]) + if len(src) == 202: + hash.update(src[131:192]) + result = hash.digest() + if result == dest[107:127]: + return dest + return None + +def validate_cert(cert, key): + buf = decrypt_block(cert[8:], key) + if buf is None: + return None + return buf[36:107] + cert[139:196] + +def read_random(): + try: + fd = open("/dev/urandom", "r") + buf = fd.read(8) + fd.close() + return buf + except: + return None + +def main(session, **kwargs): + 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: + print "l2cert not found" + return + + l2key = validate_cert(l2cert, rootkey) + if l2key is None: + print "l2cert invalid" + return + + l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT) + if l3cert is None: + print "l3cert not found (can be fixed by running the genuine dreambox plugin and running the offered update)" + return + + l3key = validate_cert(l3cert, l2key) + if l3key is None: + print "l3cert invalid" + return + + rnd = read_random() + if rnd is None: + print "random error" + return + val = etpm.challenge(rnd) + result = decrypt_block(val, l3key) + if result[80:88] == rnd: + print "successfully finished the tpm test" + # would start your plugin here + +def Plugins(**kwargs): + return [PluginDescriptor(name = "TPM Demo", description = _("A demo plugin for TPM usage."), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main), + PluginDescriptor(name = "TPM Demo", description = _("A demo plugin for TPM usage."), icon = "plugin.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main)] + \ No newline at end of file diff --git a/lib/python/Plugins/Makefile.am b/lib/python/Plugins/Makefile.am index f0435036..79d2b0b6 100644 --- a/lib/python/Plugins/Makefile.am +++ b/lib/python/Plugins/Makefile.am @@ -4,3 +4,4 @@ SUBDIRS = Extensions SystemPlugins DemoPlugins install_PYTHON = \ __init__.py Plugin.py + diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 2fec2ff1..19fb9254 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -39,6 +39,7 @@ is usually caused by not marking PSignals as immutable. #include #include #include +#include #include #include #include @@ -157,6 +158,7 @@ typedef long time_t; %immutable ePythonMessagePump::recv_msg; %immutable eDVBLocalTimeHandler::m_timeUpdated; %include +%include %include %include %include -- cgit v1.2.3 From 31addde4d83dfbbaf273bc48a1f0783dc476a30f Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 9 Apr 2010 19:10:52 +0200 Subject: refs bug #467 add __init__.py in TPMDemo plugin --- lib/python/Plugins/DemoPlugins/TPMDemo/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/python/Plugins/DemoPlugins/TPMDemo/__init__.py (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/DemoPlugins/TPMDemo/__init__.py b/lib/python/Plugins/DemoPlugins/TPMDemo/__init__.py new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3 From b8d09c6e14ce43b375fcb5006444551713b42a7c Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 9 Apr 2010 20:40:28 +0200 Subject: refs bug #467 whitelist dm7025 from tpm test and add beta warning to the documentation --- doc/TPM | 5 +- lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py | 63 +++++++++++++----------- 2 files changed, 37 insertions(+), 31 deletions(-) (limited to 'lib/python/Plugins') diff --git a/doc/TPM b/doc/TPM index 2b2b2062..20c02300 100644 --- a/doc/TPM +++ b/doc/TPM @@ -1,3 +1,6 @@ +The TPM check is currently to be considered a beta version. So please expect +code changes in the future. + If you'd like to write your own plugins and honor the efforts, Dream Multimedia puts into developing Enigma 2, you can protect your plugin against execution on Non-Dream Multimedia Hardware by implementing a TPM (Trusted Platform Module) @@ -21,4 +24,4 @@ TPM check each time the plugin is called) or directly use it in the Plugins(**kwargs) function and not return the Plugins-list if the TPM check failes (which will prevent the plugin from showing up at all). You can also implement a warning message for all possible TPM failure scenarios. - \ No newline at end of file + diff --git a/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py b/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py index dafb2837..0be09ccf 100644 --- a/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py +++ b/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py @@ -1,5 +1,6 @@ from Screens.Screen import Screen from Plugins.Plugin import PluginDescriptor +from Tools.HardwareInfo import HardwareInfo from enigma import eTPM import sha @@ -43,38 +44,40 @@ def read_random(): return None def main(session, **kwargs): - 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', ':', '?'] + device = HardwareInfo().get_device_name() + if device != "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: + print "l2cert not found" + return - etpm = eTPM() - l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT) - if l2cert is None: - print "l2cert not found" - return - - l2key = validate_cert(l2cert, rootkey) - if l2key is None: - print "l2cert invalid" - return - - l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT) - if l3cert is None: - print "l3cert not found (can be fixed by running the genuine dreambox plugin and running the offered update)" - return - - l3key = validate_cert(l3cert, l2key) - if l3key is None: - print "l3cert invalid" - return - - rnd = read_random() - if rnd is None: - print "random error" - return - val = etpm.challenge(rnd) - result = decrypt_block(val, l3key) - if result[80:88] == rnd: + l2key = validate_cert(l2cert, rootkey) + if l2key is None: + print "l2cert invalid" + return + + l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT) + if l3cert is None: + print "l3cert not found (can be fixed by running the genuine dreambox plugin and running the offered update)" + return + + l3key = validate_cert(l3cert, l2key) + if l3key is None: + print "l3cert invalid" + return + + rnd = read_random() + if rnd is None: + print "random error" + return + val = etpm.challenge(rnd) + result = decrypt_block(val, l3key) + if device == "dm7025" or result[80:88] == rnd: print "successfully finished the tpm test" - # would start your plugin here + # would start your plugin here def Plugins(**kwargs): return [PluginDescriptor(name = "TPM Demo", description = _("A demo plugin for TPM usage."), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main), -- cgit v1.2.3 From cdf6f671e3089e8269ce3dd0dd20dbc4878b898a Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 9 Apr 2010 20:49:15 +0200 Subject: refs bug #467 read proc device instead of using internal methods --- lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py b/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py index 0be09ccf..2c078d35 100644 --- a/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py +++ b/lib/python/Plugins/DemoPlugins/TPMDemo/plugin.py @@ -1,6 +1,5 @@ from Screens.Screen import Screen from Plugins.Plugin import PluginDescriptor -from Tools.HardwareInfo import HardwareInfo from enigma import eTPM import sha @@ -44,7 +43,10 @@ def read_random(): return None def main(session, **kwargs): - device = HardwareInfo().get_device_name() + try: + device = open("/proc/stb/info/model", "r").readline().strip() + except: + device = "" if device != "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', ':', '?'] -- cgit v1.2.3 From 56f2ffeb0301567710eb8f08a92a73ce67a40ef5 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 29 Apr 2010 18:29:07 +0200 Subject: dm800se support --- data/defaults/Dream/Makefile.am | 2 ++ data/defaults/Dream/dm800se.info | 26 ++++++++++++++++++++++ data/defaults/Dream/settings.800se | 1 + lib/dvb/dvb.cpp | 4 +++- lib/dvb/dvb.h | 2 +- .../SystemPlugins/Videomode/VideoHardware.py | 4 ++-- .../Plugins/SystemPlugins/Videomode/VideoWizard.py | 4 ++-- 7 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 data/defaults/Dream/dm800se.info create mode 100644 data/defaults/Dream/settings.800se (limited to 'lib/python/Plugins') diff --git a/data/defaults/Dream/Makefile.am b/data/defaults/Dream/Makefile.am index 31ba1c69..cda55835 100644 --- a/data/defaults/Dream/Makefile.am +++ b/data/defaults/Dream/Makefile.am @@ -4,10 +4,12 @@ installdir = $(pkgdatadir)/defaults/Dream dist_install_DATA = \ bouquets.tv \ + dm800se.info \ dm500hd.info \ dm7025.info \ dm8000.info \ dm800.info \ + settings.800se \ settings.500hd \ settings.7025 \ settings.800 \ diff --git a/data/defaults/Dream/dm800se.info b/data/defaults/Dream/dm800se.info new file mode 100644 index 00000000..6974b120 --- /dev/null +++ b/data/defaults/Dream/dm800se.info @@ -0,0 +1,26 @@ + + + + + + + + Dream Multimedia GmbH + Dream Multimedia Default + + + + + + + + + + + + diff --git a/data/defaults/Dream/settings.800se b/data/defaults/Dream/settings.800se new file mode 100644 index 00000000..ae2963bb --- /dev/null +++ b/data/defaults/Dream/settings.800se @@ -0,0 +1 @@ +config.misc.rcused=1 \ No newline at end of file diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index 836851c5..40d44186 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -96,6 +96,8 @@ eDVBResourceManager::eDVBResourceManager() m_boxtype = DM800; else if (!strncmp(tmp, "dm500hd\n", rd)) m_boxtype = DM500HD; + else if (!strncmp(tmp, "dm800se\n", rd)) + m_boxtype = DM800SE; else { eDebug("boxtype detection via /proc/stb/info not possible... use fallback via demux count!\n"); if (m_demux.size() == 3) @@ -455,7 +457,7 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr unused; - if (m_boxtype == DM800 || m_boxtype == DM500HD) // dm800 / 500hd + if (m_boxtype == DM800 || m_boxtype == DM500HD || m_boxtype == DM800SE) // dm800 / 500hd { cap |= capHoldDecodeReference; // this is checked in eDVBChannel::getDemux for (; i != m_demux.end(); ++i, ++n) diff --git a/lib/dvb/dvb.h b/lib/dvb/dvb.h index 405bd557..fb925807 100644 --- a/lib/dvb/dvb.h +++ b/lib/dvb/dvb.h @@ -135,7 +135,7 @@ class eDVBResourceManager: public iObject, public Object DECLARE_REF(eDVBResourceManager); int avail, busy; - enum { DM7025, DM800, DM500HD, DM8000 }; + enum { DM7025, DM800, DM500HD, DM800SE, DM8000 }; int m_boxtype; diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index e3b902f0..59c50476 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -239,9 +239,9 @@ class VideoHardware: portlist = self.getPortList() for port in portlist: descr = port - if descr == 'DVI' and hw_type == 'dm500hd': + if descr == 'DVI' and hw_type in ('dm500hd', 'dm800se'): descr = 'HDMI' - elif descr == 'DVI-PC' and hw_type == 'dm500hd': + elif descr == 'DVI-PC' and hw_type in ('dm500hd', 'dm800se'): descr = 'HDMI-PC' lst.append((port, descr)) diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index 15f4d516..3c76685e 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -82,7 +82,7 @@ class VideoWizard(WizardLanguage, Rc): for port in self.hw.getPortList(): if self.hw.isPortUsed(port): descr = port - if descr == 'DVI' and hw_type == 'dm500hd': + if descr == 'DVI' and hw_type in ('dm500hd', 'dm800se'): descr = 'HDMI' if port != "DVI-PC": list.append((descr,port)) @@ -100,7 +100,7 @@ class VideoWizard(WizardLanguage, Rc): self.inputSelect(self.selection) if self["portpic"].instance is not None: picname = self.selection - if picname == "DVI" and HardwareInfo().get_device_name() == "dm500hd": + if picname == "DVI" and HardwareInfo().get_device_name() in ("dm500hd", "dm800se"): picname = "HDMI" self["portpic"].instance.setPixmapFromFile(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/" + picname + ".png")) -- cgit v1.2.3 From 05b454322d04bc7fa35e5a05fcdebba7fa8e942a Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 2 Jun 2010 15:03:52 +0200 Subject: Extend AudioSelection width, fix mediaplayer subtitle selection key --- data/skin_default.xml | 24 +++++++++--------- .../Plugins/Extensions/MediaPlayer/plugin.py | 8 +++--- lib/python/Screens/AudioSelection.py | 29 ++++++++++++++-------- 3 files changed, 35 insertions(+), 26 deletions(-) (limited to 'lib/python/Plugins') diff --git a/data/skin_default.xml b/data/skin_default.xml index 9fb2fc27..ea0e29f2 100755 --- a/data/skin_default.xml +++ b/data/skin_default.xml @@ -62,8 +62,8 @@ - - + + @@ -78,24 +78,24 @@ - + - + {"templates": {"default": (25, [ MultiContentEntryText(pos = (0, 0), size = (35, 25), font = 0, flags = RT_HALIGN_LEFT, text = 1), # key, - MultiContentEntryText(pos = (40, 0), size = (55, 25), font = 0, flags = RT_HALIGN_LEFT, text = 2), # number, - MultiContentEntryText(pos = (100, 0), size = (80, 25), font = 0, flags = RT_HALIGN_LEFT, text = 3), # description, - MultiContentEntryText(pos = (190, 0), size = (140, 25), font = 0, flags = RT_HALIGN_LEFT, text = 4), # language, - MultiContentEntryText(pos = (340, 4), size = (60, 25), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # selection, + MultiContentEntryText(pos = (40, 0), size = (60, 25), font = 0, flags = RT_HALIGN_LEFT, text = 2), # number, + MultiContentEntryText(pos = (110, 0), size = (120, 25), font = 0, flags = RT_HALIGN_LEFT, text = 3), # description, + MultiContentEntryText(pos = (240, 0), size = (210, 25), font = 0, flags = RT_HALIGN_LEFT, text = 4), # language, + MultiContentEntryText(pos = (460, 4), size = (80, 25), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # selection, ], True, "showNever"), "notselected": (25, [ MultiContentEntryText(pos = (0, 0), size = (35, 25), font = 0, flags = RT_HALIGN_LEFT, text = 1), # key, - MultiContentEntryText(pos = (40, 0), size = (55, 25), font = 0, flags = RT_HALIGN_LEFT, text = 2), # number, - MultiContentEntryText(pos = (100, 0), size = (80, 25), font = 0, flags = RT_HALIGN_LEFT, text = 3), # description, - MultiContentEntryText(pos = (190, 0), size = (140, 25), font = 0, flags = RT_HALIGN_LEFT, text = 4), # language, - MultiContentEntryText(pos = (340, 4), size = (60, 25), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # selection, + MultiContentEntryText(pos = (40, 0), size = (60, 25), font = 0, flags = RT_HALIGN_LEFT, text = 2), # number, + MultiContentEntryText(pos = (110, 0), size = (120, 25), font = 0, flags = RT_HALIGN_LEFT, text = 3), # description, + MultiContentEntryText(pos = (240, 0), size = (210, 25), font = 0, flags = RT_HALIGN_LEFT, text = 4), # language, + MultiContentEntryText(pos = (460, 4), size = (80, 25), font = 1, flags = RT_HALIGN_RIGHT, text = 5), # selection, ], False, "showNever") }, "fonts": [gFont("Regular", 20), gFont("Regular", 16)], diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 0fc78fb1..15806e8c 100755 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -901,11 +901,11 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB def unPauseService(self): self.setSeekState(self.SEEK_STATE_PLAY) - + def subtitleSelection(self): - from Screens.Subtitles import Subtitles - self.session.open(Subtitles, self) - + from Screens.AudioSelection import SubtitleSelection + self.session.open(SubtitleSelection, self) + def hotplugCB(self, dev, media_state): if dev == harddiskmanager.getCD(): if media_state == "1": diff --git a/lib/python/Screens/AudioSelection.py b/lib/python/Screens/AudioSelection.py index 2cae1de9..2dd6ad90 100644 --- a/lib/python/Screens/AudioSelection.py +++ b/lib/python/Screens/AudioSelection.py @@ -14,9 +14,10 @@ from enigma import iPlayableService from Tools.ISO639 import LanguageCodes from Tools.BoundFunction import boundFunction FOCUS_CONFIG, FOCUS_STREAMS = range(2) +[PAGE_AUDIO, PAGE_SUBTITLES] = ["audio", "subtitles"] class AudioSelection(Screen, ConfigListScreen): - def __init__(self, session, infobar=None): + def __init__(self, session, infobar=None, page=PAGE_AUDIO): Screen.__init__(self, session) self["streams"] = List([]) @@ -48,8 +49,8 @@ class AudioSelection(Screen, ConfigListScreen): }, -3) self.settings = ConfigSubsection() - choicelist = [("audio",_("audio tracks")), ("subtitles",_("Subtitles"))] - self.settings.menupage = ConfigSelection(choices = choicelist) + choicelist = [(PAGE_AUDIO,_("audio tracks")), (PAGE_SUBTITLES,_("Subtitles"))] + self.settings.menupage = ConfigSelection(choices = choicelist, default=page) self.settings.menupage.addNotifier(self.fillList) self.onLayoutFinish.append(self.__layoutFinished) @@ -66,7 +67,7 @@ class AudioSelection(Screen, ConfigListScreen): self.audioTracks = audio = service and service.audioTracks() n = audio and audio.getNumberOfTracks() or 0 - if self.settings.menupage.getValue() == "audio": + if self.settings.menupage.getValue() == PAGE_AUDIO: self.setTitle(_("Select audio track")) if SystemInfo["CanDownmixAC3"]: print "config.av.downmix_ac3.value=", config.av.downmix_ac3.value @@ -115,8 +116,11 @@ class AudioSelection(Screen, ConfigListScreen): else: streams = [] + self.settings.dummy = ConfigNothing() + conflist.append(getConfigListEntry("", self.settings.dummy)) + self["key_green"].setBoolean(False) - elif self.settings.menupage.getValue() == "subtitles": + elif self.settings.menupage.getValue() == PAGE_SUBTITLES: self.setTitle(_("Subtitle selection")) self.settings.dummy = ConfigNothing() @@ -158,9 +162,9 @@ class AudioSelection(Screen, ConfigListScreen): elif x[0] == 1: description = "TTX" number = "%x%02x" % (x[3],x[2]) - + elif x[0] == 2: - types = (" UTF-8 text "," SSA / AAS "," .SRT file ") + types = ("UTF-8 text","SSA / AAS",".SRT file") description = types[x[2]] streams.append((x, "", number, description, language, selected)) @@ -252,7 +256,7 @@ class AudioSelection(Screen, ConfigListScreen): ConfigListScreen.keyRight(self) elif hasattr(self, "plugincallfunc"): self.plugincallfunc() - if self.focus == FOCUS_STREAMS and self["streams"].count(): + if self.focus == FOCUS_STREAMS and self["streams"].count() and config == False: self["streams"].setIndex(self["streams"].count()-1) def keyRed(self): @@ -305,10 +309,10 @@ class AudioSelection(Screen, ConfigListScreen): print "[keyok]", self["streams"].list, self["streams"].getCurrent() if self.focus == FOCUS_STREAMS and self["streams"].list: cur = self["streams"].getCurrent() - if self.settings.menupage.getValue() == "audio" and cur[0] is not None: + if self.settings.menupage.getValue() == PAGE_AUDIO and cur[0] is not None: self.changeAudio(cur[2]) self.__updatedInfo() - if self.settings.menupage.getValue() == "subtitles" and cur[0] is not None: + if self.settings.menupage.getValue() == PAGE_SUBTITLES and cur[0] is not None: if self.infobar.selected_subtitle == cur[0]: self.enableSubtitle(None) selectedidx = self["streams"].getIndex() @@ -323,3 +327,8 @@ class AudioSelection(Screen, ConfigListScreen): def cancel(self): self.close(0) + +class SubtitleSelection(AudioSelection): + def __init__(self, session, infobar=None): + AudioSelection.__init__(self, session, infobar, page=PAGE_SUBTITLES) + self.skinName = ["AudioSelection"] -- cgit v1.2.3 From 1445e37b9d2b2d17009cf2b91c24b895a288a702 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Thu, 10 Jun 2010 15:19:12 +0200 Subject: add missing dm800se color oled screens. refs #530 --- data/skin_default.xml | 227 +++++++++++++++------ lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 19 +- .../Plugins/Extensions/MediaPlayer/plugin.py | 11 +- .../Plugins/SystemPlugins/NFIFlash/flasher.py | 14 +- .../Plugins/SystemPlugins/Videomode/VideoWizard.py | 14 +- 5 files changed, 211 insertions(+), 74 deletions(-) mode change 100644 => 100755 lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py mode change 100644 => 100755 lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py (limited to 'lib/python/Plugins') diff --git a/data/skin_default.xml b/data/skin_default.xml index 7262f43c..a2bcc6f7 100755 --- a/data/skin_default.xml +++ b/data/skin_default.xml @@ -203,9 +203,7 @@ self.instance.move(ePoint((720-wsizex)/2, (576-wsizey)/(count > 7 and 2 or 3) - - - + @@ -550,10 +548,6 @@ newwidth = wsize[0] self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) - - - - @@ -1093,11 +1087,55 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Name @@ -1110,9 +1148,21 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) Format:%S + + + + + Name + + + Progress + + + Format:%H:%M + - + Name @@ -1146,15 +1196,8 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) Blink - - - - - - - - + Name @@ -1169,18 +1212,89 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) Blink + + + + Name + + + Position + + + Format:%H:%M + + + config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean + Blink + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + + + + + - + Format:%H:%M @@ -1189,37 +1303,18 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) Blink - - - - - - - - - - - - - - - - - - - - - - - - + + + + Format:%H:%M - - + + config.usage.blinking_display_clock_during_recording,True,CheckSourceBoolean + Blink - - + + @@ -1227,19 +1322,29 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) - - - - - - + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index e092e82f..64b4ae50 100755 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -88,8 +88,8 @@ class FileBrowser(Screen): self.close(None) class DVDSummary(Screen): - skin = """ - + skin = ( + """ Name @@ -101,7 +101,20 @@ class DVDSummary(Screen): Position - """ + """, + """ + + Name + + + + + Position + + + Position + + """) def __init__(self, session, parent): Screen.__init__(self, session, parent) diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index 15806e8c..e4bdba12 100755 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -925,12 +925,17 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB self.clear_playlist() class MediaPlayerLCDScreen(Screen): - skin = """ - + skin = ( + """ - """ + """, + """ + + + + """) def __init__(self, session, parent): Screen.__init__(self, session) diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py old mode 100644 new mode 100755 index 8986560b..7a0da851 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py @@ -39,13 +39,19 @@ class writeNAND(Task): self.output_line = data class NFISummary(Screen): - skin = """ - + skin = ( + """ - - """ + + """, + """ + + + + + """) def __init__(self, session, parent): Screen.__init__(self, session, parent) diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py old mode 100644 new mode 100755 index 3c76685e..9b9044ee --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -12,14 +12,22 @@ from Tools.HardwareInfo import HardwareInfo config.misc.showtestcard = ConfigBoolean(default = False) class VideoWizardSummary(WizardSummary): - skin = """ - + skin = ( + """ - """ #% (resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/lcd_Scart.png")) + """, + """ + + + + + + """) + #% (resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/lcd_Scart.png")) def __init__(self, session, parent): WizardSummary.__init__(self, session, parent) -- cgit v1.2.3 From cdfd83c94cc6f2aab412cbcd686348d51c7e8869 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Tue, 6 Jul 2010 15:41:11 +0200 Subject: Softwaremanager: * properly count processed packages. * make configfile owerwrite question while upgrading configurable over new setupscreen on Menu Button. * show files that will be backed up inside own infoscreen and not inside the menu description. * add possibility to navigate with the remote keys (a-z) inside packagemanager. thx emanuel fixes #550 --- .../SystemPlugins/SoftwareManager/SoftwareTools.py | 124 +++++++-- .../SystemPlugins/SoftwareManager/plugin.py | 302 +++++++++++++++++++-- 2 files changed, 388 insertions(+), 38 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py index d4653cca..a29a5e99 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py @@ -1,4 +1,5 @@ -from enigma import eConsoleAppContainer +# -*- coding: iso-8859-1 -*- +from enigma import eConsoleAppContainer,eTPM from Components.Console import Console from Components.About import about from Components.DreamInfoHandler import DreamInfoHandler @@ -8,9 +9,49 @@ from Components.Ipkg import IpkgComponent from Components.Network import iNetwork from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_METADIR from Tools.HardwareInfo import HardwareInfo +import sha from time import time +def bin2long(s): + return reduce( lambda x,y:(x<<8L)+y, map(ord, s)) + +def long2bin(l): + res = "" + for byte in range(128): + res += chr((l >> (1024 - (byte + 1) * 8)) & 0xff) + return res + +def rsa_pub1024(src, mod): + return long2bin(pow(bin2long(src), 65537, bin2long(mod))) + +def decrypt_block(src, mod): + if len(src) != 128 and len(src) != 202: + return None + dest = rsa_pub1024(src[:128], mod) + hash = sha.new(dest[1:107]) + if len(src) == 202: + hash.update(src[131:192]) + result = hash.digest() + if result == dest[107:127]: + return dest + return None + +def validate_cert(cert, key): + buf = decrypt_block(cert[8:], key) + if buf is None: + return None + return buf[36:107] + cert[139:196] + +def read_random(): + try: + fd = open("/dev/urandom", "r") + buf = fd.read(8) + fd.close() + return buf + except: + return None + class SoftwareTools(DreamInfoHandler): lastDownloadDate = None NetworkConnectionAvailable = None @@ -58,24 +99,71 @@ class SoftwareTools(DreamInfoHandler): self.getUpdates() def getUpdates(self, callback = None): - if SoftwareTools.NetworkConnectionAvailable == True: - SoftwareTools.lastDownloadDate = time() - if SoftwareTools.list_updating is False and callback is None: - SoftwareTools.list_updating = True - self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) - elif SoftwareTools.list_updating is False and callback is not None: - SoftwareTools.list_updating = True - self.NotifierCallback = callback - self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) - elif SoftwareTools.list_updating is True and callback is not None: - #update info collecting already in progress - self.NotifierCallback = callback + if SoftwareTools.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 + l2key = validate_cert(l2cert, rootkey) + if l2key 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: + 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: + if SoftwareTools.NetworkConnectionAvailable == True: + SoftwareTools.lastDownloadDate = time() + if SoftwareTools.list_updating is False and callback is None: + SoftwareTools.list_updating = True + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + elif SoftwareTools.list_updating is False and callback is not None: + SoftwareTools.list_updating = True + self.NotifierCallback = callback + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + elif SoftwareTools.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) + else: + SoftwareTools.NetworkConnectionAvailable = False + SoftwareTools.list_updating = False + if callback is not None: + callback(False) + elif self.NotifierCallback is not None: + self.NotifierCallback(False) else: - SoftwareTools.list_updating = False - if callback is not None: - callback(False) - elif self.NotifierCallback is not None: - self.NotifierCallback(False) + if SoftwareTools.NetworkConnectionAvailable == True: + SoftwareTools.lastDownloadDate = time() + if SoftwareTools.list_updating is False and callback is None: + SoftwareTools.list_updating = True + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + elif SoftwareTools.list_updating is False and callback is not None: + SoftwareTools.list_updating = True + self.NotifierCallback = callback + self.ipkg.startCmd(IpkgComponent.CMD_UPDATE) + elif SoftwareTools.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) def ipkgCallback(self, event, param): if event == IpkgComponent.EVENT_ERROR: diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 1e0ed4d5..99837678 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -14,7 +14,8 @@ from Components.MenuList import MenuList from Components.Sources.List import List from Components.Slider import Slider from Components.Harddisk import harddiskmanager -from Components.config import config,getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations +from Components.config import config,getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations, ConfigYesNo, ConfigSelection +from Components.ConfigList import ConfigListScreen from Components.Console import Console from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest from Components.SelectionList import SelectionList @@ -26,7 +27,8 @@ from Components.AVSwitch import AVSwitch from Components.Network import iNetwork from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_PLUGIN, SCOPE_CURRENT_SKIN, SCOPE_METADIR from Tools.LoadPixmap import LoadPixmap -from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad +from Tools.NumericalTextInput import NumericalTextInput +from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont, getDesktop, ePicLoad, eRCInput, getPrevAsciiCode from cPickle import dump, load from os import path as os_path, system as os_system, unlink, stat, mkdir, popen, makedirs, listdir, access, rename, remove, W_OK, R_OK, F_OK from time import time, gmtime, strftime, localtime @@ -43,6 +45,14 @@ config.plugins.configurationbackup = ConfigSubsection() config.plugins.configurationbackup.backuplocation = ConfigText(default = '/media/hdd/', visible_width = 50, fixed_size = False) config.plugins.configurationbackup.backupdirs = ConfigLocations(default=['/etc/enigma2/', '/etc/network/interfaces', '/etc/wpa_supplicant.conf', '/etc/resolv.conf', '/etc/default_gw', '/etc/hostname']) +config.plugins.SoftwareManager = ConfigSubsection() +config.plugins.SoftwareManager.overwriteConfigFiles = ConfigSelection( + [ + ("Y", _("Yes, always")), + ("N", _("No, never")), + ("ask", _("Always ask")) + ], "Y") + def write_cache(cache_file, cache_data): #Does a cPickle dump if not os_path.isdir( os_path.dirname(cache_file) ): @@ -109,13 +119,16 @@ class UpdatePluginMenu(Screen): self.menu = args self.list = [] self.oktext = _("\nPress OK on your remote control to continue.") + self.menutext = _("Press MENU on your remote control for additional options.") + self.infotext = _("Press INFO on your remote control for additional information.") self.text = "" self.backupdirs = ' '.join( config.plugins.configurationbackup.backupdirs.value ) if self.menu == 0: + print "building menu entries" self.list.append(("install-extensions", _("Manage extensions"), _("\nManage extensions or plugins for your Dreambox" ) + self.oktext, None)) self.list.append(("software-update", _("Software update"), _("\nOnline update of your Dreambox software." ) + self.oktext, None)) self.list.append(("software-restore", _("Software restore"), _("\nRestore your Dreambox with a new firmware." ) + self.oktext, None)) - self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext, None)) + self.list.append(("system-backup", _("Backup system settings"), _("\nBackup your Dreambox settings." ) + self.oktext + "\n\n" + self.infotext, None)) self.list.append(("system-restore",_("Restore system settings"), _("\nRestore your Dreambox settings." ) + self.oktext, None)) self.list.append(("ipkg-install", _("Install local extension"), _("\nScan for local extensions and install them." ) + self.oktext, None)) for p in plugins.getPlugins(PluginDescriptor.WHERE_SOFTWAREMANAGER): @@ -136,7 +149,7 @@ class UpdatePluginMenu(Screen): elif self.menu == 1: self.list.append(("advancedrestore", _("Advanced restore"), _("\nRestore your backups by date." ) + self.oktext, None)) self.list.append(("backuplocation", _("Choose backup location"), _("\nSelect your backup device.\nCurrent device: " ) + config.plugins.configurationbackup.backuplocation.value + self.oktext, None)) - self.list.append(("backupfiles", _("Choose backup files"), _("Select files for backup. Currently selected:\n" ) + self.backupdirs + self.oktext, None)) + self.list.append(("backupfiles", _("Choose backup files"), _("Select files for backup.") + self.oktext + "\n\n" + self.infotext, None)) if config.usage.setup_level.index >= 2: # expert+ self.list.append(("ipkg-manager", _("Packet management"), _("\nView, install and remove available or installed packages." ) + self.oktext, None)) self.list.append(("ipkg-source",_("Choose upgrade source"), _("\nEdit the upgrade source address." ) + self.oktext, None)) @@ -156,25 +169,25 @@ class UpdatePluginMenu(Screen): self["menu"] = List(self.list) self["key_red"] = StaticText(_("Close")) - self["status"] = StaticText("") + self["status"] = StaticText(self.menutext) - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions", "InfobarEPGActions"], + self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions", "InfobarEPGActions", "MenuActions"], { "ok": self.go, "back": self.close, "red": self.close, + "menu": self.handleMenu, + "showEventInfo": self.handleInfo, }, -1) self.onLayoutFinish.append(self.layoutFinished) self.backuppath = getBackupPath() self.backupfile = getBackupFilename() self.fullbackupfilename = self.backuppath + "/" + self.backupfile self.onShown.append(self.setWindowTitle) - #self.onClose.append(self.cleanup) def layoutFinished(self): idx = 0 self["menu"].index = idx - #self.getUpdateInfos() def setWindowTitle(self): self.setTitle(_("Software management")) @@ -201,9 +214,17 @@ class UpdatePluginMenu(Screen): self.text = _("No network connection available.") self["status"].setText(self.text) + def handleMenu(self): + self.session.open(SoftwareManagerSetup) + + def handleInfo(self): + current = self["menu"].getCurrent() + if current: + currentEntry = current[0] + if currentEntry in ("system-backup","backupfiles"): + self.session.open(SoftwareManagerInfo, mode = "backupinfo") def go(self): - #iNetwork.stopPingConsole() current = self["menu"].getCurrent() if current: currentEntry = current[0] @@ -290,6 +311,185 @@ class UpdatePluginMenu(Screen): self.exe = True self.session.open(RestoreScreen, runRestore = True) +class SoftwareManagerSetup(Screen, ConfigListScreen): + + skin = """ + + + + + + + + + + + + + """ + + def __init__(self, session, skin_path = None): + Screen.__init__(self, session) + self.session = session + self.skin_path = skin_path + if self.skin_path == None: + self.skin_path = resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager") + + self.onChangedEntry = [ ] + self.setup_title = _("Software manager setup") + self.overwriteConfigfilesEntry = None + + self.list = [ ] + ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry) + + self["actions"] = ActionMap(["SetupActions"], + { + "cancel": self.keyCancel, + "save": self.apply, + }, -2) + + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText(_("OK")) + self["key_yellow"] = StaticText() + self["key_blue"] = StaticText() + self["introduction"] = StaticText() + + self.createSetup() + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setTitle(self.setup_title) + + def createSetup(self): + self.list = [ ] + self.overwriteConfigfilesEntry = getConfigListEntry(_("Overwrite configuration files ?"), config.plugins.SoftwareManager.overwriteConfigFiles) + self.list.append(self.overwriteConfigfilesEntry) + self["config"].list = self.list + self["config"].l.setSeperation(400) + self["config"].l.setList(self.list) + if not self.selectionChanged in self["config"].onSelectionChanged: + self["config"].onSelectionChanged.append(self.selectionChanged) + self.selectionChanged() + + def selectionChanged(self): + if self["config"].getCurrent() == self.overwriteConfigfilesEntry: + self["introduction"].setText(_("Overwrite configuration files during software upgrade?")) + else: + self["introduction"].setText("") + + def newConfig(self): + pass + + def keyLeft(self): + ConfigListScreen.keyLeft(self) + + def keyRight(self): + ConfigListScreen.keyRight(self) + + def confirm(self, confirmed): + if not confirmed: + print "not confirmed" + return + else: + self.keySave() + + def apply(self): + self.session.openWithCallback(self.confirm, MessageBox, _("Use this settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = True) + + def cancelConfirm(self, result): + if not result: + return + for x in self["config"].list: + x[1].cancel() + self.close() + + def keyCancel(self): + if self["config"].isChanged(): + self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = True) + else: + self.close() + + # for summary: + def changedEntry(self): + for x in self.onChangedEntry: + x() + self.selectionChanged() + + def getCurrentEntry(self): + return self["config"].getCurrent()[0] + + def getCurrentValue(self): + return str(self["config"].getCurrent()[1].value) + + def createSummary(self): + from Screens.Setup import SetupSummary + return SetupSummary + + +class SoftwareManagerInfo(Screen): + skin = """ + + + + + + + + + + + + {"template": [ + MultiContentEntryText(pos = (5, 0), size = (540, 26), font=0, flags = RT_HALIGN_LEFT | RT_HALIGN_CENTER, text = 0), # index 0 is the name + ], + "fonts": [gFont("Regular", 24),gFont("Regular", 22)], + "itemHeight": 26 + } + + + + + """ + + def __init__(self, session, skin_path = None, mode = None): + Screen.__init__(self, session) + self.session = session + self.mode = mode + self.skin_path = skin_path + if self.skin_path == None: + self.skin_path = resolveFilename(SCOPE_CURRENT_PLUGIN, "SystemPlugins/SoftwareManager") + + self["actions"] = ActionMap(["ShortcutActions", "WizardActions"], + { + "back": self.close, + "red": self.close, + }, -2) + + self.list = [] + self["list"] = List(self.list) + + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText() + self["key_yellow"] = StaticText() + self["key_blue"] = StaticText() + self["introduction"] = StaticText() + + self.onLayoutFinish.append(self.layoutFinished) + + def layoutFinished(self): + self.setTitle(_("Softwaremanager information")) + if self.mode is not None: + self.showInfos() + + def showInfos(self): + if self.mode == "backupinfo": + self.list = [] + backupfiles = config.plugins.configurationbackup.backupdirs.value + for entry in backupfiles: + print entry + self.list.append((entry,)) + self['list'].setList(self.list) + class PluginManager(Screen, DreamInfoHandler): @@ -1095,7 +1295,7 @@ class PluginDetails(Screen, DreamInfoHandler): class UpdatePlugin(Screen): skin = """ - + @@ -1115,9 +1315,11 @@ class UpdatePlugin(Screen): self["status"] = self.status self.package = StaticText() self["package"] = self.package + self.oktext = _("Press OK on your remote control to continue.") self.packages = 0 self.error = 0 + self.processed_packages = [] self.activity = 0 self.activityTimer = eTimer() @@ -1151,20 +1353,34 @@ class UpdatePlugin(Screen): self.slider.setValue(self.sliderPackages[param]) self.package.setText(param) self.status.setText(_("Upgrading")) - self.packages += 1 + if not param in self.processed_packages: + self.processed_packages.append(param) + self.packages += 1 elif event == IpkgComponent.EVENT_INSTALL: self.package.setText(param) self.status.setText(_("Installing")) - self.packages += 1 + if not param in self.processed_packages: + self.processed_packages.append(param) + self.packages += 1 + elif event == IpkgComponent.EVENT_REMOVE: + self.package.setText(param) + self.status.setText(_("Removing")) + if not param in self.processed_packages: + self.processed_packages.append(param) + self.packages += 1 elif event == IpkgComponent.EVENT_CONFIGURING: self.package.setText(param) self.status.setText(_("Configuring")) + elif event == IpkgComponent.EVENT_MODIFIED: - self.session.openWithCallback( - self.modificationCallback, - MessageBox, - _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param) - ) + if config.plugins.SoftwareManager.overwriteConfigFiles.value in ("N", "Y"): + self.ipkg.write(True and config.plugins.SoftwareManager.overwriteConfigFiles.value) + else: + self.session.openWithCallback( + self.modificationCallback, + MessageBox, + _("A configuration file (%s) was modified since Installation.\nDo you want to keep your version?") % (param) + ) elif event == IpkgComponent.EVENT_ERROR: self.error += 1 elif event == IpkgComponent.EVENT_DONE: @@ -1178,7 +1394,7 @@ class UpdatePlugin(Screen): self.activityslider.setValue(0) self.package.setText("") - self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages) + self.status.setText(_("Done - Installed or upgraded %d packages") % self.packages + "\n\n" + self.oktext) else: self.activityTimer.stop() self.activityslider.setValue(0) @@ -1381,7 +1597,7 @@ class IPKGSource(Screen): self["text"].number(number) -class PacketManager(Screen): +class PacketManager(Screen, NumericalTextInput): skin = """ @@ -1405,15 +1621,29 @@ class PacketManager(Screen): def __init__(self, session, plugin_path, args = None): Screen.__init__(self, session) + NumericalTextInput.__init__(self) self.session = session self.skin_path = plugin_path - self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"], + self.setUseableChars(u'1234567890abcdefghijklmnopqrstuvwxyz') + + self["shortcuts"] = NumberActionMap(["ShortcutActions", "WizardActions", "NumberActions", "InputActions", "InputAsciiActions", "KeyboardInputActions" ], { "ok": self.go, "back": self.exit, "red": self.exit, "green": self.reload, + "gotAsciiCode": self.keyGotAscii, + "1": self.keyNumberGlobal, + "2": self.keyNumberGlobal, + "3": self.keyNumberGlobal, + "4": self.keyNumberGlobal, + "5": self.keyNumberGlobal, + "6": self.keyNumberGlobal, + "7": self.keyNumberGlobal, + "8": self.keyNumberGlobal, + "9": self.keyNumberGlobal, + "0": self.keyNumberGlobal }, -1) self.list = [] @@ -1438,12 +1668,44 @@ class PacketManager(Screen): self.onShown.append(self.setWindowTitle) self.onLayoutFinish.append(self.rebuildList) + rcinput = eRCInput.getInstance() + rcinput.setKeyboardMode(rcinput.kmAscii) + + def keyNumberGlobal(self, val): + key = self.getKey(val) + if key is not None: + keyvalue = key.encode("utf-8") + if len(keyvalue) == 1: + self.setNextIdx(keyvalue[0]) + + def keyGotAscii(self): + keyvalue = unichr(getPrevAsciiCode()).encode("utf-8") + if len(keyvalue) == 1: + self.setNextIdx(keyvalue[0]) + + def setNextIdx(self,char): + if char in ("0", "1", "a"): + self["list"].setIndex(0) + else: + idx = self.getNextIdx(char) + if idx and idx <= self["list"].count: + self["list"].setIndex(idx) + + def getNextIdx(self,char): + idx = 0 + for i in self["list"].list: + if i[0][0] == char: + return idx + idx += 1 + def exit(self): self.ipkg.stop() if self.Console is not None: if len(self.Console.appContainers): for name in self.Console.appContainers.keys(): self.Console.kill(name) + rcinput = eRCInput.getInstance() + rcinput.setKeyboardMode(rcinput.kmNone) self.close() def reload(self): -- cgit v1.2.3 From 675f9d0eeb82577252a68ee263049acc1ff80bcc Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 20 Jul 2010 10:06:11 +0200 Subject: implement configurable http user-agent (fixes #224) --- .../Plugins/Extensions/MediaPlayer/settings.py | 2 ++ lib/service/servicemp3.cpp | 25 ++++++++++++++++++++++ lib/service/servicemp3.h | 2 ++ 3 files changed, 29 insertions(+) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/MediaPlayer/settings.py b/lib/python/Plugins/Extensions/MediaPlayer/settings.py index 0b95812f..7f42677d 100755 --- a/lib/python/Plugins/Extensions/MediaPlayer/settings.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/settings.py @@ -12,6 +12,8 @@ config.mediaplayer.repeat = ConfigYesNo(default=False) config.mediaplayer.savePlaylistOnExit = ConfigYesNo(default=True) config.mediaplayer.saveDirOnExit = ConfigYesNo(default=False) config.mediaplayer.defaultDir = ConfigDirectory() +config.mediaplayer.useAlternateUserAgent = ConfigYesNo(default=False) +config.mediaplayer.alternateUserAgent = ConfigText(default="") class DirectoryBrowser(Screen, HelpableScreen): diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index b34b62f2..b50b52d0 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -290,8 +290,20 @@ eServiceMP3::eServiceMP3(eServiceReference ref) if ( m_sourceinfo.is_streaming ) { uri = g_strdup_printf ("%s", filename); +<<<<<<< HEAD m_streamingsrc_timeout = eTimer::create(eApp);; CONNECT(m_streamingsrc_timeout->timeout, eServiceMP3::sourceTimeout); +======= + + std::string config_str; + if( ePythonConfigQuery::getConfigValue("config.mediaplayer.useAlternateUserAgent", config_str) == 0 ) + { + if ( config_str == "True" ) + ePythonConfigQuery::getConfigValue("config.mediaplayer.alternateUserAgent", m_useragent); + } + if ( m_useragent.length() == 0 ) + m_useragent = "Dream Multimedia Dreambox Enigma2 Mediaplayer"; +>>>>>>> b08c138... implement configurable http user-agent (fixes #224) } else if ( m_sourceinfo.containertype == ctCDA ) { @@ -353,6 +365,10 @@ eServiceMP3::eServiceMP3(eServiceReference ref) subs.language_code = std::string("und"); m_subtitleStreams.push_back(subs); } + if ( sourceinfo.is_streaming ) + { + g_signal_connect (G_OBJECT (m_gst_playbin), "notify::source", G_CALLBACK (gstHTTPSourceSetAgent), this); + } } else { m_event((iPlayableService*)this, evUser+12); @@ -1410,6 +1426,15 @@ GstBusSyncReply eServiceMP3::gstBusSyncHandler(GstBus *bus, GstMessage *message, return GST_BUS_PASS; } +void eServiceMP3::gstHTTPSourceSetAgent(GObject *object, GParamSpec *unused, gpointer user_data) +{ + eServiceMP3 *_this = (eServiceMP3*)user_data; + GstElement *source; + g_object_get(_this->m_gst_playbin, "source", &source, NULL); + g_object_set (G_OBJECT (source), "user-agent", _this->m_useragent.c_str(), NULL); + gst_object_unref(source); +} + audiotype_t eServiceMP3::gstCheckAudioPad(GstStructure* structure) { if (!structure) diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index af68bd91..01f7cf7f 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -208,6 +208,7 @@ private: static void gstCBsubtitleAvail(GstElement *element, gpointer user_data); GstPad* gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type); void gstPoll(const int&); + static void gstHTTPSourceSetAgent(GObject *source, GParamSpec *unused, gpointer user_data); std::list m_subtitle_pages; ePtr m_subtitle_sync_timer; @@ -224,6 +225,7 @@ private: RESULT seekToImpl(pts_t to); gint m_aspect, m_width, m_height, m_framerate, m_progressive; + std::string m_useragent; RESULT trickSeek(gdouble ratio); }; #endif -- cgit v1.2.3 From b5c3db5f8af9c6de71a0dadd3cc9e13ead7f06d6 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Sun, 25 Jul 2010 22:35:19 +0200 Subject: Softwaremanager: fix potential crash when trying to delete from empty list. Graphmultiepg: fix typo inside metafile. fixes #563 --- .../Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml | 2 +- .../Plugins/SystemPlugins/SoftwareManager/BackupRestore.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml b/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml index a10840da..3e2a3f6e 100755 --- a/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml +++ b/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml @@ -6,7 +6,7 @@ Dream Multimedia GraphMultiEPG - eenigma2-plugin-extensions-graphmultiepg + enigma2-plugin-extensions-graphmultiepg GraphMultiEPG shows a graphical timeline EPG. GraphMultiEPG shows a graphical timeline EPG.\nShows a nice overview of all running und upcoming tv shows. diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py index dcff3ca2..7bd7d7a2 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -251,8 +251,9 @@ class RestoreMenu(Screen): def KeyOk(self): if (self.exe == False) and (self.entry == True): self.sel = self["filelist"].getCurrent() - self.val = self.path + "/" + self.sel - self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore\nfollowing backup:\n") + self.sel + _("\nSystem will restart after the restore!")) + if self.sel: + self.val = self.path + "/" + self.sel + self.session.openWithCallback(self.startRestore, MessageBox, _("Are you sure you want to restore\nfollowing backup:\n") + self.sel + _("\nSystem will restart after the restore!")) def keyCancel(self): self.close() @@ -265,8 +266,9 @@ class RestoreMenu(Screen): def deleteFile(self): if (self.exe == False) and (self.entry == True): self.sel = self["filelist"].getCurrent() - self.val = self.path + "/" + self.sel - self.session.openWithCallback(self.startDelete, MessageBox, _("Are you sure you want to delete\nfollowing backup:\n" + self.sel )) + if self.sel: + self.val = self.path + "/" + self.sel + self.session.openWithCallback(self.startDelete, MessageBox, _("Are you sure you want to delete\nfollowing backup:\n" + self.sel )) def startDelete(self, ret = False): if (ret == True): -- cgit v1.2.3 From a4dbb3a4ca8e0926250cbe7be76291448e5e1f56 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Sat, 24 Jul 2010 15:41:58 +0200 Subject: SystemPlugins/WirelessLan: remove outdated flags.py and iwlibs.py. refs #558 --- .../Plugins/SystemPlugins/WirelessLan/Makefile.am | 2 - .../Plugins/SystemPlugins/WirelessLan/flags.py | 104 -- .../Plugins/SystemPlugins/WirelessLan/iwlibs.py | 1114 -------------------- 3 files changed, 1220 deletions(-) delete mode 100755 lib/python/Plugins/SystemPlugins/WirelessLan/flags.py delete mode 100755 lib/python/Plugins/SystemPlugins/WirelessLan/iwlibs.py (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/Makefile.am b/lib/python/Plugins/SystemPlugins/WirelessLan/Makefile.am index 2f362379..bdc1a884 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/Makefile.am @@ -4,8 +4,6 @@ SUBDIRS = meta install_PYTHON = \ __init__.py \ - flags.py \ - iwlibs.py \ plugin.py \ Wlan.py diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/flags.py b/lib/python/Plugins/SystemPlugins/WirelessLan/flags.py deleted file mode 100755 index 4435f845..00000000 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/flags.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: ISO-8859-1 -*- -# python-wifi -- a wireless library to access wireless cards via python -# Copyright (C) 2004, 2005, 2006 Róman Joost -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA - -modes = ['Auto', - 'Ad-Hoc', - 'Managed', - 'Master', - 'Repeat', - 'Second', - 'Monitor'] - -IFNAMSIZE = 16 -IW_ESSID_MAX_SIZE = 16 - -KILO = 10**3 -MEGA = 10**6 -GIGA = 10**9 - -# ioctl calls for the Linux/i386 kernel -SIOCIWFIRST = 0x8B00 # FIRST ioctl identifier -SIOCGIFCONF = 0x8912 # ifconf struct -SIOCGIWNAME = 0x8B01 # get name == wireless protocol -SIOCGIWFREQ = 0x8B05 # get channel/frequency -SIOCSIWMODE = 0x8B06 # set the operation mode -SIOCGIWMODE = 0x8B07 # get operation mode -SIOCGIWSENS = 0x8B09 # get sensitivity -SIOCGIWAP = 0x8B15 # get AP MAC address -SIOCSIWSCAN = 0x8B18 # set scanning off -SIOCGIWSCAN = 0x8B19 # get scanning results -SIOCGIWRATE = 0x8B21 # get default bit rate -SIOCGIWRTS = 0x8B23 # get rts/cts threshold -SIOCGIWFRAG = 0x8B25 # get fragmention thrh -SIOCGIWTXPOW = 0x8B27 # get transmit power (dBm) -SIOCGIWRETRY = 0x8B29 # get retry limit -SIOCGIWRANGE = 0x8B0B # range -SIOCGIWSTATS = 0x8B0F # get wireless statistics -SIOCSIWESSID = 0x8B1A # set essid -SIOCGIWESSID = 0x8B1B # get essid -SIOCGIWPOWER = 0x8B2D # get power managment settings -SIOCGIWENCODE = 0x8B2B # get encryption information -SIOCIWLAST = 0x8BFF # LAST ioctl identifier - -# Power management flags -IW_POWER_ON = 0x0000 # No details ... -IW_POWER_TYPE = 0xF000 # Type of parameter -IW_POWER_PERIOD = 0x1000 # Value is a period/duration of -IW_POWER_TIMEOUT = 0x2000 # Value is a timeout -IW_POWER_MODE = 0x0F00 # Power management mode -IW_POWER_MIN = 0x0001 # Value is a minimum -IW_POWER_MAX = 0x0002 # Value is a maximum -IW_POWER_RELATIVE = 0x0004 # Value is not in seconds/ms/us - -# Retry limits -IW_RETRY_TYPE = 0xF000 # Type of parameter - -# encoding stuff -IW_ENCODE_DISABLED = 0x8000 # encoding is disabled -IW_ENCODE_NOKEY = 0x0800 # key is write only, not present - -# constants responsible for scanning -IW_SCAN_MAX_DATA = 4096 - -IW_EV_LCP_LEN = 4 -IW_EV_CHAR_LEN = IW_EV_LCP_LEN + IFNAMSIZE -IW_EV_UINT_LEN = IW_EV_LCP_LEN + 4 -IW_EV_FREQ_LEN = IW_EV_LCP_LEN + 8 -IW_EV_ADDR_LEN = IW_EV_LCP_LEN + 16 -IW_EV_POINT_LEN = IW_EV_LCP_LEN + 4 -IW_EV_PARAM_LEN = IW_EV_LCP_LEN + 8 -IW_EV_QUAL_LEN = IW_EV_LCP_LEN + 4 - -EPERM = 1 -E2BIG = 7 -EAGAIN = 11 - -IWHT_NULL = 0 -IWHT_CHAR = 2 -IWHT_UINT = 4 -IWHT_FREQ = 5 -IWHT_ADDR = 6 -IWHT_POINT = 8 -IWHT_PARAM = 9 -IWHT_QUAL = 10 - -IWEVFIRST = 0x8C00 # FIRST event identifier -IWEVQUAL = 0x8C01 # Quality statistics from scan -IWEVCUSTOM = 0x8C02 # Custom Ascii string from Driver -IWEVLAST = 0x8C0A # LAST event identifier diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/iwlibs.py b/lib/python/Plugins/SystemPlugins/WirelessLan/iwlibs.py deleted file mode 100755 index c5f9c6d2..00000000 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/iwlibs.py +++ /dev/null @@ -1,1114 +0,0 @@ -# -*- coding: ISO-8859-1 -*- -# python-wifi -- a wireless library to access wireless cards via python -# Copyright (C) 2004, 2005, 2006 Róman Joost -# -# Contributions from: -# Mike Auty (Iwscanresult, Iwscan) -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public License -# as published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA - -from struct import pack as struct_pack, \ - unpack as struct_unpack, \ - calcsize as struct_calcsize - -from array import array -from math import ceil, log10 -from fcntl import ioctl -from socket import AF_INET, SOCK_DGRAM, socket -from time import sleep -from re import compile - -from flags import * - -def getNICnames(): - """ extract wireless device names of /proc/net/wireless - - returns empty list if no devices are present - - >>> getNICnames() - ['eth1', 'wifi0'] - """ - device = compile('[a-z]+[0-9]+') - ifnames = [] - - f = open('/proc/net/wireless', 'r') - data = f.readlines() - for line in data: - try: - ifnames.append(device.search(line).group()) - except AttributeError: - pass - # if we couldn't lookup the devices, try to ask the kernel - if ifnames == []: - ifnames = getConfiguredNICnames() - - return ifnames - -def getConfiguredNICnames(): - """get the *configured* ifnames by a systemcall - - >>> getConfiguredNICnames() - [] - """ - iwstruct = Iwstruct() - ifnames = [] - buff = array('c', '\0'*1024) - caddr_t, length = buff.buffer_info() - s = iwstruct.pack('iP', length, caddr_t) - try: - result = iwstruct._fcntl(SIOCGIFCONF, s) - except IOError, (i, e): - return i, e - - # get the interface names out of the buffer - for i in range(0, 1024, 32): - ifname = buff.tostring()[i:i+32] - ifname = struct_unpack('32s', ifname)[0] - ifname = ifname.split('\0', 1)[0] - if ifname: - # verify if ifnames are really wifi devices - wifi = Wireless(ifname) - result = wifi.getAPaddr() - if result[0] == 0: - ifnames.append(ifname) - - return ifnames - -def makedict(**kwargs): - return kwargs - - -class Wireless(object): - """Access to wireless interfaces""" - - def __init__(self, ifname): - self.sockfd = socket(AF_INET, SOCK_DGRAM) - self.ifname = ifname - self.iwstruct = Iwstruct() - - def getAPaddr(self): - """ returns accesspoint mac address - - >>> from iwlibs import Wireless, getNICnames - >>> ifnames = getNICnames() - >>> ifnames - ['eth1', 'wifi0'] - >>> wifi = Wireless(ifnames[0]) - >>> wifi.getAPaddr() - '00:0D:88:8E:4E:93' - - Test with non-wifi card: - >>> wifi = Wireless('eth0') - >>> wifi.getAPaddr() - (95, 'Operation not supported') - - Test with non-existant card: - >>> wifi = Wireless('eth2') - >>> wifi.getAPaddr() - (19, 'No such device') - """ - buff, s = self.iwstruct.pack_wrq(32) - i, result = self.iwstruct.iw_get_ext(self.ifname, - SIOCGIWAP, - data=s) - if i > 0: - return result - - return self.iwstruct.getMAC(result) - - def getBitrate(self): - """returns device currently set bit rate - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getBitrate() - '11 Mb/s' - """ - i, result = self.iwstruct.iw_get_ext(self.ifname, - SIOCGIWRATE) - if i > 0: - return result - iwfreq = Iwfreq(result) - return iwfreq.getBitrate() - - def getBitrates(self): - """returns the number of available bitrates for the device - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> num, rates = wifi.getBitrates() - >>> num == len(rates) - True - """ - range = Iwrange(self.ifname) - if range.errorflag: - return (range.errorflag, range.error) - return (range.num_bitrates, range.bitrates) - - def getChannelInfo(self): - """returns the number of channels and available frequency for - the device - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> num, rates = wifi.getChannelInfo() - >>> num == len(rates) - True - """ - range = Iwrange(self.ifname) - if range.errorflag: - return (range.errorflag, range.error) - return (range.num_channels, range.frequencies) - - def getEssid(self): - """get essid information - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getEssid() - 'romanofski' - """ - essid = "" - buff, s = self.iwstruct.pack_wrq(32) - i, result = self.iwstruct.iw_get_ext(self.ifname, - SIOCGIWESSID, - data=s) - if i > 0: - return result - str = buff.tostring() - return str.strip('\x00') - - def setEssid(self, essid): - """set essid """ - raise NotImplementedError - if len(essid) > IW_ESSID_MAX_SIZE: - return "essid to big" - buff, s = self.iwstruct.pack_test(essid, 32) - i, result = self.iwstruct.iw_get_ext(self.ifname, - SIOCSIWESSID, - data=s) - if i > 0: - return result - - def getEncryption(self): - """get encryption information which is probably a string of '*', - 'open', 'private' - - as a normal user, you will get a 'Operation not permitted' - error: - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getEncryption() - (1, 'Operation not permitted') - """ - iwpoint = Iwpoint(self.ifname) - if iwpoint.errorflag: - return (iwpoint.errorflag, iwpoint.error) - return iwpoint.getEncryptionKey() - - def getFragmentation(self): - """returns fragmentation threshold - - It depends on what the driver says. If you have fragmentation - threshold turned on, you'll get an int. If it's turned of - you'll get a string: 'off'. - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getFragmentation() - 'off' - """ - iwparam = Iwparam(self.ifname, SIOCGIWFRAG) - if iwparam.errorflag: - return (iwparam.errorflag, iwparam.error) - return iwparam.getValue() - - def getFrequency(self): - """returns currently set frequency of the card - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getFrequency() - '2.417GHz' - """ - i, r = self.iwstruct.iw_get_ext(self.ifname, - SIOCGIWFREQ) - if i > 0: - return (i, r) - iwfreq = Iwfreq(r) - return iwfreq.getFrequency() - - - def getMode(self): - """returns currently set operation mode - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getMode() - 'Managed' - """ - i, result = self.iwstruct.iw_get_ext(self.ifname, - SIOCGIWMODE) - if i > 0: - return result - mode = self.iwstruct.unpack('i', result[:4])[0] - return modes[mode] - - def setMode(self, mode): - """sets the operation mode """ - try: - this_modes = [x.lower() for x in modes] - mode = mode.lower() - wifimode = this_modes.index(mode) - except ValueError: - return "Invalid operation mode!" - - s = self.iwstruct.pack('I', wifimode) - i, result = self.iwstruct.iw_get_ext(self.ifname, - SIOCSIWMODE, - data=s) - if i > 0: - return result - - def getWirelessName(self): - """ returns wireless name - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getWirelessName() - 'IEEE 802.11-DS' - """ - i, result = self.iwstruct.iw_get_ext(self.ifname, - SIOCGIWNAME) - if i > 0: - return result - return result.split('\0')[0] - - def getPowermanagement(self): - """returns power management settings - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getPowermanagement() - 'off' - """ - iwparam = Iwparam(self.ifname, SIOCGIWPOWER) - if iwparam.errorflag: - return (iwparam.errorflag, iwparam.error) - return iwparam.getValue() - - - def getRetrylimit(self): - """returns limit retry/lifetime - - man iwconfig: - Most cards have MAC retransmissions, and some allow to set - the behaviour of the retry mechanism. - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getRetrylimit() - 16 - """ - iwparam = Iwparam(self.ifname, SIOCGIWRETRY) - if iwparam.errorflag: - return (iwparam.errorflag, iwparam.error) - return iwparam.getValue() - - def getRTS(self): - """returns rts threshold - - returns int, 'auto', 'fixed', 'off' - - man iwconfig: - RTS/CTS adds a handshake before each packet transmission to - make sure that the channel is clear. This adds overhead, but - increases performance in case of hidden nodes or a large - number of active nodes. This parameter sets the size of the - smallest packet for which the node sends RTS; a value equal - to the maximum packet size disable the mechanism. - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getRTS() - 'off' - """ - iwparam = Iwparam(self.ifname, SIOCGIWRTS) - if iwparam.errorflag: - return (iwparam.errorflag, iwparam.error) - return iwparam.getValue() - - def getSensitivity(self): - """returns sensitivity information - - man iwconfig: - This is the lowest signal level for which the hardware - attempt packet reception, signals weaker than this are - ignored. This is used to avoid receiving background noise, - so you should set it according to the average noise - level. Positive values are assumed to be the raw value used - by the hardware or a percentage, negative values are - assumed to be dBm. - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getSensitivity() - 'off' - - """ - iwparam = Iwparam(self.ifname, SIOCGIWSENS) - if iwparam.errorflag: - return (iwparam.errorflag, iwparam.error) - return iwparam.getValue() - - def getTXPower(self): - """returns transmit power in dBm - - >>> from iwlibs import Wireless - >>> wifi = Wireless('eth1') - >>> wifi.getTXPower() - '17 dBm' - """ - i, r = self.iwstruct.iw_get_ext(self.ifname, - SIOCGIWTXPOW) - if i > 0: - return (i, r) - iwfreq = Iwfreq(r) - return iwfreq.getTransmitPower() - - def getStatistics(self): - """returns statistics information which can also be found in - /proc/net/wireless - """ - iwstats = Iwstats(self.ifname) - if iwstats.errorflag > 0: - return (iwstats.errorflag, iwstats.error) - return [iwstats.status, iwstats.qual, iwstats.discard, - iwstats.missed_beacon] - - def scan(self): - """returns Iwscanresult objects, after a successful scan""" - iwscan = Iwscan(self.ifname) - return iwscan.scan() - - -class Iwstruct(object): - """basic class to handle iwstruct data """ - - def __init__(self): - self.idx = 0 - self.sockfd = socket(AF_INET, SOCK_DGRAM) - - def parse_data(self, fmt, data): - """ unpacks raw C data """ - size = struct_calcsize(fmt) - idx = self.idx - - str = data[idx:idx + size] - self.idx = idx+size - value = struct_unpack(fmt, str) - - # take care of a tuple like (int, ) - if len(value) == 1: - return value[0] - else: - return value - - def pack(self, fmt, *args): - """ calls struct_pack and returns the result """ - return struct_pack(fmt, *args) - - def pack_wrq(self, buffsize): - """ packs wireless request data for sending it to the kernel """ - # Prepare a buffer - # We need the address of our buffer and the size for it. The - # ioctl itself looks for the pointer to the address in our - # memory and the size of it. - # Dont change the order how the structure is packed!!! - buff = array('c', '\0'*buffsize) - caddr_t, length = buff.buffer_info() - s = struct_pack('Pi', caddr_t, length) - return buff, s - - def pack_test(self, string, buffsize): - """ packs wireless request data for sending it to the kernel """ - buffsize = buffsize - len(string) - buff = array('c', string+'\0'*buffsize) - caddr_t, length = buff.buffer_info() - s = struct_pack('Pii', caddr_t, length, 1) - return buff, s - - def unpack(self, fmt, packed_data): - """ unpacks data with given format """ - return struct_unpack(fmt, packed_data) - - def _fcntl(self, request, args): - return ioctl(self.sockfd.fileno(), request, args) - - def iw_get_ext(self, ifname, request, data=None): - """ read information from ifname """ - # put some additional data behind the interface name - if data is not None: - buff = IFNAMSIZE-len(ifname) - ifreq = ifname + '\0'*buff - ifreq = ifreq + data - else: - ifreq = (ifname + '\0'*32) - - try: - result = self._fcntl(request, ifreq) - except IOError, (i, e): - return i, e - - return (0, result[16:]) - - def getMAC(self, packed_data): - """ extracts mac addr from packed data and returns it as str """ - mac_addr = struct_unpack('xxBBBBBB', packed_data[:8]) - return "%02X:%02X:%02X:%02X:%02X:%02X" % mac_addr - -class Iwparam(object): - """class to hold iwparam data """ - - def __init__(self, ifname, ioctl): - # (i) value, (b) fixed, (b) disabled, (b) flags - self.fmt = "ibbH" - self.value = 0 - self.fixed = 0 - self.disabled = 0 - self.flags = 0 - self.errorflag = 0 - self.error = "" - self.ioctl = ioctl - self.ifname = ifname - self.update() - - def getValue(self): - """returns the value if not disabled """ - - if self.disabled: - return 'off' - if self.flags & IW_RETRY_TYPE == 0: - return self.getRLAttributes() - else: - return self.getPMAttributes() - - def getRLAttributes(self): - """returns a string with attributes determined by self.flags - """ - return self.value - - def getPMAttributes(self): - """returns a string with attributes determined by self.flags - and IW_POWER* - """ - result = "" - - # Modifiers - if self.flags & IW_POWER_MIN == 0: - result = " min" - if self.flags & IW_POWER_MAX == 0: - result = " max" - - # Type - if self.flags & IW_POWER_TIMEOUT == 0: - result = " period:" - else: - result = " timeout:" - # Value with or without units - # IW_POWER_RELATIVE - value is *not* in s/ms/us - if self.flags & IW_POWER_RELATIVE: - result += "%f" %(float(self.value)/MEGA) - else: - if self.value >= MEGA: - result += "%fs" %(float(self.value)/MEGA) - elif self.value >= KILO: - result += "%fms" %(float(self.value)/KILO) - else: - result += "%dus" % self.value - - return result - - def update(self): - iwstruct = Iwstruct() - i, r = iwstruct.iw_get_ext(self.ifname, - self.ioctl) - if i > 0: - self.errorflag = i - self.error = r - self._parse(r) - - def _parse(self, data): - """ unpacks iwparam data """ - iwstruct = Iwstruct() - self.value, self.fixed, self.disabled, self.flags =\ - iwstruct.parse_data(self.fmt, data) - -class Iwfreq(object): - """ class to hold iwfreq data - delegates to Iwstruct class - """ - - def __init__(self, data=None): - self.fmt = "ihbb" - if data is not None: - self.frequency = self.parse(data) - else: - self.frequency = 0 - self.iwstruct = Iwstruct() - - def __getattr__(self, attr): - return getattr(self.iwstruct, attr) - - def parse(self, data): - """ unpacks iwparam""" - - size = struct_calcsize(self.fmt) - m, e, i, pad = struct_unpack(self.fmt, data[:size]) - # XXX well, its not *the* frequency - we need a better name - if e == 0: - return m - else: - return float(m)*10**e - - def getFrequency(self): - """returns Frequency (str) - - data - binary data returned by systemcall (iw_get_ext()) - """ - freq = self.frequency - - if freq >= GIGA: - return "%0.3fGHz" %(freq/GIGA) - - if freq >= MEGA: - return "%0.3fMHZ" %(freq/MEGA) - - if freq >= KILO: - return "%0.3fKHz" %(freq/KILO) - - def getBitrate(self): - """ returns Bitrate in Mbit - - data - binary data returned by systemcall (iw_get_ext()) - """ - bitrate = self.frequency - - if bitrate >= GIGA: - return "%i Gb/s" %(bitrate/GIGA) - - if bitrate >= MEGA: - return "%i Mb/s" %(bitrate/MEGA) - - if bitrate >= KILO: - return "%i Kb/s" %(bitrate/KILO) - - def getTransmitPower(self): - """ returns transmit power in dbm """ - # XXX something flaky is going on with m and e - # eg. m = 50 and e should than be 0, because the number is stored in - # m and don't needs to be recalculated - return "%i dBm" %self.mw2dbm(self.frequency/10) - - def getChannel(self, freq): - """returns channel information given by frequency - - returns None if frequency can't be converted - freq = frequency to convert (int) - iwrange = Iwrange object - """ - - try: - freq = float(freq) - except: - return None - - lut = {} - #13 Channels beginning at 2.412GHz and inreasing by 0,005 GHz steps - for i in range(0,12): - cur = float( 2.412 + ( i * 0.005 ) ) - lut[str(cur)] = i+1 - # Channel 14 need special actions ;) - lut['2.484'] = 14 - - - if str(freq) in lut.keys(): - return lut[str(freq)] - - return None - - - def mw2dbm(self, mwatt): - """ converts mw to dbm(float) """ - return ceil(10.0 * log10(mwatt)) - - def _setFrequency(self, list): - """sets self.frequency by given list - - currently only used by Iwrange - """ - assert len(list) == 4 - m, e, i, pad = list - if e == 0: - self.frequency = m - else: - self.frequency = m #float(m)*10**e - -class Iwstats(object): - """ class to hold iwstat data """ - - def __init__(self, ifname): - # (2B) status, 4B iw_quality, 6i iw_discarded - self.fmt = "2B4B6i" - self.status = 0 - self.qual = Iwquality() - self.discard = {} - self.missed_beacon = 0 - self.ifname = ifname - self.errorflag = 0 - self.error = "" - self.update() - - def update(self): - iwstruct = Iwstruct() - buff, s = iwstruct.pack_wrq(32) - i, result = iwstruct.iw_get_ext(self.ifname, - SIOCGIWSTATS, - data=s) - if i > 0: - self.error = result - self.errorflag = i - self._parse(buff.tostring()) - - def _parse(self, data): - """ unpacks iwstruct data """ - struct = Iwstruct() - iwqual = Iwquality() - iwstats_data = struct.parse_data(self.fmt, data) - - self.status = iwstats_data[0:2] - self.qual.quality, self.qual.sl, self.qual.nl,\ - self.qual.flags = iwstats_data[2:6] - nwid, code, frag, retries, flags = iwstats_data[6:11] - self.missed_beacon = iwstats_data[11:12][0] - self.discard = makedict(nwid=nwid, code=code, - fragment=frag, retries=retries, misc=flags) - -class Iwquality(object): - """ class to hold iwquality data """ - - def __init__(self): - self.quality = 0 - self.sl = 0 - self.nl = 0 - self.updated = 0 - self.fmt = "4B" - - def parse(self, data): - """ unpacks iwquality data """ - struct = Iwstruct() - qual, sl, nl, flags = struct.parse_data(self.fmt, data) - - # compute signal and noise level - self.signal_level = sl - self.noise_level = nl - - # asign the other values - self.quality = qual - self.updated = flags - - def setValues(self, list): - """ assigns values given by a list to our attributes """ - attributes = ["quality", "signallevel", "noise_level", - "updated"] - assert len(list) == 4 - - for i in range(len(list)): - setattr(self, attributes[i], list[i]) - - def getSignallevel(self): - """ returns signal level """ - return self.sl-0x100 - - def setSignallevel(self, sl): - """ sets signal level """ - self.sl = sl - signallevel = property(getSignallevel, setSignallevel) - - def getNoiselevel(self): - """ returns noise level """ - return self.nl - 0x100 - - def setNoiselevel(self): - raise NotImplementedError - self.nl = nl - noiselevel = property(getNoiselevel, setNoiselevel) - -class Iwpoint(object): - """ class to hold iwpoint data """ - - def __init__(self, ifname): - self.key = [0,0,0,0] - self.fields = 0 - self.flags = 0 - # (4B) pointer to data, H length, H flags - self.fmt = "4BHH" - self.errorflag = 0 - self.error = "" - self.ifname = ifname - self.update() - - def __getattr__(self, attr): - return getattr(self.iwstruct, attr) - - def update(self): - iwstruct = Iwstruct() - buff, s = iwstruct.pack_wrq(32) - i, result = iwstruct.iw_get_ext(self.ifname, - SIOCGIWENCODE, - data=s) - if i > 0: - self.errorflag = i - self.error = result - self._parse(result) - - def getEncryptionKey(self): - """ returns encryption key as '**' or 'off' as str """ - if self.flags & IW_ENCODE_DISABLED != 0: - return 'off' - elif self.flags & IW_ENCODE_NOKEY != 0: - # a key is set, so print it - return '**' * self.fields - - def _parse(self, data): - """ unpacks iwpoint data - """ - iwstruct = Iwstruct() - ptr, ptr, ptr, ptr, self.fields, self.flags =\ - iwstruct.parse_data(self.fmt, data) - self.key = [ptr, ptr, ptr, ptr] - -class Iwrange(object): - """holds iwrange struct """ - IW_MAX_FREQUENCIES = 32 - - def __init__(self, ifname): - self.fmt = "iiihb6ii4B4Bi32i2i2i2i2i3h8h2b2bhi8i2b3h2i2ihB17x"\ - + self.IW_MAX_FREQUENCIES*"ihbb" - - self.ifname = ifname - self.errorflag = 0 - self.error = "" - - # informative stuff - self.throughput = 0 - - # nwid (or domain id) - self.min_nwid = self.max_nwid = 0 - - # frequency for backward compatibility - self.old_num_channels = self.old_num_frequency = self.old_freq = 0 - - # signal level threshold - self.sensitivity = 0 - - # link quality - self.max_qual = Iwquality() - self.avg_qual = Iwquality() - - # rates - self.num_bitrates = 0 - self.bitrates = [] - - # rts threshold - self.min_rts = self.max_rts = 0 - - # fragmention threshold - self.min_frag = self.max_frag = 0 - - # power managment - self.min_pmp = self.max_pmp = 0 - self.min_pmt = self.max_pmt = 0 - self.pmp_flags = self.pmt_flags = self.pm_capa = 0 - - # encoder stuff - self.encoding_size = 0 - self.num_encoding_sizes = self.max_encoding_tokens = 0 - self.encoding_login_index = 0 - - # transmit power - self.txpower_capa = self.num_txpower = self.txpower = 0 - - # wireless extension version info - self.we_vers_compiled = self.we_vers_src = 0 - - # retry limits and lifetime - self.retry_capa = self.retry_flags = self.r_time_flags = 0 - self.min_retry = self.max_retry = 0 - self.min_r_time = self.max_r_time = 0 - - # frequency - self.num_channels = self.num_frequency = 0 - self.frequencies = [] - self.update() - - def update(self): - """updates Iwrange object by a system call to the kernel - and updates internal attributes - """ - iwstruct = Iwstruct() - buff, s = iwstruct.pack_wrq(640) - i, result = iwstruct.iw_get_ext(self.ifname, - SIOCGIWRANGE, - data=s) - if i > 0: - self.errorflag = i - self.error = result - data = buff.tostring() - self._parse(data) - - def _parse(self, data): - struct = Iwstruct() - result = struct.parse_data(self.fmt, data) - - # XXX there is maybe a much more elegant way to do this - self.throughput, self.min_nwid, self.max_nwid = result[0:3] - self.old_num_channels, self.old_num_frequency = result[3:5] - self.old_freq = result[5:11] - self.sensitivity = result[11] - self.max_qual.setValues(result[12:16]) - self.avg_qual.setValues(result[16:20]) - self.num_bitrates = result[20] # <- XXX - raw_bitrates = result[21:53] - for rate in raw_bitrates: - iwfreq = Iwfreq() - iwfreq.frequency = rate - br = iwfreq.getBitrate() - if br is not None: - self.bitrates.append(br) - - self.min_rts, self.max_rts = result[53:55] - self.min_frag, self.max_frag = result[55:57] - self.min_pmp, self.max_pmp = result[57:59] - self.min_pmt, self.max_pmt = result[59:61] - self.pmp_flags, self.pmt_flags, self.pm_capa = result[61:64] - self.encoding_size = result[64:72] - self.num_encoding_sizes, self.max_encoding_tokens = result[72:74] - self.encoding_login_index = result[74:76] - self.txpower_capa, self.num_txpower = result[76:78] - self.txpower = result[78:86] - self.we_vers_compiled, self.we_vers_src = result[86:88] - self.retry_capa, self.retry_flags, self.r_time_flags = result[88:91] - self.min_retry, self.max_retry = result[91:93] - self.min_r_time, self.max_r_time = result[93:95] - self.num_channels = result[95] - self.num_frequency = result[96] - freq = result[97:] - - i = self.num_frequency - for x in range(0, len(freq), 4): - iwfreq = Iwfreq() - iwfreq._setFrequency(freq[x:x+4]) - fq = iwfreq.getFrequency() - if fq is not None: - self.frequencies.append(fq) - i -= 1 - if i <= 0: - break - -class Iwscan(object): - """class to handle AP scanning""" - - def __init__(self, ifname): - self.ifname = ifname - self.range = Iwrange(ifname) - self.errorflag = 0 - self.error = "" - self.stream = None - self.aplist = None - - def scan(self, fullscan=True): - """Completes a scan for available access points, - and returns them in Iwscanresult format - - fullscan: If False, data is read from a cache of the last scan - If True, a scan is conducted, and then the data is read - """ - # By default everything is fine, do not wait - result = 1 - if fullscan: - self.setScan() - if self.errorflag > EPERM: - raise RuntimeError, 'setScan failure ' + str(self.errorflag) + " " + str(self.error) - return None - elif self.errorflag < EPERM: - # Permission was NOT denied, therefore we must WAIT to get results - result = 250 - - while (result > 0): - sleep(result/1000) - result = self.getScan() - - if result < 0 or self.errorflag != 0: - raise RuntimeError, 'getScan failure ' + str(self.errorflag) + " " + str(self.error) - - return self.aplist - - - def setScan(self): - """Triggers the scan, if we have permission - """ - iwstruct = Iwstruct() - s = iwstruct.pack('Pii', 0, 0, 0) - i, result = iwstruct.iw_get_ext(self.ifname, - SIOCSIWSCAN,s) - if i > 0: - self.errorflag = i - self.error = result - return result - - def getScan(self): - """Retreives results, stored from the most recent scan - Returns 0 if successful, a delay if the data isn't ready yet - or -1 if something really nasty happened - """ - iwstruct = Iwstruct() - i = E2BIG - bufflen = IW_SCAN_MAX_DATA - - # Keep resizing the buffer until it's large enough to hold the scan - while (i == E2BIG): - buff, s = iwstruct.pack_wrq(bufflen) - i, result = iwstruct.iw_get_ext(self.ifname, - SIOCGIWSCAN, - data=s) - if i == E2BIG: - pbuff, newlen = iwstruct.unpack('Pi', s) - if bufflen < newlen: - bufflen = newlen - else: - bufflen = bufflen * 2 - - if i == EAGAIN: - return 100 - if i > 0: - self.errorflag = i - self.error = result - return -1 - - pbuff, reslen = iwstruct.unpack('Pi', s) - if reslen > 0: - # Initialize the stream, and turn it into an enumerator - self.aplist = self._parse(buff.tostring()) - return 0 - - def _parse(self, data): - """Parse the event stream, and return a list of Iwscanresult objects - """ - iwstruct = Iwstruct() - scanresult = None - aplist = [] - - # Run through the stream, until broken - while 1: - # If we're the stream doesn't have enough space left for a header, break - if len(data) < IW_EV_LCP_LEN: - break; - - # Unpack the header - length, cmd = iwstruct.unpack('HH', data[:4]) - # If the header says the following data is shorter than the header, then break - if length < IW_EV_LCP_LEN: - break; - - # Put the events into their respective result data - if cmd == SIOCGIWAP: - if scanresult is not None: - aplist.append(scanresult) - scanresult = Iwscanresult(data[IW_EV_LCP_LEN:length], self.range) - elif scanresult is None: - raise RuntimeError, 'Attempting to add an event without AP data' - else: - scanresult.addEvent(cmd, data[IW_EV_LCP_LEN:length]) - - # We're finished with the preveious event - data = data[length:] - - # Don't forgset the final result - if scanresult.bssid != "00:00:00:00:00:00": - aplist.append(scanresult) - else: - raise RuntimeError, 'Attempting to add an AP without a bssid' - return aplist - -class Iwscanresult(object): - """An object to contain all the events associated with a single scanned AP - """ - - def __init__(self, data, range): - """Initialize the scan result with the access point data""" - self.iwstruct = Iwstruct() - self.range = range - self.bssid = "%02X:%02X:%02X:%02X:%02X:%02X" % struct_unpack('BBBBBB', data[2:8]) - self.essid = None - self.mode = None - self.rate = [] - self.quality = Iwquality() - self.frequency = None - self.encode = None - self.custom = [] - self.protocol = None - - def addEvent(self, cmd, data): - """Attempts to add the data from an event to a scanresult - Only certain data is accept, in which case the result is True - If the event data is invalid, None is returned - If the data is valid but unused, False is returned - """ - if cmd <= SIOCIWLAST: - if cmd < SIOCIWFIRST: - return None - elif cmd >= IWEVFIRST: - if cmd > IWEVLAST: - return None - else: - return None - - if cmd == SIOCGIWESSID: - self.essid = data[4:] - elif cmd == SIOCGIWMODE: - self.mode = modes[self.iwstruct.unpack('i', data[:4])[0]] - elif cmd == SIOCGIWRATE: - # TODO, deal with multiple rates, or at least the highest rate - freqsize = struct_calcsize("ihbb") - while len(data) >= freqsize: - iwfreq = Iwfreq(data) - self.rate.append(iwfreq.getBitrate()) - data = data[freqsize:] - elif cmd == IWEVQUAL: - self.quality.parse(data) - elif cmd == SIOCGIWFREQ: - self.frequency = Iwfreq(data) - elif cmd == SIOCGIWENCODE: - self.encode = data - elif cmd == IWEVCUSTOM: - self.custom.append(data[1:]) - elif cmd == SIOCGIWNAME: - self.protocol = data[:len(data)-2] - else: - #print "Cmd:", cmd - return False - return True \ No newline at end of file -- cgit v1.2.3 From 6be1855d457d28e25917a29f710f2401519d7160 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Sat, 24 Jul 2010 23:14:58 +0200 Subject: Enigma2-Network: update Wlan plugin to support new python-wifi. some fixes and cleanups. refs #558 --- lib/python/Components/About.py | 11 ++ lib/python/Components/Network.py | 54 ++++--- .../SystemPlugins/NetworkWizard/NetworkWizard.py | 2 +- .../Plugins/SystemPlugins/WirelessLan/Wlan.py | 179 ++++++++++----------- .../Plugins/SystemPlugins/WirelessLan/plugin.py | 73 ++++++++- lib/python/Screens/NetworkSetup.py | 68 +++++--- 6 files changed, 251 insertions(+), 136 deletions(-) mode change 100644 => 100755 lib/python/Components/About.py (limited to 'lib/python/Plugins') diff --git a/lib/python/Components/About.py b/lib/python/Components/About.py old mode 100644 new mode 100755 index 8e332e33..6b322c9d --- a/lib/python/Components/About.py +++ b/lib/python/Components/About.py @@ -1,5 +1,6 @@ from Tools.Directories import resolveFilename, SCOPE_SYSETC from enigma import getEnigmaVersionString +from os import popen class About: def __init__(self): @@ -43,4 +44,14 @@ class About: def getEnigmaVersionString(self): return getEnigmaVersionString() + def getKernelVersionString(self): + try: + result = popen("uname -r","r").read().strip("\n").split('-') + kernel_version = result[0] + return kernel_version + except: + pass + + return "unknown" + about = About() diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py index e8a3d459..e980cb8c 100755 --- a/lib/python/Components/Network.py +++ b/lib/python/Components/Network.py @@ -4,6 +4,7 @@ from socket import * from enigma import eConsoleAppContainer from Components.Console import Console from Components.PluginComponent import plugins +from Components.About import about from Plugins.Plugin import PluginDescriptor class Network: @@ -349,8 +350,10 @@ class Network: return _("Zydas")+ " " + str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.") elif os_path.realpath(driverdir).endswith('rt73'): return _("Ralink")+ " " + str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.") + elif os_path.realpath(driverdir).endswith('rt73usb'): + return _("Ralink")+ " " + str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.") else: - return _("Unknown network adapter.") + return str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.") else: return _("Unknown network adapter.") @@ -606,24 +609,39 @@ class Network: if callback is not None: callback(True) - def detectWlanModule(self): + def detectWlanModule(self, iface = None): self.wlanmodule = None - rt73_dir = "/sys/bus/usb/drivers/rt73/" - zd1211b_dir = "/sys/bus/usb/drivers/zd1211b/" - madwifi_dir = "/sys/bus/pci/drivers/ath_pci/" - if os_path.exists(madwifi_dir): - files = listdir(madwifi_dir) - if len(files) >= 1: - self.wlanmodule = 'madwifi' - if os_path.exists(rt73_dir): - rtfiles = listdir(rt73_dir) - if len(rtfiles) == 2 or len(rtfiles) == 5: - self.wlanmodule = 'ralink' - if os_path.exists(zd1211b_dir): - zdfiles = listdir(zd1211b_dir) - if len(zdfiles) == 1 or len(zdfiles) == 5: - self.wlanmodule = 'zydas' - return self.wlanmodule + classdir = "/sys/class/net/" + iface + "/device/" + driverdir = "/sys/class/net/" + iface + "/device/driver/" + if os_path.exists(classdir): + classfiles = listdir(classdir) + driver_found = False + nl80211_found = False + for x in classfiles: + if x == 'driver': + driver_found = True + if x.startswith('ieee80211:'): + nl80211_found = True + + if driver_found and nl80211_found: + #print about.getKernelVersionString() + self.wlanmodule = "nl80211" + else: + if driver_found and not nl80211_found: + driverfiles = listdir(driverdir) + if os_path.realpath(driverdir).endswith('ath_pci'): + if len(driverfiles) >= 1: + self.wlanmodule = 'madwifi' + if os_path.realpath(driverdir).endswith('rt73'): + if len(driverfiles) == 2 or len(driverfiles) == 5: + self.wlanmodule = 'ralink' + if os_path.realpath(driverdir).endswith('zd1211b'): + if len(driverfiles) == 1 or len(driverfiles) == 5: + self.wlanmodule = 'zydas' + if self.wlanmodule is None: + self.wlanmodule = "wext" + print 'Using "%s" as wpa-supplicant driver' % (self.wlanmodule) + return self.wlanmodule def calc_netmask(self,nmask): from struct import pack, unpack diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py index a8b34acd..d7e83072 100755 --- a/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py @@ -257,7 +257,7 @@ class NetworkWizard(WizardLanguage, Rc): text1 = _("Your Dreambox is now ready to use.\n\nYour internet connection is working now.\n\n") text2 = _('Accesspoint:') + "\t" + str(status[self.selectedInterface]["acesspoint"]) + "\n" text3 = _('SSID:') + "\t" + str(status[self.selectedInterface]["essid"]) + "\n" - text4 = _('Link Quality:') + "\t" + str(status[self.selectedInterface]["quality"])+"%" + "\n" + text4 = _('Link Quality:') + "\t" + str(status[self.selectedInterface]["quality"])+ "\n" text5 = _('Signal Strength:') + "\t" + str(status[self.selectedInterface]["signal"]) + "\n" text6 = _('Bitrate:') + "\t" + str(status[self.selectedInterface]["bitrate"]) + "\n" text7 = _('Encryption:') + " " + str(status[self.selectedInterface]["encryption"]) + "\n" diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py b/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py index 1c1471ce..baefd435 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py @@ -1,7 +1,3 @@ -#from enigma import eListboxPythonMultiContent, eListbox, gFont, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_HALIGN_CENTER -#from Components.MultiContent import MultiContentEntryText -#from Components.GUIComponent import GUIComponent -#from Components.HTMLComponent import HTMLComponent from Components.config import config, ConfigYesNo, NoSave, ConfigSubsection, ConfigText, ConfigSelection, ConfigPassword from Components.Console import Console @@ -10,7 +6,8 @@ from string import maketrans, strip import sys import types from re import compile as re_compile, search as re_search -from iwlibs import getNICnames, Wireless, Iwfreq +from pythonwifi.iwlibs import getNICnames, Wireless, Iwfreq, getWNICnames +from pythonwifi import flags as wififlags list = [] list.append("WEP") @@ -65,38 +62,42 @@ class Wlan: print "self.iface im iwconfigFinished",self.iface callback = extra_args data = { 'essid': False, 'frequency': False, 'acesspoint': False, 'bitrate': False, 'encryption': False, 'quality': False, 'signal': False } - #print "result im iwconfigFinished",result for line in result.splitlines(): - #print "line",line line = line.strip() if "ESSID" in line: if "off/any" in line: ssid = _("No Connection") else: - tmpssid=(line[line.index('ESSID')+7:len(line)-1]) - if tmpssid == '': - ssid = _("Hidden networkname") - elif tmpssid ==' ': - ssid = _("Hidden networkname") + if "Nickname" in line: + tmpssid=(line[line.index('ESSID')+7:line.index('" Nickname')]) + if tmpssid == '': + ssid = _("Hidden networkname") + elif tmpssid ==' ': + ssid = _("Hidden networkname") + else: + ssid = tmpssid else: - ssid = tmpssid - #print "SSID->",ssid + tmpssid=(line[line.index('ESSID')+7:len(line)-1]) + if tmpssid == '': + ssid = _("Hidden networkname") + elif tmpssid ==' ': + ssid = _("Hidden networkname") + else: + ssid = tmpssid + if ssid is not None: data['essid'] = ssid if 'Frequency' in line: frequency = line[line.index('Frequency')+10 :line.index(' GHz')] - #print "Frequency",frequency if frequency is not None: data['frequency'] = frequency if "Access Point" in line: ap=line[line.index('Access Point')+14:len(line)-1] - #print "AP",ap if ap is not None: data['acesspoint'] = ap if "Bit Rate" in line: br = line[line.index('Bit Rate')+9 :line.index(' Mb/s')] - #print "Bitrate",br if br is not None: data['bitrate'] = br if 'Encryption key' in line: @@ -104,7 +105,6 @@ class Wlan: enc = _("Disabled") else: enc = line[line.index('Encryption key')+15 :line.index(' Security')] - #print "Encryption key",enc if enc is not None: data['encryption'] = _("Enabled") if 'Quality' in line: @@ -112,12 +112,10 @@ class Wlan: qual = line[line.index('Quality')+8:line.index('/100')] else: qual = line[line.index('Quality')+8:line.index('Sig')] - #print "Quality",qual if qual is not None: data['quality'] = qual if 'Signal level' in line: - signal = line[line.index('Signal level')+14 :line.index(' dBm')] - #print "Signal level",signal + signal = line[line.index('Signal level')+13 :line.index(' dBm')] if signal is not None: data['signal'] = signal @@ -130,7 +128,6 @@ class Wlan: callback(True,self.wlaniface) def getAdapterAttribute(self, attribute): - print "im getAdapterAttribute" if self.wlaniface.has_key(self.iface): print "self.wlaniface.has_key",self.iface if self.wlaniface[self.iface].has_key(attribute): @@ -142,13 +139,17 @@ class Wlan: def getWirelessInterfaces(self): - iwifaces = None - try: - iwifaces = getNICnames() - except: - print "[Wlan.py] No Wireless Networkcards could be found" - - return iwifaces + device = re_compile('[a-z]{2,}[0-9]*:') + ifnames = [] + + fp = open('/proc/net/wireless', 'r') + for line in fp: + try: + # append matching pattern, without the trailing colon + ifnames.append(device.search(line).group()[:-1]) + except AttributeError: + pass + return ifnames def getNetworkList(self): @@ -156,8 +157,8 @@ class Wlan: ifobj = Wireless(self.iface) # a Wireless NIC Object #Association mappings - stats, quality, discard, missed_beacon = ifobj.getStatistics() - snr = quality.signallevel - quality.noiselevel + #stats, quality, discard, missed_beacon = ifobj.getStatistics() + #snr = quality.signallevel - quality.noiselevel try: scanresults = ifobj.scan() @@ -167,55 +168,47 @@ class Wlan: if scanresults is not None: aps = {} + (num_channels, frequencies) = ifobj.getChannelInfo() + index = 1 for result in scanresults: - bssid = result.bssid - - encryption = map(lambda x: hex(ord(x)), result.encode) - - if encryption[-1] == "0x8": + + if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0: + encryption = False + elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0: encryption = True else: - encryption = False - + encryption = None + + signal = str(result.quality.siglevel-0x100) + " dBm" + quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality) + extra = [] for element in result.custom: element = element.encode() extra.append( strip(self.asciify(element)) ) - - if result.quality.sl is 0 and len(extra) > 0: - begin = extra[0].find('SignalStrength=')+15 - - done = False - end = begin+1 - - while not done: - if extra[0][begin:end].isdigit(): - end += 1 - else: - done = True - end -= 1 - - signal = extra[0][begin:end] - #print "[Wlan.py] signal is:" + str(signal) + for element in extra: + print element + if 'SignalStrength' in element: + signal = element[element.index('SignalStrength')+15:element.index(',L')] + if 'LinkQuality' in element: + quality = element[element.index('LinkQuality')+12:len(element)] - else: - signal = str(result.quality.sl) - aps[bssid] = { 'active' : True, 'bssid': result.bssid, - 'channel': result.frequency.getChannel(result.frequency.getFrequency()), + 'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1, 'encrypted': encryption, 'essid': strip(self.asciify(result.essid)), 'iface': self.iface, - 'maxrate' : result.rate[-1], - 'noise' : result.quality.getNoiselevel(), - 'quality' : str(result.quality.quality), - 'signal' : signal, + 'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]), + 'noise' : '',#result.quality.nlevel-0x100, + 'quality' : str(quality), + 'signal' : str(signal), 'custom' : extra, } - print aps[bssid] + #print "GOT APS ENTRY:",aps[bssid] + index = index + 1 return aps @@ -226,12 +219,11 @@ class Wlan: self.channel = str(fq.getChannel(str(ifobj.getFrequency()[0:-3]))) except: self.channel = 0 - #print ifobj.getStatistics() status = { - 'BSSID': str(ifobj.getAPaddr()), + 'BSSID': str(ifobj.getAPaddr()), #ifobj.getStatistics() 'ESSID': str(ifobj.getEssid()), - 'quality': str(ifobj.getStatistics()[1].quality), - 'signal': str(ifobj.getStatistics()[1].sl), + 'quality': "%s/%s" % (ifobj.getStatistics()[1].quality,ifobj.getQualityMax().quality), + 'signal': str(ifobj.getStatistics()[1].siglevel-0x100) + " dBm", 'bitrate': str(ifobj.getBitrate()), 'channel': str(self.channel), #'channel': str(fq.getChannel(str(ifobj.getFrequency()[0:-3]))), @@ -326,7 +318,6 @@ class wpaSupplicant: essid = split[1][1:-1] elif split[0] == 'proto': - print "split[1]",split[1] config.plugins.wlan.encryption.enabled.value = True if split[1] == "WPA" : mode = 'WPA' @@ -354,12 +345,9 @@ class wpaSupplicant: else: config.plugins.wlan.encryption.wepkeytype.value = 'HEX' config.plugins.wlan.encryption.psk.value = split[1] - print "[Wlan.py] Got Encryption: WEP - keytype is: "+config.plugins.wlan.encryption.wepkeytype.value - print "[Wlan.py] Got Encryption: WEP - key0 is: "+config.plugins.wlan.encryption.psk.value elif split[0] == 'psk': config.plugins.wlan.encryption.psk.value = split[1][1:-1] - print "[Wlan.py] Got PSK: "+split[1][1:-1] else: pass @@ -436,24 +424,30 @@ class Status: if "off/any" in line: ssid = _("No Connection") else: - tmpssid=(line[line.index('ESSID')+7:len(line)-1]) - if tmpssid == '': - ssid = _("Hidden networkname") - elif tmpssid ==' ': - ssid = _("Hidden networkname") + if "Nickname" in line: + tmpssid=(line[line.index('ESSID')+7:line.index('" Nickname')]) + if tmpssid == '': + ssid = _("Hidden networkname") + elif tmpssid ==' ': + ssid = _("Hidden networkname") + else: + ssid = tmpssid else: - ssid = tmpssid - #print "SSID->",ssid + tmpssid=(line[line.index('ESSID')+7:len(line)-1]) + if tmpssid == '': + ssid = _("Hidden networkname") + elif tmpssid ==' ': + ssid = _("Hidden networkname") + else: + ssid = tmpssid if ssid is not None: data['essid'] = ssid if 'Frequency' in line: frequency = line[line.index('Frequency')+10 :line.index(' GHz')] - #print "Frequency",frequency if frequency is not None: data['frequency'] = frequency if "Access Point" in line: ap=line[line.index('Access Point')+14:len(line)] - #print "AP",ap if ap is not None: data['acesspoint'] = ap if ap == "Not-Associated": @@ -467,7 +461,6 @@ class Status: br += " Mb/s" else: br = line[line.index('Bit Rate')+9 :line.index(' Mb/s')] + " Mb/s" - #print "Bitrate",br if br is not None: data['bitrate'] = br if 'Encryption key' in line: @@ -480,28 +473,30 @@ class Status: enc = line[line.index('Encryption key')+15 :line.index(' Security')] if enc is not None: enc = _("Enabled") - #print "Encryption key",enc if enc is not None: data['encryption'] = enc if 'Quality' in line: if "/100" in line: - qual = line[line.index('Quality')+8:line.index('/100')] + #qual = line[line.index('Quality')+8:line.index('/100')] + qual = line[line.index('Quality')+8:line.index(' Signal')] else: qual = line[line.index('Quality')+8:line.index('Sig')] - #print "Quality",qual if qual is not None: data['quality'] = qual if 'Signal level' in line: if "dBm" in line: - signal = line[line.index('Signal level')+14 :line.index(' dBm')] + signal = line[line.index('Signal level')+13 :line.index(' dBm')] signal += " dBm" elif "/100" in line: - signal = line[line.index('Signal level')+13:line.index('/100 Noise')] - signal += "%" + if "Noise" in line: + signal = line[line.index('Signal level')+13:line.index(' Noise')] + else: + signal = line[line.index('Signal level')+13:len(line)] else: - signal = line[line.index('Signal level')+13:line.index(' Noise')] - signal += "%" - #print "Signal level",signal + if "Noise" in line: + signal = line[line.index('Signal level')+13:line.index(' Noise')] + else: + signal = line[line.index('Signal level')+13:len(line)] if signal is not None: data['signal'] = signal @@ -515,12 +510,10 @@ class Status: callback(True,self.wlaniface) def getAdapterAttribute(self, iface, attribute): - print "im getAdapterAttribute" self.iface = iface if self.wlaniface.has_key(self.iface): - print "self.wlaniface.has_key",self.iface if self.wlaniface[self.iface].has_key(attribute): return self.wlaniface[self.iface][attribute] return None -iStatus = Status() \ No newline at end of file +iStatus = Status() diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py index 2df5814c..28ee363e 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/plugin.py @@ -1,4 +1,4 @@ -from enigma import eTimer +from enigma import eTimer, eTPM from Screens.Screen import Screen from Components.ActionMap import ActionMap, NumberActionMap from Components.Pixmap import Pixmap,MultiPixmap @@ -14,7 +14,9 @@ from Plugins.Plugin import PluginDescriptor from os import system, path as os_path, listdir from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE from Tools.LoadPixmap import LoadPixmap +from Tools.HardwareInfo import HardwareInfo from Wlan import Wlan, wpaSupplicant, iStatus +import sha plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan" @@ -122,7 +124,7 @@ class WlanStatus(Screen): if status is not None: self["BSSID"].setText(status[self.iface]["acesspoint"]) self["ESSID"].setText(status[self.iface]["essid"]) - self["quality"].setText(status[self.iface]["quality"]+"%") + self["quality"].setText(status[self.iface]["quality"]) self["signal"].setText(status[self.iface]["signal"]) self["bitrate"].setText(status[self.iface]["bitrate"]) self["enc"].setText(status[self.iface]["encryption"]) @@ -373,6 +375,45 @@ class WlanScan(Screen): return self.WlanList +def bin2long(s): + return reduce( lambda x,y:(x<<8L)+y, map(ord, s)) + +def long2bin(l): + res = "" + for byte in range(128): + res += chr((l >> (1024 - (byte + 1) * 8)) & 0xff) + return res + +def rsa_pub1024(src, mod): + return long2bin(pow(bin2long(src), 65537, bin2long(mod))) + +def decrypt_block(src, mod): + if len(src) != 128 and len(src) != 202: + return None + dest = rsa_pub1024(src[:128], mod) + hash = sha.new(dest[1:107]) + if len(src) == 202: + hash.update(src[131:192]) + result = hash.digest() + if result == dest[107:127]: + return dest + return None + +def validate_cert(cert, key): + buf = decrypt_block(cert[8:], key) + if buf is None: + return None + return buf[36:107] + cert[139:196] + +def read_random(): + try: + fd = open("/dev/urandom", "r") + buf = fd.read(8) + fd.close() + return buf + except: + return None + def WlanStatusScreenMain(session, iface): session.open(WlanStatus, iface) @@ -387,8 +428,32 @@ def callFunction(iface): def configStrings(iface): - driver = iNetwork.detectWlanModule() - print "Found WLAN-Driver:",driver + hardware_info = HardwareInfo() + if 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 + l2key = validate_cert(l2cert, rootkey) + if l2key is None: + return + l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT) + if l3cert is None: + print "better run the genuine dreambox plugin" + 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 hardware_info.device_name == "dm7025" or result[80:88] == rnd: + driver = iNetwork.detectWlanModule(iface) + else: + driver = 'dreambox' if driver in ('ralink', 'zydas'): return " pre-up /usr/sbin/wpa_supplicant -i"+iface+" -c/etc/wpa_supplicant.conf -B -D"+driver+"\n post-down wpa_cli terminate" else: diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py index 2e33ac3b..de2fa993 100755 --- a/lib/python/Screens/NetworkSetup.py +++ b/lib/python/Screens/NetworkSetup.py @@ -745,14 +745,21 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): if self.iface in iNetwork.wlan_interfaces: try: from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan - from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless + from pythonwifi.iwlibs import Wireless except ImportError: self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 ) else: ifobj = Wireless(self.iface) # a Wireless NIC Object - self.wlanresponse = ifobj.getStatistics() - if self.wlanresponse[0] != 19: # Wlan Interface found. - self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface) + try: + self.wlanresponse = ifobj.getAPaddr() + except IOError: + self.wlanresponse = ifobj.getStatistics() + if self.wlanresponse: + if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported' + self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup,self.iface) + else: + # Display Wlan not available Message + self.showErrorMessage() else: # Display Wlan not available Message self.showErrorMessage() @@ -765,28 +772,42 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): if self["menulist"].getCurrent()[1] == 'scanwlan': try: from Plugins.SystemPlugins.WirelessLan.plugin import WlanScan - from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless + from pythonwifi.iwlibs import Wireless except ImportError: self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 ) else: ifobj = Wireless(self.iface) # a Wireless NIC Object - self.wlanresponse = ifobj.getStatistics() - if self.wlanresponse[0] != 19: - self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface) + try: + self.wlanresponse = ifobj.getAPaddr() + except IOError: + self.wlanresponse = ifobj.getStatistics() + if self.wlanresponse: + if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported' + self.session.openWithCallback(self.WlanScanClosed, WlanScan, self.iface) + else: + # Display Wlan not available Message + self.showErrorMessage() else: # Display Wlan not available Message self.showErrorMessage() if self["menulist"].getCurrent()[1] == 'wlanstatus': try: from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus - from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless + from pythonwifi.iwlibs import Wireless except ImportError: self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 ) else: ifobj = Wireless(self.iface) # a Wireless NIC Object - self.wlanresponse = ifobj.getStatistics() - if self.wlanresponse[0] != 19: - self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface) + try: + self.wlanresponse = ifobj.getAPaddr() + except IOError: + self.wlanresponse = ifobj.getStatistics() + if self.wlanresponse: + if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported' + self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface) + else: + # Display Wlan not available Message + self.showErrorMessage() else: # Display Wlan not available Message self.showErrorMessage() @@ -898,14 +919,21 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): if ret[0] == 'ok' and (self.iface in iNetwork.wlan_interfaces) and iNetwork.getAdapterAttribute(self.iface, "up") is True: try: from Plugins.SystemPlugins.WirelessLan.plugin import WlanStatus - from Plugins.SystemPlugins.WirelessLan.iwlibs import Wireless + from pythonwifi.iwlibs import Wireless except ImportError: self.session.open(MessageBox, _("The wireless LAN plugin is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 ) else: ifobj = Wireless(self.iface) # a Wireless NIC Object - self.wlanresponse = ifobj.getStatistics() - if self.wlanresponse[0] != 19: - self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface) + try: + self.wlanresponse = ifobj.getAPaddr() + except IOError: + self.wlanresponse = ifobj.getStatistics() + if self.wlanresponse: + if self.wlanresponse[0] not in (19,95): # 19 = 'No such device', 95 = 'Operation not supported' + self.session.openWithCallback(self.WlanStatusClosed, WlanStatus,self.iface) + else: + # Display Wlan not available Message + self.showErrorMessage() else: # Display Wlan not available Message self.showErrorMessage() @@ -916,7 +944,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): def WlanStatusClosed(self, *ret): if ret is not None and len(ret): - from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status + from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus iStatus.stopWlanConsole() self.updateStatusbar() @@ -924,7 +952,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): if ret[0] is not None: self.session.openWithCallback(self.AdapterSetupClosed, AdapterSetup, self.iface,ret[0],ret[1]) else: - from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status + from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus iStatus.stopWlanConsole() self.updateStatusbar() @@ -1335,7 +1363,7 @@ class NetworkAdapterTest(Screen): def getLinkState(self,iface): if iface in iNetwork.wlan_interfaces: try: - from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status + from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus except: self["Network"].setForegroundColorNum(1) self["Network"].setText(_("disconnected")) @@ -1417,7 +1445,7 @@ class NetworkAdapterTest(Screen): iNetwork.stopLinkStateConsole() iNetwork.stopDNSConsole() try: - from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status + from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus except ImportError: pass else: -- cgit v1.2.3 From 91ad4707b3a64d8d166e0c1976977ba85ea29a70 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 10 Aug 2010 13:45:17 +0200 Subject: re-commit new NFIFlash plugin (bug #480) --- .../SystemPlugins/NFIFlash/dm8000_writenand | Bin 71669 -> 0 bytes .../Plugins/SystemPlugins/NFIFlash/downloader.py | 1216 ++++++++++---------- .../Plugins/SystemPlugins/NFIFlash/flasher.py | 324 ++---- .../Plugins/SystemPlugins/NFIFlash/mywritenand | Bin 71626 -> 0 bytes .../Plugins/SystemPlugins/NFIFlash/plugin.py | 23 +- 5 files changed, 747 insertions(+), 816 deletions(-) delete mode 100755 lib/python/Plugins/SystemPlugins/NFIFlash/dm8000_writenand delete mode 100755 lib/python/Plugins/SystemPlugins/NFIFlash/mywritenand (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/dm8000_writenand b/lib/python/Plugins/SystemPlugins/NFIFlash/dm8000_writenand deleted file mode 100755 index bd02d8fe..00000000 Binary files a/lib/python/Plugins/SystemPlugins/NFIFlash/dm8000_writenand and /dev/null differ diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index 6463f179..c0094cc1 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -1,72 +1,209 @@ # -*- coding: utf-8 -*- -from Components.MenuList import MenuList +from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Screens.ChoiceBox import ChoiceBox +from Screens.HelpMenu import HelpableScreen +from Screens.TaskView import JobView +from Components.About import about from Components.ActionMap import ActionMap from Components.Sources.StaticText import StaticText -from Components.Sources.Progress import Progress +from Components.Sources.List import List from Components.Label import Label from Components.FileList import FileList +from Components.MenuList import MenuList from Components.MultiContent import MultiContentEntryText from Components.ScrollLabel import ScrollLabel +from Components.Harddisk import harddiskmanager +from Components.Task import Task, Job, job_manager, Condition from Tools.Directories import fileExists from Tools.HardwareInfo import HardwareInfo -from enigma import eConsoleAppContainer, eListbox, gFont, eListboxPythonMultiContent, \ - RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, eRect, eTimer -from os import system, remove -import re -import urllib from Tools.Downloader import downloadWithProgress +from enigma import eConsoleAppContainer, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, eTimer +from os import system, path, access, stat, remove, W_OK, R_OK from twisted.web import client from twisted.internet import reactor, defer from twisted.python import failure -from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier - -class UserRequestedCancel(Exception): - pass - -class Feedlist(MenuList): - def __init__(self, list=[], enableWrapAround = False): - MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent) - self.l.setFont(0, gFont("Regular", 16)) - self.l.setItemHeight(22) - - def clear(self): - del self.list[:] - self.l.setList(self.list) - - def getNFIname(self): - l = self.l.getCurrentSelection() - return l and l[0][0] - - def getNFIurl(self): - l = self.l.getCurrentSelection() - return l and l[0][1] - - def getNFOname(self): - l = self.l.getCurrentSelection() - return l and l[0][0][:-3]+"nfo" - - def getNFOurl(self): - l = self.l.getCurrentSelection() - return l and l[0][1][:-3]+"nfo" +import re - def isValid(self): - l = self.l.getCurrentSelection() - if not l or l[0] == 0: - return False +class ImageDownloadJob(Job): + def __init__(self, url, filename, device=None, mountpoint="/"): + Job.__init__(self, _("Download .NFI-Files for USB-Flasher")) + if device: + MountTask(self, device, mountpoint) + ImageDownloadTask(self, url, mountpoint+filename) + ImageDownloadTask(self, url[:-4]+".nfo", mountpoint+filename[:-4]+".nfo") + if device: + UmountTask(self, mountpoint) + + def retry(self): + self.tasks[0].args += self.tasks[0].retryargs + Job.retry(self) + +class MountTask(Task): + def __init__(self, job, device, mountpoint): + Task.__init__(self, job, ("mount")) + self.setTool("mount") + self.args += [device, mountpoint, "-orw,sync"] + self.weighting = 1 + + def processOutput(self, data): + print "[MountTask] output:", data + +class UmountTask(Task): + def __init__(self, job, mountpoint): + Task.__init__(self, job, ("mount")) + self.setTool("umount") + self.args += [mountpoint] + self.weighting = 1 + +class DownloaderPostcondition(Condition): + def check(self, task): + return task.returncode == 0 + + def getErrorMessage(self, task): + return self.error_message + +class ImageDownloadTask(Task): + def __init__(self, job, url, path): + Task.__init__(self, job, _("Downloading")) + self.postconditions.append(DownloaderPostcondition()) + self.job = job + self.url = url + self.path = path + self.error_message = "" + self.last_recvbytes = 0 + self.error_message = None + + def run(self, callback): + self.callback = callback + self.download = downloadWithProgress(self.url,self.path) + self.download.addProgress(self.download_progress) + self.download.start().addCallback(self.download_finished).addErrback(self.download_failed) + print "[ImageDownloadTask] downloading", self.url, "to", self.path + + def download_progress(self, recvbytes, totalbytes): + #print "[update_progress] recvbytes=%d, totalbytes=%d" % (recvbytes, totalbytes) + if ( recvbytes - self.last_recvbytes ) > 10000: # anti-flicker + self.progress = int(100*(float(recvbytes)/float(totalbytes))) + self.name = _("Downloading") + ' ' + "%d of %d kBytes" % (recvbytes/1024, totalbytes/1024) + self.last_recvbytes = recvbytes + + def download_failed(self, failure_instance=None, error_message=""): + self.error_message = error_message + if error_message == "" and failure_instance is not None: + self.error_message = failure_instance.getErrorMessage() + print "[download_failed]", self.error_message + Task.processFinished(self, 1) + + def download_finished(self, string=""): + print "[download_finished]", string + Task.processFinished(self, 0) + +class StickWizardJob(Job): + def __init__(self, path): + Job.__init__(self, _("USB stick wizard")) + self.path = path + self.device = path + while self.device[-1:] == "/" or self.device[-1:].isdigit(): + self.device = self.device[:-1] + + box = HardwareInfo().get_device_name() + url = "http://www.dreamboxupdate.com/download/opendreambox/dreambox-nfiflasher-%s.tar.bz2" % box + self.downloadfilename = "/tmp/dreambox-nfiflasher-%s.tar.bz2" % box + self.imagefilename = "/tmp/nfiflash_%s.img" % box + #UmountTask(self, device) + PartitionTask(self) + ImageDownloadTask(self, url, self.downloadfilename) + UnpackTask(self) + CopyTask(self) + +class PartitionTaskPostcondition(Condition): + def check(self, task): + return task.returncode == 0 + + def getErrorMessage(self, task): + return { + task.ERROR_BLKRRPART: ("Device or resource busy"), + task.ERROR_UNKNOWN: (task.errormsg) + }[task.error] + +class PartitionTask(Task): + ERROR_UNKNOWN, ERROR_BLKRRPART = range(2) + def __init__(self, job): + Task.__init__(self, job, ("partitioning")) + self.postconditions.append(PartitionTaskPostcondition()) + self.job = job + self.setTool("sfdisk") + self.args += [self.job.device] + self.weighting = 10 + self.initial_input = "0 - 0x6 *\n;\n;\n;\ny" + self.errormsg = "" + + def run(self, callback): + Task.run(self, callback) + + def processOutput(self, data): + print "[PartitionTask] output:", data + if data.startswith("BLKRRPART:"): + self.error = self.ERROR_BLKRRPART else: - return True + self.error = self.ERROR_UNKNOWN + self.errormsg = data + +class UnpackTask(Task): + def __init__(self, job): + Task.__init__(self, job, ("Unpacking USB flasher image...")) + self.job = job + self.setTool("tar") + self.args += ["-xjvf", self.job.downloadfilename] + self.weighting = 80 + self.end = 80 + self.delayTimer = eTimer() + self.delayTimer.callback.append(self.progress_increment) + + def run(self, callback): + Task.run(self, callback) + self.delayTimer.start(1000, False) + + def progress_increment(self): + self.progress += 1 + + def processOutput(self, data): + print "[UnpackTask] output: \'%s\'" % data + self.job.imagefilename = data + + def afterRun(self): + self.delayTimer.callback.remove(self.progress_increment) + +class CopyTask(Task): + def __init__(self, job): + Task.__init__(self, job, ("Copying USB flasher boot image to stick...")) + self.job = job + self.setTool("dd") + self.args += ["if=%s" % self.job.imagefilename, "of=%s1" % self.job.device] + self.weighting = 20 + self.end = 20 + self.delayTimer = eTimer() + self.delayTimer.callback.append(self.progress_increment) + + def run(self, callback): + Task.run(self, callback) + self.delayTimer.start(100, False) + + def progress_increment(self): + self.progress += 1 + + def processOutput(self, data): + print "[CopyTask] output:", data - def moveSelection(self,idx=0): - if self.instance is not None: - self.instance.moveSelectionTo(idx) + def afterRun(self): + self.delayTimer.callback.remove(self.progress_increment) class NFOViewer(Screen): skin = """ - - + + """ def __init__(self, session, nfo): @@ -80,206 +217,37 @@ class NFOViewer(Screen): "ok": self.exit, "cancel": self.exit, "down": self.pageDown, - "up": self.pageUp + "up": self.pageUp }) def pageUp(self): self["changelog"].pageUp() def pageDown(self): self["changelog"].pageDown() - + def exit(self): self.close(False) -class NFIDownload(Screen): - LIST_SOURCE = 1 - LIST_DEST = 2 - skin = """ - - - - - - - - - - - - - - - - - - - - - - """ - - def __init__(self, session, destdir="/tmp/"): - self.skin = NFIDownload.skin - Screen.__init__(self, session) - - self["job_progressbar"] = Progress() - self["job_progresslabel"] = StaticText() - - self["infolabel"] = StaticText() - self["statusbar"] = StaticText() - self["label_top"] = StaticText() - self["label_bottom"] = StaticText() - self["path_bottom"] = StaticText() - - self["key_green"] = StaticText() - self["key_yellow"] = StaticText() - self["key_blue"] = StaticText() - - self["key_red"] = StaticText() - - self["feedlist"] = Feedlist([0,(eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, "feed not available")]) - self["destlist"] = FileList(destdir, showDirectories = True, showFiles = False) - self["destlist"].hide() - - self.download_container = eConsoleAppContainer() - self.nfo = "" - self.nfofile = "" - self.feedhtml = "" - self.focus = None - self.download = None - self.box = HardwareInfo().get_device_name() - self.feed_base = "http://www.dreamboxupdate.com/opendreambox/1.5/%s/images/" % self.box - self.nfi_filter = "" # "release" # only show NFIs containing this string, or all if "" - self.wizard_mode = False - - self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "EPGSelectActions"], - { - "cancel": self.closeCB, - "red": self.closeCB, - "green": self.nfi_download, - "yellow": self.switchList, - "blue": self.askCreateUSBstick, - "prevBouquet": self.switchList, - "nextBouquet": self.switchList, - "ok": self.ok, - "left": self.left, - "right": self.right, - "up": self.up, - "upRepeated": self.up, - "downRepeated": self.down, - "down": self.down - }, -1) - - self.feed_download() - - def downloading(self, state=True): - if state is True: - self["key_red"].text = _("Cancel") - self["key_green"].text = "" - self["key_yellow"].text = "" - self["key_blue"].text = "" - else: - self.download = None - self["key_red"].text = _("Exit") - if self["feedlist"].isValid(): - self["key_green"].text = (_("Download")) - if self.focus is self.LIST_SOURCE: - self["key_yellow"].text = (_("Change dir.")) - else: - self["key_yellow"].text = (_("Select image")) - self["key_blue"].text = (_("USB stick wizard")) - - def switchList(self,to_where=None): - if self.download or not self["feedlist"].isValid(): - return - - self["job_progressbar"].value = 0 - self["job_progresslabel"].text = "" - - if to_where is None: - if self.focus is self.LIST_SOURCE: - to_where = self.LIST_DEST - if self.focus is self.LIST_DEST: - to_where = self.LIST_SOURCE - - if to_where is self.LIST_DEST: - self.focus = self.LIST_DEST - self["statusbar"].text = _("Please select target directory or medium") - self["label_top"].text = _("choose destination directory")+":" - self["feedlist"].hide() - self["destlist"].show() - self["label_bottom"].text = _("Selected source image")+":" - self["path_bottom"].text = str(self["feedlist"].getNFIname()) - self["key_yellow"].text = (_("Select image")) - - elif to_where is self.LIST_SOURCE: - self.focus = self.LIST_SOURCE - self["statusbar"].text = _("Please choose .NFI image file from feed server to download") - self["label_top"].text = _("select image from server")+":" - self["feedlist"].show() - self["destlist"].hide() - self["label_bottom"].text = _("Destination directory")+":" - self["path_bottom"].text = str(self["destlist"].getCurrentDirectory()) - self["key_yellow"].text = (_("Change dir.")) - - def up(self): - if self.download: - return - if self.focus is self.LIST_SOURCE: - self["feedlist"].up() - self.nfo_download() - if self.focus is self.LIST_DEST: - self["destlist"].up() - - def down(self): - if self.download: - return - if self.focus is self.LIST_SOURCE: - self["feedlist"].down() - self.nfo_download() - if self.focus is self.LIST_DEST: - self["destlist"].down() - - def left(self): - if self.download: - return - if self.focus is self.LIST_SOURCE: - self["feedlist"].pageUp() - self.nfo_download() - if self.focus is self.LIST_DEST: - self["destlist"].pageUp() - - def right(self): - if self.download: - return - if self.focus is self.LIST_SOURCE: - self["feedlist"].pageDown() - self.nfo_download() - if self.focus is self.LIST_DEST: - self["destlist"].pageDown() - - def ok(self): - if self.focus is self.LIST_SOURCE and self.nfo: - self.session.open(NFOViewer, self.nfo) - if self.download: - return - if self.focus is self.LIST_DEST: - if self["destlist"].canDescent(): - self["destlist"].descent() - - def feed_download(self): - self.downloading(True) - self.download = self.feed_download - client.getPage(self.feed_base).addCallback(self.feed_finished).addErrback(self.feed_failed) +class feedDownloader: + def __init__(self, feed_base, box, OE_vers): + print "[feedDownloader::init] feed_base=%s, box=%s" % (feed_base, box) + self.feed_base = feed_base + self.OE_vers = OE_vers + self.box = box + + def getList(self, callback, errback): + self.urlbase = "%s/%s/%s/images/" % (self.feed_base, self.OE_vers, self.box) + print "[getList]", self.urlbase + self.callback = callback + self.errback = errback + client.getPage(self.urlbase).addCallback(self.feed_finished).addErrback(self.feed_failed) def feed_failed(self, failure_instance): - print "[feed_failed] " + str(failure_instance) - self["infolabel"].text = _("Could not connect to Dreambox .NFI Image Feed Server:") + "\n" + failure_instance.getErrorMessage() + "\n\n" + _("Please check your network settings!") - self.downloading(False) + print "[feed_failed]", str(failure_instance) + self.errback(failure_instance.getErrorMessage()) def feed_finished(self, feedhtml): - print "[feed_finished] " + str(feedhtml) - self.downloading(False) + print "[feed_finished]" fileresultmask = re.compile(".*?)[\'\"]>(?P.*?.nfi)", re.DOTALL) searchresults = fileresultmask.finditer(feedhtml) fileresultlist = [] @@ -287,378 +255,472 @@ class NFIDownload(Screen): for x in searchresults: url = x.group("url") if url[0:7] != "http://": - url = self.feed_base + x.group("url") + url = self.urlbase + x.group("url") name = x.group("name") - if name.find(self.nfi_filter) > -1: - entry = [[name, url],(eListboxPythonMultiContent.TYPE_TEXT, 0, 0,250, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, name)] - print "adding to feedlist: " + str(entry) - fileresultlist.append(entry) - else: - print "NOT adding to feedlist: " + name - self["feedlist"].l.setList(fileresultlist) - self["feedlist"].moveSelection(0) + entry = (name, url) + fileresultlist.append(entry) + self.callback(fileresultlist, self.OE_vers) - if len(fileresultlist) > 0: - self.switchList(self.LIST_SOURCE) - self.nfo_download() - else: - self["infolabel"].text = _("Cannot parse feed directory") - - def nfo_download(self): - print "[check_for_NFO]" - if self["feedlist"].isValid(): - print "nfiname: " + self["feedlist"].getNFIname() - self["job_progressbar"].value = 0 - self["job_progresslabel"].text = "" - if self["feedlist"].getNFIurl() is None: - self["key_green"].text = "" - return - self["key_green"].text = _("Download") - nfourl = self["feedlist"].getNFOurl() - print "downloading " + nfourl - self.download = self.nfo_download - self.downloading(True) - client.getPage(nfourl).addCallback(self.nfo_finished).addErrback(self.nfo_failed) - self["statusbar"].text = ("Downloading image description...") +class DeviceBrowser(Screen, HelpableScreen): + skin = """ + + + + + + + + """ - def nfo_failed(self, failure_instance): - print "[nfo_failed] " + str(failure_instance) - self["infolabel"].text = _("No details for this image file") + "\n" + self["feedlist"].getNFIname() - self["statusbar"].text = "" - self.nfofilename = "" - self.nfo = "" - self.downloading(False) + def __init__(self, session, startdir, message="", showDirectories = True, showFiles = True, showMountpoints = True, matchingPattern = "", useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, additionalExtensions = None): + Screen.__init__(self, session) - def nfo_finished(self,nfodata=""): - print "[nfo_finished] " + str(nfodata) - self.downloading(False) - self.nfo = nfodata - if self.nfo != "": - self.nfofilename = self["destlist"].getCurrentDirectory() + '/' + self["feedlist"].getNFOname() - self["infolabel"].text = self.nfo - else: - self.nfofilename = "" - self["infolabel"].text = _("No details for this image file") - self["statusbar"].text = _("Press OK to view full changelog") - - def nfi_download(self): - if self["destlist"].getCurrentDirectory() is None: - self.switchList(self.LIST_TARGET) - if self["feedlist"].isValid(): - url = self["feedlist"].getNFIurl() - self.nfilocal = self["destlist"].getCurrentDirectory()+'/'+self["feedlist"].getNFIname() - print "[nfi_download] downloading %s to %s" % (url, self.nfilocal) - self.download = downloadWithProgress(url,self.nfilocal) - self.download.addProgress(self.nfi_progress) - self["job_progressbar"].range = 1000 - self.download.start().addCallback(self.nfi_finished).addErrback(self.nfi_failed) - self.downloading(True) - - def nfi_progress(self, recvbytes, totalbytes): - #print "[update_progress] recvbytes=%d, totalbytes=%d" % (recvbytes, totalbytes) - self["job_progressbar"].value = int(1000*recvbytes/float(totalbytes)) - self["job_progresslabel"].text = "%d of %d kBytes (%.2f%%)" % (recvbytes/1024, totalbytes/1024, 100*recvbytes/float(totalbytes)) + HelpableScreen.__init__(self) - def nfi_failed(self, failure_instance=None, error_message=""): - if error_message == "" and failure_instance is not None: - error_message = failure_instance.getErrorMessage() - print "[nfi_failed] " + error_message - if fileExists(self["destlist"].getCurrentDirectory()+'/'+self["feedlist"].getNFIname()): - message = "%s %s\n%s" % (_(".NFI Download failed:"), error_message, _("Remove the incomplete .NFI file?")) - self.session.openWithCallback(self.nfi_remove, MessageBox, message, MessageBox.TYPE_YESNO) + self["key_red"] = StaticText(_("Cancel")) + self["key_green"] = StaticText() + self["message"] = StaticText(message) + + self.filelist = FileList(startdir, showDirectories = showDirectories, showFiles = showFiles, showMountpoints = showMountpoints, matchingPattern = matchingPattern, useServiceRef = useServiceRef, inhibitDirs = inhibitDirs, inhibitMounts = inhibitMounts, isTop = isTop, enableWrapAround = enableWrapAround, additionalExtensions = additionalExtensions) + self["filelist"] = self.filelist + + self["FilelistActions"] = ActionMap(["SetupActions", "ColorActions"], + { + "green": self.use, + "red": self.exit, + "ok": self.ok, + "cancel": self.exit + }) + + hotplugNotifier.append(self.hotplugCB) + self.onShown.append(self.updateButton) + self.onClose.append(self.removeHotplug) + + def hotplugCB(self, dev, action): + print "[hotplugCB]", dev, action + self.updateButton() + + def updateButton(self): + + if self["filelist"].getFilename() or self["filelist"].getCurrentDirectory(): + self["key_green"].text = _("Use") else: - message = "%s %s" % (_(".NFI Download failed:"),error_message) - self.session.open(MessageBox, message, MessageBox.TYPE_ERROR) - self.downloading(False) + self["key_green"].text = "" + + def removeHotplug(self): + print "[removeHotplug]" + hotplugNotifier.remove(self.hotplugCB) - def nfi_finished(self, string=""): - print "[nfi_finished] " + str(string) - if self.nfo != "": - self.nfofilename = self["destlist"].getCurrentDirectory() + '/' + self["feedlist"].getNFOname() - nfofd = open(self.nfofilename, "w") - if nfofd: - nfofd.write(self.nfo) - nfofd.close() - else: - print "couldn't save nfo file " + self.nfofilename - - pos = self.nfo.find("MD5:") - if pos > 0 and len(self.nfo) >= pos+5+32: - self["statusbar"].text = ("Please wait for md5 signature verification...") - cmd = "md5sum -c -" - md5 = self.nfo[pos+5:pos+5+32] + " " + self.nfilocal - print cmd, md5 - self.download_container.setCWD(self["destlist"].getCurrentDirectory()) - self.download_container.appClosed.append(self.md5finished) - self.download_container.execute(cmd) - self.download_container.write(md5) - self.download_container.dataSent.append(self.md5ready) + def ok(self): + if self.filelist.canDescent(): + if self["filelist"].showMountpoints == True and self["filelist"].showDirectories == False: + self.use() else: - self["statusbar"].text = "Download completed." - self.downloading(False) - else: - self["statusbar"].text = "Download completed." - self.downloading(False) - if self.wizard_mode: - self.configBackup() + self.filelist.descent() - def md5ready(self, retval): - self.download_container.sendEOF() + def use(self): + print "[use]", self["filelist"].getCurrentDirectory(), self["filelist"].getFilename() + if self["filelist"].getCurrentDirectory() is not None: + if self.filelist.canDescent() and self["filelist"].getFilename() and len(self["filelist"].getFilename()) > len(self["filelist"].getCurrentDirectory()): + self.filelist.descent() + self.close(self["filelist"].getCurrentDirectory()) + elif self["filelist"].getFilename(): + self.close(self["filelist"].getFilename()) - def md5finished(self, retval): - print "[md5finished]: " + str(retval) - self.download_container.appClosed.remove(self.md5finished) - if retval==0: - self.downloading(False) - if self.wizard_mode: - self.configBackup() - else: - self["statusbar"].text = _(".NFI file passed md5sum signature check. You can safely flash this image!") - self.switchList(self.LIST_SOURCE) - else: - self.session.openWithCallback(self.nfi_remove, MessageBox, (_("The md5sum validation failed, the file may be downloaded incompletely or be corrupted!") + "\n" + _("Remove the broken .NFI file?")), MessageBox.TYPE_YESNO) - - def nfi_remove(self, answer): - self.downloading(False) - if answer == True: - nfifilename = self["destlist"].getCurrentDirectory()+'/'+self["feedlist"].getNFIname() - if fileExists(self.nfofilename): - remove(self.nfofilename) - if fileExists(nfifilename): - remove(nfifilename) - self.switchList(self.LIST_SOURCE) - - def askCreateUSBstick(self): - self.downloading() - self.imagefilename = "/tmp/nfiflash_" + self.box + ".img" - message = _("You have chosen to create a new .NFI flasher bootable USB stick. This will repartition the USB stick and therefore all data on it will be erased.") - self.session.openWithCallback(self.flasherdownload_query, MessageBox, (message + '\n' + _("First we need to download the latest boot environment for the USB flasher.")), MessageBox.TYPE_YESNO) - - def flasherdownload_query(self, answer): - if answer is False: - self.downloading(False) - self.switchList(self.LIST_SOURCE) - return - #url = self.feed_base + "/nfiflasher_" + self.box + ".tar.bz2" - url = "http://www.dreamboxupdate.com/download/opendreambox/dreambox-nfiflasher-%s.tar.bz2" % self.box - localfile = "/tmp/nfiflasher_image.tar.bz2" - print "[flasherdownload_query] downloading %s to %s" % (url, localfile) - self["statusbar"].text = ("Downloading %s..." % url) - self.download = downloadWithProgress(url,localfile) - self.download.addProgress(self.nfi_progress) - self["job_progressbar"].range = 1000 - self.download.start().addCallback(self.flasherdownload_finished).addErrback(self.flasherdownload_failed) - - def flasherdownload_failed(self, failure_instance=None, error_message=""): - if error_message == "" and failure_instance is not None: - error_message = failure_instance.getErrorMessage() - print "[flasherdownload_failed] " + error_message - message = "%s %s" % (_("Download of USB flasher boot image failed: "),error_message) - self.session.open(MessageBox, message, MessageBox.TYPE_ERROR) - self.remove_img(True) - - def flasherdownload_finished(self, string=""): - print "[flasherdownload_finished] " + str(string) + def exit(self): + self.close(False) + +(ALLIMAGES, RELEASE, EXPERIMENTAL, STICK_WIZARD, START) = range(5) + +class NFIDownload(Screen): + skin = """ + + + + + + + + + + + + + {"templates": + {"default": (25, [ + MultiContentEntryText(pos = (2, 2), size = (330, 24), flags = RT_HALIGN_LEFT, text = 1), # index 0 is the MenuText, + ], True, "showOnDemand") + }, + "fonts": [gFont("Regular", 22)], + "itemHeight": 25 + } + + + + + {"templates": + {"default": (300, [ + MultiContentEntryText(pos = (2, 2), size = (240, 300), flags = RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, text = 2), # index 2 is the Description, + ], False, "showNever") + }, + "fonts": [gFont("Regular", 22)], + "itemHeight": 300 + } + + + + """ + + def __init__(self, session, destdir=None): + Screen.__init__(self, session) + #self.skin_path = plugin_path + #self.menu = args + + self.box = HardwareInfo().get_device_name() + self.feed_base = "http://www.dreamboxupdate.com/opendreambox" #/1.5/%s/images/" % self.box + self.usbmountpoint = "/mnt/usb/" + + self.menulist = [] + + self["menu"] = List(self.menulist) + self["key_red"] = StaticText(_("Close")) + self["key_green"] = StaticText() + self["key_yellow"] = StaticText() + self["key_blue"] = StaticText() + + self["status"] = StaticText(_("Please wait... Loading list...")) + + self["shortcuts"] = ActionMap(["OkCancelActions", "ColorActions", "ShortcutActions", "DirectionActions"], + { + "ok": self.keyOk, + "green": self.keyOk, + "red": self.keyRed, + "blue": self.keyBlue, + "up": self.keyUp, + "upRepeated": self.keyUp, + "downRepeated": self.keyDown, + "down": self.keyDown, + "cancel": self.close, + }, -1) + self.onShown.append(self.go) + self.feedlists = [[],[],[]] + self.branch = START self.container = eConsoleAppContainer() - self.container.appClosed.append(self.umount_finished) self.container.dataAvail.append(self.tool_avail) self.taskstring = "" - umountdevs = "" - from os import listdir - for device in listdir("/dev"): - if device[:2] == "sd" and device[-1:].isdigit(): - umountdevs += "/dev/"+device - self.cmd = "umount " + umountdevs - print "executing " + self.cmd - self.container.execute(self.cmd) + self.image_idx = 0 + self.nfofilename = "" + self.nfo = "" + self.target_dir = None def tool_avail(self, string): print "[tool_avail]" + string self.taskstring += string - def umount_finished(self, retval): - self.container.appClosed.remove(self.umount_finished) - self.container.appClosed.append(self.dmesg_cleared) - self.taskstring = "" - self.cmd = "dmesg -c" - print "executing " + self.cmd - self.container.execute(self.cmd) + def go(self): + self.onShown.remove(self.go) + self["menu"].index = 0 + url = "http://www.dreamboxupdate.com/download/opendreambox/dreambox-nfiflasher-%s-md5sums" % self.box + client.getPage(url).addCallback(self.md5sums_finished).addErrback(self.feed_failed) - def dmesg_cleared(self, answer): - self.container.appClosed.remove(self.dmesg_cleared) - self.msgbox = self.session.open(MessageBox, _("Please disconnect all USB devices from your Dreambox and (re-)attach the target USB stick (minimum size is 64 MB) now!"), MessageBox.TYPE_INFO) - hotplugNotifier.append(self.hotplugCB) + def md5sums_finished(self, data): + print "[md5sums_finished]", data + self.stickimage_md5 = data + self.checkUSBStick() - def hotplugCB(self, dev, action): - print "[hotplugCB]", dev, action - if dev.startswith("sd") and action == "add": - self.msgbox.close() - hotplugNotifier.remove(self.hotplugCB) - self.container.appClosed.append(self.dmesg_scanned) - self.taskstring = "" - self.cmd = "dmesg" - print "executing " + self.cmd - self.container.execute(self.cmd) - - def dmesg_scanned(self, retval): - self.container.appClosed.remove(self.dmesg_scanned) - dmesg_lines = self.taskstring.splitlines() - self.devicetext = None - self.stickdevice = None - for i, line in enumerate(dmesg_lines): - if line.find("usb-storage: waiting for device") != -1 and len(dmesg_lines) > i+3: - self.devicetext = dmesg_lines[i+1].lstrip()+"\n"+dmesg_lines[i+3] - elif line.find("/dev/scsi/host") != -1: - self.stickdevice = line.split(":",1)[0].lstrip() - - if retval != 0 or self.devicetext is None or self.stickdevice is None: - self.session.openWithCallback(self.remove_img, MessageBox, _("No useable USB stick found"), MessageBox.TYPE_ERROR) - else: - self.session.openWithCallback(self.fdisk_query, MessageBox, (_("The following device was found:\n\n%s\n\nDo you want to write the USB flasher to this stick?") % self.devicetext), MessageBox.TYPE_YESNO) - - def fdisk_query(self, answer): - if answer == True and self.stickdevice: - self["statusbar"].text = ("Partitioning USB stick...") - self["job_progressbar"].range = 1000 - self["job_progressbar"].value = 100 - self["job_progresslabel"].text = "5.00%" - self.taskstring = "" - self.container.appClosed.append(self.fdisk_finished) - self.container.execute("fdisk " + self.stickdevice + "/disc") - self.container.write("d\n4\nd\n3\nd\n2\nd\nn\np\n1\n\n\nt\n6\nw\n") - self.delayTimer = eTimer() - self.delayTimer.callback.append(self.progress_increment) - self.delayTimer.start(105, False) - else: - self.remove_img(True) - - def fdisk_finished(self, retval): - self.container.appClosed.remove(self.fdisk_finished) - self.delayTimer.stop() - if retval == 0: - if fileExists(self.imagefilename): - self.tar_finished(0) - self["job_progressbar"].value = 700 - else: - self["statusbar"].text = ("Decompressing USB stick flasher boot image...") - self.taskstring = "" - self.container.appClosed.append(self.tar_finished) - self.container.setCWD("/tmp") - self.cmd = "tar -xjvf nfiflasher_image.tar.bz2" - self.container.execute(self.cmd) - print "executing " + self.cmd - self.delayTimer = eTimer() - self.delayTimer.callback.append(self.progress_increment) - self.delayTimer.start(105, False) + def keyRed(self): + if self.branch == START: + self.close() else: - print "fdisk failed: " + str(retval) - self.session.openWithCallback(self.remove_img, MessageBox, ("fdisk " + _("failed") + ":\n" + str(self.taskstring)), MessageBox.TYPE_ERROR) + self.branch = START + self["menu"].setList(self.menulist) + #elif self.branch == ALLIMAGES or self.branch == STICK_WIZARD: - def progress_increment(self): - newval = int(self["job_progressbar"].value) + 1 - if newval < 950: - self["job_progressbar"].value = newval - self["job_progresslabel"].text = "%.2f%%" % (newval/10.0) - - def tar_finished(self, retval): - self.delayTimer.stop() - if len(self.container.appClosed) > 0: - self.container.appClosed.remove(self.tar_finished) - if retval == 0: - self.imagefilename = "/tmp/nfiflash_" + self.box + ".img" - self["statusbar"].text = ("Copying USB flasher boot image to stick...") - self.taskstring = "" - self.container.appClosed.append(self.dd_finished) - self.cmd = "dd if=%s of=%s" % (self.imagefilename,self.stickdevice+"/part1") - self.container.execute(self.cmd) - print "executing " + self.cmd - self.delayTimer = eTimer() - self.delayTimer.callback.append(self.progress_increment) - self.delayTimer.start(105, False) + def keyBlue(self): + if self.nfo != "": + self.session.open(NFOViewer, self.nfo) + + def keyOk(self): + print "[keyOk]", self["menu"].getCurrent() + current = self["menu"].getCurrent() + if current: + if self.branch == START: + currentEntry = current[0] + if currentEntry == RELEASE: + self.image_idx = 0 + self.branch = RELEASE + self.askDestination() + elif currentEntry == EXPERIMENTAL: + self.image_idx = 0 + self.branch = EXPERIMENTAL + self.askDestination() + elif currentEntry == ALLIMAGES: + self.branch = ALLIMAGES + self.listImages() + elif currentEntry == STICK_WIZARD: + self.askStartWizard() + elif self.branch == ALLIMAGES: + self.image_idx = self["menu"].getIndex() + self.askDestination() + self.updateButtons() + + def keyUp(self): + self["menu"].selectPrevious() + self.updateButtons() + + def keyDown(self): + self["menu"].selectNext() + self.updateButtons() + + def updateButtons(self): + current = self["menu"].getCurrent() + if current: + if self.branch == START: + self["key_red"].text = _("Close") + currentEntry = current[0] + if currentEntry in (RELEASE, EXPERIMENTAL): + self.nfo_download(currentEntry, 0) + self["key_green"].text = _("Download") + else: + self.nfofilename = "" + self.nfo = "" + self["key_blue"].text = "" + self["key_green"].text = _("continue") + + elif self.branch == ALLIMAGES: + self["key_red"].text = _("Back") + self["key_green"].text = _("Download") + self.nfo_download(ALLIMAGES, self["menu"].getIndex()) + + def listImages(self): + print "[listImages]" + imagelist = [] + for name, url in self.feedlists[ALLIMAGES]: + imagelist.append((url, name, _("Download %s from Server" ) % url, None)) + self["menu"].setList(imagelist) + + def getUSBPartitions(self): + allpartitions = [ (r.description, r.mountpoint) for r in harddiskmanager.getMountedPartitions(onlyhotplug = True)] + print "[getUSBPartitions]", allpartitions + usbpartition = [] + for x in allpartitions: + print x, x[1] == '/', x[0].find("USB"), access(x[1], R_OK) + if x[1] != '/' and x[0].find("USB") > -1: # and access(x[1], R_OK) is True: + usbpartition.append(x) + return usbpartition + + def askDestination(self): + usbpartition = self.getUSBPartitions() + if len(usbpartition) == 1: + self.target_dir = usbpartition[0][1] + self.ackDestinationDevice(device_description=usbpartition[0][0]) + else: + self.openDeviceBrowser() + + def openDeviceBrowser(self): + if self.branch != STICK_WIZARD: + self.session.openWithCallback(self.DeviceBrowserClosed, DeviceBrowser, None, showDirectories=True, showMountpoints=True, inhibitMounts=["/autofs/sr0/"]) + if self.branch == STICK_WIZARD: + self.session.openWithCallback(self.DeviceBrowserClosed, DeviceBrowser, None, showDirectories=False, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/"]) + + def DeviceBrowserClosed(self, path): + print "[DeviceBrowserClosed]", str(path) + self.target_dir = path + if path: + self.ackDestinationDevice() else: - self.session.openWithCallback(self.remove_img, MessageBox, (self.cmd + " " + _("failed") + ":\n" + str(self.taskstring)), MessageBox.TYPE_ERROR) - - def dd_finished(self, retval): - self.delayTimer.stop() - self.container.appClosed.remove(self.dd_finished) - self.downloading(False) - if retval == 0: - self["job_progressbar"].value = 950 - self["job_progresslabel"].text = "95.00%" - self["statusbar"].text = ("Remounting stick partition...") - self.taskstring = "" - self.container.appClosed.append(self.mount_finished) - self.cmd = "mount %s /mnt/usb -o rw,sync" % (self.stickdevice+"/part1") - self.container.execute(self.cmd) - print "executing " + self.cmd + self.keyRed() + + def ackDestinationDevice(self, device_description=None): + if device_description == None: + dev = self.target_dir else: - self.session.openWithCallback(self.remove_img, MessageBox, (self.cmd + " " + _("failed") + ":\n" + str(self.taskstring)), MessageBox.TYPE_ERROR) - - def mount_finished(self, retval): - self.container.dataAvail.remove(self.tool_avail) - self.container.appClosed.remove(self.mount_finished) - if retval == 0: - self["job_progressbar"].value = 1000 - self["job_progresslabel"].text = "100.00%" - self["statusbar"].text = (".NFI Flasher bootable USB stick successfully created.") - self.session.openWithCallback(self.flasherFinishedCB, MessageBox, _("The USB stick is now bootable. Do you want to download the latest image from the feed server and save it on the stick?"), type = MessageBox.TYPE_YESNO) - self["destlist"].changeDir("/mnt/usb") + dev = device_description + message = _("Do you want to download the image to %s ?") % (dev) + choices = [(_("Yes"), self.ackedDestination), (_("List of Storage Devices"),self.openDeviceBrowser), (_("Cancel"),self.keyRed)] + self.session.openWithCallback(self.ackDestination_query, ChoiceBox, title=message, list=choices) + + def ackDestination_query(self, choice): + print "[ackDestination_query]", choice + if isinstance(choice, tuple): + choice[1]() else: - self.session.openWithCallback(self.flasherFinishedCB, MessageBox, (self.cmd + " " + _("failed") + ":\n" + str(self.taskstring)), MessageBox.TYPE_ERROR) - self.remove_img(True) - - def remove_img(self, answer): - if fileExists("/tmp/nfiflasher_image.tar.bz2"): - remove("/tmp/nfiflasher_image.tar.bz2") - if fileExists(self.imagefilename): - remove(self.imagefilename) - self.downloading(False) - self.switchList(self.LIST_SOURCE) - - def flasherFinishedCB(self, answer): - if answer == True: - self.wizard_mode = True - self["feedlist"].moveSelection(0) - self["path_bottom"].text = str(self["destlist"].getCurrentDirectory()) - self.nfo_download() - self.nfi_download() - - def configBackup(self): - self.session.openWithCallback(self.runBackup, MessageBox, _("The wizard can backup your current settings. Do you want to do a backup now?")) - - def runBackup(self, result=None): - from Tools.Directories import createDir, isMount, pathExists - from time import localtime - from datetime import date - from Screens.Console import Console - if result: - if isMount("/mnt/usb/"): - if (pathExists("/mnt/usb/backup") == False): - createDir("/mnt/usb/backup", True) - d = localtime() - dt = date(d.tm_year, d.tm_mon, d.tm_mday) - self.backup_file = "backup/" + str(dt) + "_settings_backup.tar.gz" - self.session.open(Console, title = "Backup running", cmdlist = ["tar -czvf " + "/mnt/usb/" + self.backup_file + " /etc/enigma2/ /etc/network/interfaces /etc/wpa_supplicant.conf"], finishedCallback = self.backup_finished, closeOnSuccess = True) + self.keyRed() + + def ackedDestination(self): + print "[ackedDestination]", self.branch, self.target_dir, self.target_dir[8:] + self.container.setCWD("/mnt") + if self.target_dir[:8] == "/autofs/": + self.target_dir = "/dev/" + self.target_dir[8:-1] + + if self.branch == STICK_WIZARD: + job = StickWizardJob(self.target_dir) + job_manager.AddJob(job) + self.session.openWithCallback(self.StickWizardCB, JobView, job) + + elif self.branch != STICK_WIZARD: + url = self.feedlists[self.branch][self.image_idx][1] + filename = self.feedlists[self.branch][self.image_idx][0] + print "[getImage] start downloading %s to %s" % (url, path) + job = ImageDownloadJob(url, filename, self.target_dir, self.usbmountpoint) + job_manager.AddJob(job) + self.session.openWithCallback(self.ImageDownloadCB, JobView, job) + + def StickWizardCB(self, ret=None): + self.session.open(MessageBox, _("The USB stick was prepared to be bootable.\nNow you can download an NFI image file!"), type = MessageBox.TYPE_INFO) + print "[StickWizardCB]", ret + if len(self.feedlists[ALLIMAGES]) == 0: + self.getFeed() else: - self.backup_file = None - self.backup_finished(skipped=True) - - def backup_finished(self, skipped=False): - if not skipped: - wizardfd = open("/mnt/usb/wizard.nfo", "w") - if wizardfd: - wizardfd.write("image: "+self["feedlist"].getNFIname()+'\n') - wizardfd.write("configuration: "+self.backup_file+'\n') - wizardfd.close() + self.setMenu() + + def ImageDownloadCB(self, ret): + print "[ImageDownloadCB]", ret self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) - def closeCB(self): - try: - self.download.stop() - #self.nfi_failed(None, "Cancelled by user request") - self.downloading(False) - except AttributeError: + def getFeed(self): + self.feedDownloader15 = feedDownloader(self.feed_base, self.box, OE_vers="1.5") + self.feedDownloader16 = feedDownloader(self.feed_base, self.box, OE_vers="1.6") + self.feedlists = [[],[],[]] + self.feedDownloader15.getList(self.gotFeed, self.feed_failed) + self.feedDownloader16.getList(self.gotFeed, self.feed_failed) + + def feed_failed(self, message=""): + self["status"].text = _("Could not connect to Dreambox .NFI Image Feed Server:") + "\n" + str(message) + "\n" + _("Please check your network settings!") + + def gotFeed(self, feedlist, OE_vers): + print "[gotFeed]", OE_vers + releaselist = [] + experimentallist = [] + + for name, url in feedlist: + if name.find("release") > -1: + releaselist.append((name, url)) + if name.find("experimental") > -1: + experimentallist.append((name, url)) + self.feedlists[ALLIMAGES].append((name, url)) + + if OE_vers == "1.6": + self.feedlists[RELEASE] = releaselist + self.feedlists[RELEASE] + self.feedlists[EXPERIMENTAL] = experimentallist + self.feedlists[RELEASE] + elif OE_vers == "1.5": + self.feedlists[RELEASE] = self.feedlists[RELEASE] + releaselist + self.feedlists[EXPERIMENTAL] = self.feedlists[EXPERIMENTAL] + experimentallist + + self.setMenu() + + def checkUSBStick(self): + self.target_dir = None + allpartitions = [ (r.description, r.mountpoint) for r in harddiskmanager.getMountedPartitions(onlyhotplug = True)] + print "[checkUSBStick] found partitions:", allpartitions + usbpartition = [] + for x in allpartitions: + print x, x[1] == '/', x[0].find("USB"), access(x[1], R_OK) + if x[1] != '/' and x[0].find("USB") > -1: # and access(x[1], R_OK) is True: + usbpartition.append(x) + + print usbpartition + if len(usbpartition) == 1: + self.target_dir = usbpartition[0][1] + self.md5_passback = self.getFeed + self.md5_failback = self.askStartWizard + self.md5verify(self.stickimage_md5, self.target_dir) + elif usbpartition == []: + print "[NFIFlash] needs to create usb flasher stick first!" + self.askStartWizard() + else: + self.askStartWizard() + + def askStartWizard(self): + self.branch = STICK_WIZARD + message = _("""This plugin creates a USB stick which can be used to update the firmware of your Dreambox in case it has no network connection or only WLAN access. +First, you need to prepare a USB stick so that it is bootable. +In the next step, an NFI image file can be downloaded from the update server and saved on the USB stick. +If you already have a prepared bootable USB stick, please insert it now. Otherwise plug in a USB stick with a minimum size of 64 MB!""") + self.session.openWithCallback(self.wizardDeviceBrowserClosed, DeviceBrowser, None, message, showDirectories=True, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/"]) + + def wizardDeviceBrowserClosed(self, path): + print "[wizardDeviceBrowserClosed]", path + self.target_dir = path + if path: + self.md5_passback = self.getFeed + self.md5_failback = self.wizardQuery + self.md5verify(self.stickimage_md5, self.target_dir) + else: self.close() + + def wizardQuery(self): + print "[wizardQuery]" + description = self.target_dir + for name, dev in self.getUSBPartitions(): + if dev == self.target_dir: + description = name + message = _("You have chosen to create a new .NFI flasher bootable USB stick. This will repartition the USB stick and therefore all data on it will be erased.") + "\n" + message += _("The following device was found:\n\n%s\n\nDo you want to write the USB flasher to this stick?") % description + choices = [(_("Yes"), self.ackedDestination), (_("List of Storage Devices"),self.askStartWizard), (_("Cancel"),self.close)] + self.session.openWithCallback(self.ackDestination_query, ChoiceBox, title=message, list=choices) + + def setMenu(self): + self.menulist = [] + try: + latest_release = "Release %s (Opendreambox 1.5)" % self.feedlists[RELEASE][0][0][-9:-4] + self.menulist.append((RELEASE, _("Get latest release image"), _("Download %s from Server" ) % latest_release, None)) + except IndexError: + pass + + try: + dat = self.feedlists[EXPERIMENTAL][0][0][-12:-4] + latest_experimental = "Experimental %s-%s-%s (Opendreambox 1.6)" % (dat[:4], dat[4:6], dat[6:]) + self.menulist.append((EXPERIMENTAL, _("Get latest experimental image"), _("Download %s from Server") % latest_experimental, None)) + except IndexError: + pass + + self.menulist.append((ALLIMAGES, _("Choose image to download"), _("Select desired image from feed list" ), None)) + self.menulist.append((STICK_WIZARD, _("USB stick wizard"), _("Prepare another USB stick for image flashing" ), None)) + self["menu"].setList(self.menulist) + self["status"].text = _("Currently installed image") + ": %s" % (about.getImageVersionString())) + self.branch = START + self.updateButtons() + + def nfo_download(self, branch, idx): + nfourl = (self.feedlists[branch][idx][1])[:-4]+".nfo" + self.nfofilename = (self.feedlists[branch][idx][0])[:-4]+".nfo" + print "[check_for_NFO]", nfourl + client.getPage(nfourl).addCallback(self.nfo_finished).addErrback(self.nfo_failed) + + def nfo_failed(self, failure_instance): + print "[nfo_failed] " + str(failure_instance) + self["key_blue"].text = "" + self.nfofilename = "" + self.nfo = "" + + def nfo_finished(self,nfodata=""): + print "[nfo_finished] " + str(nfodata) + self["key_blue"].text = _("Changelog viewer") + self.nfo = nfodata + + def md5verify(self, md5, path): + cmd = "md5sum -c -s" + print "[verify_md5]", md5, path, cmd + self.container.setCWD(path) + self.container.appClosed.append(self.md5finished) + self.container.execute(cmd) + self.container.write(md5) + self.container.dataSent.append(self.md5ready) + + def md5ready(self, retval): + self.container.sendEOF() + + def md5finished(self, retval): + print "[md5finished]", str(retval) + self.container.appClosed.remove(self.md5finished) + self.container.dataSent.remove(self.md5ready) + if retval==0: + print "check passed! calling", repr(self.md5_passback) + self.md5_passback() + else: + print "check failed! calling", repr(self.md5_failback) + self.md5_failback() def main(session, **kwargs): session.open(NFIDownload,"/home/root") diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py index 7a0da851..95c7eee9 100755 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py @@ -8,25 +8,55 @@ from Components.Sources.Progress import Progress from Components.Sources.Boolean import Boolean from Components.Label import Label from Components.FileList import FileList -from Components.Task import Task, Job, JobManager +from Components.Task import Task, Job, job_manager, Condition +from Screens.TaskView import JobView from Tools.Directories import fileExists from Tools.HardwareInfo import HardwareInfo from os import system from enigma import eConsoleAppContainer -import re +from Components.About import about + +class md5Postcondition(Condition): + def check(self, task): + print "md5Postcondition::check", task.returncode + return task.returncode == 0 + + def getErrorMessage(self, task): + if task.returncode == 1: + return _("The md5sum validation failed, the file may be corrupted!") + return "md5 error" + +class md5verify(Task): + def __init__(self, job, path, md5): + Task.__init__(self, job, "md5sum") + self.postconditions.append(md5Postcondition()) + self.weighting = 5 + self.cwd = path + self.setTool("md5sum") + self.args += ["-c", "-s"] + self.initial_input = md5 + + def writeInput(self, input): + self.container.dataSent.append(self.md5ready) + print "[writeInput]", input + Task.writeInput(self, input) + + def md5ready(self, retval): + self.container.sendEOF() + + def processOutput(self, data): + print "[md5sum]", class writeNAND(Task): - def __init__(self,job,param,box): + def __init__(self, job, param, box): Task.__init__(self,job, ("Writing image file to NAND Flash")) - self.setTool("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/mywritenand") + self.setTool("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/writenfi-mipsel-2.6.18-r1") if box == "dm7025": self.end = 256 elif box[:5] == "dm800": self.end = 512 - if box == "dm8000": - self.setTool("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/dm8000_writenand") self.args += param - self.weighting = 1 + self.weighting = 95 def processOutput(self, data): print "[writeNand] " + data @@ -38,149 +68,84 @@ class writeNAND(Task): else: self.output_line = data -class NFISummary(Screen): - skin = ( - """ - - - - - """, - """ - - - - - """) - - def __init__(self, session, parent): - Screen.__init__(self, session, parent) - self["title"] = StaticText(_("Image flash utility")) - self["content"] = StaticText(_("Please select .NFI flash image file from medium")) - self["job_progressbar"] = Progress() - self["job_progresslabel"] = StaticText("") - - def setText(self, text): - self["content"].setText(text) - class NFIFlash(Screen): skin = """ - - - - - - - - - - - - - - """ - - def __init__(self, session, cancelable = True, close_on_finish = False): - self.skin = NFIFlash.skin + + + + + + + + + + + + + + """ + + def __init__(self, session, destdir=None): Screen.__init__(self, session) - self["job_progressbar"] = Progress() - self["job_progresslabel"] = StaticText("") - - self["finished"] = Boolean() + self.box = HardwareInfo().get_device_name() + self.usbmountpoint = "/mnt/usb/" - self["infolabel"] = StaticText("") - self["statusbar"] = StaticText(_("Please select .NFI flash image file from medium")) - self["listlabel"] = StaticText(_("select .NFI flash file")+":") - + self["key_red"] = StaticText() self["key_green"] = StaticText() self["key_yellow"] = StaticText() self["key_blue"] = StaticText() + self.filelist = FileList(self.usbmountpoint, matchingPattern = "^.*\.(nfi|NFI)") + self["filelist"] = self.filelist + self["infolabel"] = StaticText("") - self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"], + self["status"] = StaticText("currently installed image: %s" % (about.getImageVersionString())) + self.job = None + + self["shortcuts"] = ActionMap(["OkCancelActions", "ColorActions", "ShortcutActions", "DirectionActions"], { - "green": self.ok, + "ok": self.keyOk, + "green": self.keyOk, + "up": self.keyUp, + "upRepeated": self.keyUp, + "downRepeated": self.keyDown, + "down": self.keyDown, + "left": self.keyLeft, "yellow": self.reboot, - "blue": self.runWizard, - "ok": self.ok, - "left": self.left, - "right": self.right, - "up": self.up, - "down": self.down + "right": self.keyRight }, -1) - - currDir = "/media/usb/" - self.filelist = FileList(currDir, matchingPattern = "^.*\.(nfi|NFI)") - self["filelist"] = self.filelist - self.nfifile = "" self.md5sum = "" - self.job = None - self.box = HardwareInfo().get_device_name() - self.configuration_restorable = None - self.wizard_mode = False - from enigma import eTimer - self.delayTimer = eTimer() - self.delayTimer.callback.append(self.runWizard) - self.delayTimer.start(50,1) - - def check_for_wizard(self): - if self["filelist"].getCurrentDirectory() is not None and fileExists(self["filelist"].getCurrentDirectory()+"wizard.nfo"): - self["key_blue"].text = _("USB stick wizard") - return True - else: - self["key_blue"].text = "" - return False - def runWizard(self): - if not self.check_for_wizard(): - self.wizard_mode = False - return - wizardcontent = open(self["filelist"].getCurrentDirectory()+"/wizard.nfo", "r").readlines() - nfifile = None - for line in wizardcontent: - line = line.strip() - if line.startswith("image: "): - nfifile = self["filelist"].getCurrentDirectory()+line[7:] - if line.startswith("configuration: "): - backupfile = self["filelist"].getCurrentDirectory()+line[15:] - if fileExists(backupfile): - print "wizard configuration:", backupfile - self.configuration_restorable = backupfile - else: - self.configuration_restorable = None - if nfifile and fileExists(nfifile): - self.wizard_mode = True - print "wizard image:", nfifile - self.check_for_NFO(nfifile) - self.queryFlash() - - def closeCB(self): - if ( self.job is None or self.job.status is not self.job.IN_PROGRESS ) and not self.no_autostart: - self.close() - #else: - #if self.cancelable: - #self.cancel() - - def up(self): + def keyUp(self): self["filelist"].up() self.check_for_NFO() - def down(self): + def keyDown(self): self["filelist"].down() self.check_for_NFO() - def right(self): + def keyRight(self): self["filelist"].pageDown() self.check_for_NFO() - def left(self): + def keyLeft(self): self["filelist"].pageUp() self.check_for_NFO() + def keyOk(self): + if self.job is None or self.job.status is not self.job.IN_PROGRESS: + if self["filelist"].canDescent(): # isDir + self["filelist"].descent() + self.check_for_NFO() + elif self["filelist"].getFilename(): + self.session.openWithCallback(self.queryCB, MessageBox, _("Shall the USB stick wizard proceed and program the image file %s into flash memory?" % self.nfifile.rsplit('/',1)[-1]), MessageBox.TYPE_YESNO) + def check_for_NFO(self, nfifile=None): - self.session.summary.setText(self["filelist"].getFilename()) + print "check_for_NFO", self["filelist"].getFilename(), self["filelist"].getCurrentDirectory() + self["infolabel"].text = "" + self["key_green"].text = "" + if nfifile is None: - self.session.summary.setText(self["filelist"].getFilename()) if self["filelist"].getFilename() is None: return if self["filelist"].getCurrentDirectory() is not None: @@ -191,8 +156,10 @@ class NFIFlash(Screen): if self.nfifile.upper().endswith(".NFI"): self["key_green"].text = _("Flash") nfofilename = self.nfifile[0:-3]+"nfo" + print nfofilename, fileExists(nfofilename) if fileExists(nfofilename): nfocontent = open(nfofilename, "r").read() + print "nfocontent:", nfocontent self["infolabel"].text = nfocontent pos = nfocontent.find("MD5:") if pos > 0: @@ -202,122 +169,27 @@ class NFIFlash(Screen): else: self["infolabel"].text = _("No details for this image file") + (self["filelist"].getFilename() or "") self.md5sum = "" - else: - self["infolabel"].text = "" - self["key_green"].text = "" - - def ok(self): - if self.job is None or self.job.status is not self.job.IN_PROGRESS: - if self["filelist"].canDescent(): # isDir - self["filelist"].descent() - self.session.summary.setText(self["filelist"].getFilename()) - self.check_for_NFO() - self.check_for_wizard() - else: - self.queryFlash() - - def queryFlash(self): - fd = open(self.nfifile, 'r') - print fd - sign = fd.read(11) - print sign - if sign.find("NFI1" + self.box + "\0") == 0: - if self.md5sum != "": - self["statusbar"].text = ("Please wait for md5 signature verification...") - self.session.summary.setText(("Please wait for md5 signature verification...")) - self.container = eConsoleAppContainer() - self.container.setCWD(self["filelist"].getCurrentDirectory()) - self.container.appClosed.append(self.md5finished) - self.container.dataSent.append(self.md5ready) - self.container.execute("md5sum -cw -") - self.container.write(self.md5sum) - else: - self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file does not have a md5sum signature and is not guaranteed to work. Do you really want to burn this image to flash memory?"), MessageBox.TYPE_YESNO) - else: - self.session.open(MessageBox, (_("This .NFI file does not contain a valid %s image!") % (self.box.upper())), MessageBox.TYPE_ERROR) - - def md5ready(self, retval): - self.container.sendEOF() - - def md5finished(self, retval): - if retval==0: - if self.wizard_mode: - self.session.openWithCallback(self.queryCB, MessageBox, _("Shall the USB stick wizard proceed and program the image file %s into flash memory?" % self.nfifile.rsplit('/',1)[-1]), MessageBox.TYPE_YESNO) - else: - self.session.openWithCallback(self.queryCB, MessageBox, _("This .NFI file has a valid md5 signature. Continue programming this image to flash memory?"), MessageBox.TYPE_YESNO) - else: - self.session.openWithCallback(self.queryCB, MessageBox, _("The md5sum validation failed, the file may be corrupted! Are you sure that you want to burn this image to flash memory? You are doing this at your own risk!"), MessageBox.TYPE_YESNO) def queryCB(self, answer): if answer == True: self.createJob() - else: - self["statusbar"].text = _("Please select .NFI flash image file from medium") - self.wizard_mode = False def createJob(self): self.job = Job("Image flashing job") - param = [self.nfifile] - writeNAND(self.job,param,self.box) - #writeNAND2(self.job,param) - #writeNAND3(self.job,param) - self.job.state_changed.append(self.update_job) - self.job.end = 540 - self.cwd = self["filelist"].getCurrentDirectory() - self["job_progressbar"].range = self.job.end - self.startJob() - - def startJob(self): + cwd = self["filelist"].getCurrentDirectory() + md5verify(self.job, cwd, self.md5sum) + writeNAND(self.job, [self.nfifile], self.box) self["key_blue"].text = "" self["key_yellow"].text = "" self["key_green"].text = "" - #self["progress0"].show() - #self["progress1"].show() + job_manager.AddJob(self.job) + self.session.openWithCallback(self.flashed, JobView, self.job, cancelable = False, backgroundable = False) - self.job.start(self.jobcb) - - def update_job(self): - j = self.job - #print "[job state_changed]" - if j.status == j.IN_PROGRESS: - self.session.summary["job_progressbar"].value = j.progress - self.session.summary["job_progressbar"].range = j.end - self.session.summary["job_progresslabel"].text = "%.2f%%" % (100*j.progress/float(j.end)) - self["job_progressbar"].range = j.end - self["job_progressbar"].value = j.progress - #print "[update_job] j.progress=%f, j.getProgress()=%f, j.end=%d, text=%f" % (j.progress, j.getProgress(), j.end, (100*j.progress/float(j.end))) - self["job_progresslabel"].text = "%.2f%%" % (100*j.progress/float(j.end)) - self.session.summary.setText(j.tasks[j.current_task].name) - self["statusbar"].text = (j.tasks[j.current_task].name) - - elif j.status == j.FINISHED: - self["statusbar"].text = _("Writing NFI image file to flash completed") - self.session.summary.setText(_("NFI image flashing completed. Press Yellow to Reboot!")) - if self.wizard_mode: - self.restoreConfiguration() - self["key_yellow"].text = _("Reboot") - - elif j.status == j.FAILED: - self["statusbar"].text = j.tasks[j.current_task].name + " " + _("failed") - self.session.open(MessageBox, (_("Flashing failed") + ":\n" + j.tasks[j.current_task].name + ":\n" + j.tasks[j.current_task].output_line), MessageBox.TYPE_ERROR) - - def jobcb(self, jobref, fasel, blubber): - print "[jobcb] %s %s %s" % (jobref, fasel, blubber) - self["key_green"].text = _("Flash") + def flashed(self, bg): + print "[flashed]" + self["key_yellow"].text = _("Reboot") def reboot(self, ret=None): if self.job.status == self.job.FINISHED: - self["statusbar"].text = ("rebooting...") + self["status"].text = ("rebooting...") TryQuitMainloop(self.session,2) - - def restoreConfiguration(self): - if self.configuration_restorable: - from Screens.Console import Console - cmdlist = [ "mount /dev/mtdblock/3 /mnt/realroot -t jffs2", "tar -xzvf " + self.configuration_restorable + " -C /mnt/realroot/" ] - self.session.open(Console, title = "Restore running", cmdlist = cmdlist, finishedCallback = self.restore_finished, closeOnSuccess = True) - - def restore_finished(self): - self.session.openWithCallback(self.reboot, MessageBox, _("USB stick wizard finished. Your dreambox will now restart with your new image!"), MessageBox.TYPE_INFO) - - def createSummary(self): - return NFISummary diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/mywritenand b/lib/python/Plugins/SystemPlugins/NFIFlash/mywritenand deleted file mode 100755 index 073a204f..00000000 Binary files a/lib/python/Plugins/SystemPlugins/NFIFlash/mywritenand and /dev/null differ diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/plugin.py b/lib/python/Plugins/SystemPlugins/NFIFlash/plugin.py index 28b33305..1eba1dd4 100755 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/plugin.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/plugin.py @@ -2,6 +2,7 @@ from Plugins.Plugin import PluginDescriptor from Tools.HardwareInfo import HardwareInfo from Tools.Directories import fileExists from downloader import NFIDownload, filescan +from flasher import NFIFlash def NFIFlasherMain(session, tmp = None, **kwargs): session.open(NFIDownload, "/home/root" ) @@ -13,16 +14,12 @@ def Plugins(**kwargs): # currently only available for DM8000 if HardwareInfo().get_device_name() != "dm8000": return [PluginDescriptor()] - if fileExists("/usr/share/bootlogo-flasher.mvi"): - import flasher - # started from usb stick # don't try to be intelligent and trick this - it's not possible to rewrite the flash memory with a system currently booted from it - return [PluginDescriptor(where = PluginDescriptor.WHERE_WIZARD, fnc = (9,flasher.NFIFlash))] - else: - # started on real enigma2 - return [PluginDescriptor(name=_("NFI Image Flashing"), - description=_("Download .NFI-Files for USB-Flasher"), - icon = "flash.png", - where = PluginDescriptor.WHERE_SOFTWAREMANAGER, - fnc={"SoftwareSupported": NFICallFnc, "menuEntryName": lambda x: _("NFI Image Flashing"), - "menuEntryDescription": lambda x: _("Download .NFI-Files for USB-Flasher")}), - PluginDescriptor(name="nfi", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)] + #return [PluginDescriptor(where = PluginDescriptor.WHERE_WIZARD, fnc = (9,NFIFlash))] + # it's not possible to rewrite the flash memory with a system currently booted from it + return [PluginDescriptor(name=_("NFI Image Flashing"), + description=_("Download .NFI-Files for USB-Flasher"), + icon = "flash.png", + where = PluginDescriptor.WHERE_SOFTWAREMANAGER, + fnc={"SoftwareSupported": NFICallFnc, "menuEntryName": lambda x: _("NFI Image Flashing"), + "menuEntryDescription": lambda x: _("Download .NFI-Files for USB-Flasher")}), + PluginDescriptor(name="nfi", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)] -- cgit v1.2.3 From a03c828dc011ddf93525ad9ed6eae77f3691be7f Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Thu, 12 Aug 2010 12:05:33 +0200 Subject: NFIFlash: hide hdd and other mounts (#480) --- lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index c0094cc1..79fa069a 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -515,13 +515,7 @@ class NFIDownload(Screen): self.target_dir = usbpartition[0][1] self.ackDestinationDevice(device_description=usbpartition[0][0]) else: - self.openDeviceBrowser() - - def openDeviceBrowser(self): - if self.branch != STICK_WIZARD: self.session.openWithCallback(self.DeviceBrowserClosed, DeviceBrowser, None, showDirectories=True, showMountpoints=True, inhibitMounts=["/autofs/sr0/"]) - if self.branch == STICK_WIZARD: - self.session.openWithCallback(self.DeviceBrowserClosed, DeviceBrowser, None, showDirectories=False, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/"]) def DeviceBrowserClosed(self, path): print "[DeviceBrowserClosed]", str(path) @@ -537,7 +531,7 @@ class NFIDownload(Screen): else: dev = device_description message = _("Do you want to download the image to %s ?") % (dev) - choices = [(_("Yes"), self.ackedDestination), (_("List of Storage Devices"),self.openDeviceBrowser), (_("Cancel"),self.keyRed)] + choices = [(_("Yes"), self.ackedDestination), (_("List of Storage Devices"),self.askDestination), (_("Cancel"),self.keyRed)] self.session.openWithCallback(self.ackDestination_query, ChoiceBox, title=message, list=choices) def ackDestination_query(self, choice): @@ -637,7 +631,7 @@ class NFIDownload(Screen): First, you need to prepare a USB stick so that it is bootable. In the next step, an NFI image file can be downloaded from the update server and saved on the USB stick. If you already have a prepared bootable USB stick, please insert it now. Otherwise plug in a USB stick with a minimum size of 64 MB!""") - self.session.openWithCallback(self.wizardDeviceBrowserClosed, DeviceBrowser, None, message, showDirectories=True, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/"]) + self.session.openWithCallback(self.wizardDeviceBrowserClosed, DeviceBrowser, None, message, showDirectories=True, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/","/autofs/sda1/","/media/hdd/","/media/net/","/media/usb/","/media/dvd/"]) def wizardDeviceBrowserClosed(self, path): print "[wizardDeviceBrowserClosed]", path @@ -678,7 +672,7 @@ If you already have a prepared bootable USB stick, please insert it now. Otherwi self.menulist.append((ALLIMAGES, _("Choose image to download"), _("Select desired image from feed list" ), None)) self.menulist.append((STICK_WIZARD, _("USB stick wizard"), _("Prepare another USB stick for image flashing" ), None)) self["menu"].setList(self.menulist) - self["status"].text = _("Currently installed image") + ": %s" % (about.getImageVersionString())) + self["status"].text = _("Currently installed image") + ": %s" % (about.getImageVersionString()) self.branch = START self.updateButtons() -- cgit v1.2.3 From dc3561610ca598f28005932605ad87966350b80f Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Fri, 13 Aug 2010 22:04:43 +0200 Subject: NFIFlash fixes (#480) --- .../Plugins/SystemPlugins/NFIFlash/downloader.py | 38 +++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index 79fa069a..a94de2b6 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -16,7 +16,7 @@ from Components.MultiContent import MultiContentEntryText from Components.ScrollLabel import ScrollLabel from Components.Harddisk import harddiskmanager from Components.Task import Task, Job, job_manager, Condition -from Tools.Directories import fileExists +from Tools.Directories import fileExists, isMount from Tools.HardwareInfo import HardwareInfo from Tools.Downloader import downloadWithProgress from enigma import eConsoleAppContainer, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, eTimer @@ -30,6 +30,8 @@ class ImageDownloadJob(Job): def __init__(self, url, filename, device=None, mountpoint="/"): Job.__init__(self, _("Download .NFI-Files for USB-Flasher")) if device: + if isMount(mountpoint): + UmountTask(self, mountpoint) MountTask(self, device, mountpoint) ImageDownloadTask(self, url, mountpoint+filename) ImageDownloadTask(self, url[:-4]+".nfo", mountpoint+filename[:-4]+".nfo") @@ -44,7 +46,9 @@ class MountTask(Task): def __init__(self, job, device, mountpoint): Task.__init__(self, job, ("mount")) self.setTool("mount") - self.args += [device, mountpoint, "-orw,sync"] + options = "rw,sync" + self.mountpoint = mountpoint + self.args += [ device, mountpoint, "-o"+options ] self.weighting = 1 def processOutput(self, data): @@ -164,7 +168,7 @@ class UnpackTask(Task): def run(self, callback): Task.run(self, callback) - self.delayTimer.start(1000, False) + self.delayTimer.start(950, False) def progress_increment(self): self.progress += 1 @@ -549,28 +553,40 @@ class NFIDownload(Screen): if self.branch == STICK_WIZARD: job = StickWizardJob(self.target_dir) + job.afterEvent = "close" job_manager.AddJob(job) - self.session.openWithCallback(self.StickWizardCB, JobView, job) + job_manager.failed_jobs = [] + self.session.openWithCallback(self.StickWizardCB, JobView, job, afterEventChangeable = False) elif self.branch != STICK_WIZARD: url = self.feedlists[self.branch][self.image_idx][1] filename = self.feedlists[self.branch][self.image_idx][0] - print "[getImage] start downloading %s to %s" % (url, path) + print "[getImage] start downloading %s to %s" % (url, filename) job = ImageDownloadJob(url, filename, self.target_dir, self.usbmountpoint) + job.afterEvent = "close" job_manager.AddJob(job) - self.session.openWithCallback(self.ImageDownloadCB, JobView, job) + job_manager.failed_jobs = [] + self.session.openWithCallback(self.ImageDownloadCB, JobView, job, afterEventChangeable = False) def StickWizardCB(self, ret=None): - self.session.open(MessageBox, _("The USB stick was prepared to be bootable.\nNow you can download an NFI image file!"), type = MessageBox.TYPE_INFO) print "[StickWizardCB]", ret - if len(self.feedlists[ALLIMAGES]) == 0: - self.getFeed() + print job_manager.active_jobs, job_manager.failed_jobs, job_manager.job_classes, job_manager.in_background, job_manager.active_job + if len(job_manager.failed_jobs) == 0: + self.session.open(MessageBox, _("The USB stick was prepared to be bootable.\nNow you can download an NFI image file!"), type = MessageBox.TYPE_INFO) + if len(self.feedlists[ALLIMAGES]) == 0: + self.getFeed() + else: + self.setMenu() else: - self.setMenu() + self.checkUSBStick() def ImageDownloadCB(self, ret): print "[ImageDownloadCB]", ret - self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) + print job_manager.active_jobs, job_manager.failed_jobs, job_manager.job_classes, job_manager.in_background, job_manager.active_job + if len(job_manager.failed_jobs) == 0: + self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) + else: + self.branch = START def getFeed(self): self.feedDownloader15 = feedDownloader(self.feed_base, self.box, OE_vers="1.5") -- cgit v1.2.3 From be0859d12ff4d1f68407d1b3b0423ecaf2c693ac Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Mon, 16 Aug 2010 11:11:35 +0200 Subject: NFIFlash: change display of feed list details --- lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index a94de2b6..e0bad848 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -499,8 +499,16 @@ class NFIDownload(Screen): def listImages(self): print "[listImages]" imagelist = [] + mask = re.compile("%s/(?P1\.\d)/%s/images/(?P.*?)-%s_(?P.*?).nfi" % (self.feed_base, self.box, self.box), re.DOTALL) for name, url in self.feedlists[ALLIMAGES]: - imagelist.append((url, name, _("Download %s from Server" ) % url, None)) + result = mask.match(url) + if result: + if result.group("version").startswith("20"): + version = ( result.group("version")[:4]+'-'+result.group("version")[4:6]+'-'+result.group("version")[6:8] ) + else: + version = result.group("version") + description = "\nOpendreambox %s\n%s image\n%s\n" % (result.group("OE_vers"), result.group("branch"), version) + imagelist.append((url, name, _("Download %s from Server" ) % description, None)) self["menu"].setList(imagelist) def getUSBPartitions(self): -- cgit v1.2.3 From 892a18f6926fa4711d17a2e0442b293467e8963c Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 17 Aug 2010 20:52:48 +0200 Subject: JobView/HTTPProgressDownloader/NFIFlash correctly handle cancelling downloads --- lib/python/Components/Task.py | 5 +-- .../Plugins/SystemPlugins/NFIFlash/downloader.py | 50 ++++++++++++++++------ lib/python/Screens/TaskView.py | 2 +- 3 files changed, 41 insertions(+), 16 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Components/Task.py b/lib/python/Components/Task.py index 2e4e757d..3a755405 100644 --- a/lib/python/Components/Task.py +++ b/lib/python/Components/Task.py @@ -64,11 +64,10 @@ class Job(object): def runNext(self): if self.current_task == len(self.tasks): if len(self.resident_tasks) == 0: - cb = self.callback - self.callback = None self.status = self.FINISHED self.state_changed() - cb(self, None, []) + self.callback(self, None, []) + self.callback = None else: print "still waiting for %d resident task(s) %s to finish" % (len(self.resident_tasks), str(self.resident_tasks)) else: diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index e0bad848..8768021c 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -78,7 +78,9 @@ class ImageDownloadTask(Task): self.error_message = "" self.last_recvbytes = 0 self.error_message = None - + self.download = None + self.aborted = False + def run(self, callback): self.callback = callback self.download = downloadWithProgress(self.url,self.path) @@ -86,23 +88,30 @@ class ImageDownloadTask(Task): self.download.start().addCallback(self.download_finished).addErrback(self.download_failed) print "[ImageDownloadTask] downloading", self.url, "to", self.path + def abort(self): + print "[ImageDownloadTask] aborting", self.url + if self.download: + self.download.stop() + self.aborted = True + def download_progress(self, recvbytes, totalbytes): #print "[update_progress] recvbytes=%d, totalbytes=%d" % (recvbytes, totalbytes) if ( recvbytes - self.last_recvbytes ) > 10000: # anti-flicker self.progress = int(100*(float(recvbytes)/float(totalbytes))) self.name = _("Downloading") + ' ' + "%d of %d kBytes" % (recvbytes/1024, totalbytes/1024) self.last_recvbytes = recvbytes - + def download_failed(self, failure_instance=None, error_message=""): self.error_message = error_message if error_message == "" and failure_instance is not None: self.error_message = failure_instance.getErrorMessage() - print "[download_failed]", self.error_message Task.processFinished(self, 1) - + def download_finished(self, string=""): - print "[download_finished]", string - Task.processFinished(self, 0) + if self.aborted: + self.finish(aborted = True) + else: + Task.processFinished(self, 0) class StickWizardJob(Job): def __init__(self, path): @@ -423,7 +432,10 @@ class NFIDownload(Screen): def go(self): self.onShown.remove(self.go) - self["menu"].index = 0 + self.umountCallback = self.getMD5 + self.umount() + + def getMD5(self): url = "http://www.dreamboxupdate.com/download/opendreambox/dreambox-nfiflasher-%s-md5sums" % self.box client.getPage(url).addCallback(self.md5sums_finished).addErrback(self.feed_failed) @@ -578,7 +590,7 @@ class NFIDownload(Screen): def StickWizardCB(self, ret=None): print "[StickWizardCB]", ret - print job_manager.active_jobs, job_manager.failed_jobs, job_manager.job_classes, job_manager.in_background, job_manager.active_job +# print job_manager.active_jobs, job_manager.failed_jobs, job_manager.job_classes, job_manager.in_background, job_manager.active_job if len(job_manager.failed_jobs) == 0: self.session.open(MessageBox, _("The USB stick was prepared to be bootable.\nNow you can download an NFI image file!"), type = MessageBox.TYPE_INFO) if len(self.feedlists[ALLIMAGES]) == 0: @@ -586,15 +598,17 @@ class NFIDownload(Screen): else: self.setMenu() else: - self.checkUSBStick() + self.umountCallback = self.checkUSBStick + self.umount() def ImageDownloadCB(self, ret): print "[ImageDownloadCB]", ret - print job_manager.active_jobs, job_manager.failed_jobs, job_manager.job_classes, job_manager.in_background, job_manager.active_job +# print job_manager.active_jobs, job_manager.failed_jobs, job_manager.job_classes, job_manager.in_background, job_manager.active_job if len(job_manager.failed_jobs) == 0: self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) else: - self.branch = START + self.umountCallback = self.keyRed + self.umount() def getFeed(self): self.feedDownloader15 = feedDownloader(self.feed_base, self.box, OE_vers="1.5") @@ -655,7 +669,7 @@ class NFIDownload(Screen): First, you need to prepare a USB stick so that it is bootable. In the next step, an NFI image file can be downloaded from the update server and saved on the USB stick. If you already have a prepared bootable USB stick, please insert it now. Otherwise plug in a USB stick with a minimum size of 64 MB!""") - self.session.openWithCallback(self.wizardDeviceBrowserClosed, DeviceBrowser, None, message, showDirectories=True, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/","/autofs/sda1/","/media/hdd/","/media/net/","/media/usb/","/media/dvd/"]) + self.session.openWithCallback(self.wizardDeviceBrowserClosed, DeviceBrowser, None, message, showDirectories=True, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/","/autofs/sda1/","/media/hdd/","/media/net/",self.usbmountpoint,"/media/dvd/"]) def wizardDeviceBrowserClosed(self, path): print "[wizardDeviceBrowserClosed]", path @@ -740,6 +754,18 @@ If you already have a prepared bootable USB stick, please insert it now. Otherwi print "check failed! calling", repr(self.md5_failback) self.md5_failback() + def umount(self): + cmd = "umount " + self.usbmountpoint + print "[umount]", cmd + self.container.setCWD('/') + self.container.appClosed.append(self.umountFinished) + self.container.execute(cmd) + + def umountFinished(self, retval): + print "[umountFinished]", str(retval) + self.container.appClosed.remove(self.umountFinished) + self.umountCallback() + def main(session, **kwargs): session.open(NFIDownload,"/home/root") diff --git a/lib/python/Screens/TaskView.py b/lib/python/Screens/TaskView.py index 633aae0d..78648602 100644 --- a/lib/python/Screens/TaskView.py +++ b/lib/python/Screens/TaskView.py @@ -118,7 +118,7 @@ class JobView(InfoBarNotifications, Screen, ConfigListScreen): if self.settings.afterEvent.getValue() == "nothing": return elif self.settings.afterEvent.getValue() == "close": - self.abort() + self.close(False) from Screens.MessageBox import MessageBox if self.settings.afterEvent.getValue() == "deepstandby": if not Screens.Standby.inTryQuitMainloop: -- cgit v1.2.3 From fb75a5db67a5f82d9c4976cd2d056f47376affd3 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 24 Aug 2010 15:03:16 +0200 Subject: fix downloading image to flash or harddrive (#480) --- .../Plugins/SystemPlugins/NFIFlash/downloader.py | 42 ++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index 8768021c..2c8b45db 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -539,7 +539,10 @@ class NFIDownload(Screen): self.target_dir = usbpartition[0][1] self.ackDestinationDevice(device_description=usbpartition[0][0]) else: - self.session.openWithCallback(self.DeviceBrowserClosed, DeviceBrowser, None, showDirectories=True, showMountpoints=True, inhibitMounts=["/autofs/sr0/"]) + self.openDeviceBrowser() + + def openDeviceBrowser(self): + self.session.openWithCallback(self.DeviceBrowserClosed, DeviceBrowser, None, showDirectories=True, showMountpoints=True, inhibitMounts=["/autofs/sr0/"]) def DeviceBrowserClosed(self, path): print "[DeviceBrowserClosed]", str(path) @@ -555,7 +558,7 @@ class NFIDownload(Screen): else: dev = device_description message = _("Do you want to download the image to %s ?") % (dev) - choices = [(_("Yes"), self.ackedDestination), (_("List of Storage Devices"),self.askDestination), (_("Cancel"),self.keyRed)] + choices = [(_("Yes"), self.ackedDestination), (_("List of Storage Devices"),self.openDeviceBrowser), (_("Cancel"),self.keyRed)] self.session.openWithCallback(self.ackDestination_query, ChoiceBox, title=message, list=choices) def ackDestination_query(self, choice): @@ -566,27 +569,30 @@ class NFIDownload(Screen): self.keyRed() def ackedDestination(self): - print "[ackedDestination]", self.branch, self.target_dir, self.target_dir[8:] + print "[ackedDestination]", self.branch, self.target_dir self.container.setCWD("/mnt") if self.target_dir[:8] == "/autofs/": self.target_dir = "/dev/" + self.target_dir[8:-1] - if self.branch == STICK_WIZARD: - job = StickWizardJob(self.target_dir) - job.afterEvent = "close" - job_manager.AddJob(job) - job_manager.failed_jobs = [] - self.session.openWithCallback(self.StickWizardCB, JobView, job, afterEventChangeable = False) - - elif self.branch != STICK_WIZARD: - url = self.feedlists[self.branch][self.image_idx][1] - filename = self.feedlists[self.branch][self.image_idx][0] - print "[getImage] start downloading %s to %s" % (url, filename) + if self.branch == STICK_WIZARD: + job = StickWizardJob(self.target_dir) + job.afterEvent = "close" + job_manager.AddJob(job) + job_manager.failed_jobs = [] + self.session.openWithCallback(self.StickWizardCB, JobView, job, afterEventChangeable = False) + + elif self.branch != STICK_WIZARD: + url = self.feedlists[self.branch][self.image_idx][1] + filename = self.feedlists[self.branch][self.image_idx][0] + print "[getImage] start downloading %s to %s" % (url, filename) + if self.target_dir.startswith("/dev/"): job = ImageDownloadJob(url, filename, self.target_dir, self.usbmountpoint) - job.afterEvent = "close" - job_manager.AddJob(job) - job_manager.failed_jobs = [] - self.session.openWithCallback(self.ImageDownloadCB, JobView, job, afterEventChangeable = False) + else: + job = ImageDownloadJob(url, filename, None, self.target_dir) + job.afterEvent = "close" + job_manager.AddJob(job) + job_manager.failed_jobs = [] + self.session.openWithCallback(self.ImageDownloadCB, JobView, job, afterEventChangeable = False) def StickWizardCB(self, ret=None): print "[StickWizardCB]", ret -- cgit v1.2.3 From 88e935647412df82e4773265ff1e1e10b261e061 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 1 Sep 2010 15:41:15 +0200 Subject: [DVDBurn] remove absolut paths for DVD media toolbox console utilities (add #429) --- lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py index 53287a36..0b81cfdf 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py +++ b/lib/python/Plugins/Extensions/DVDBurn/DVDToolbox.py @@ -68,7 +68,7 @@ class DVDToolbox(Screen): self["info"].text = "" self["details"].setText("") self.Console = Console() - cmd = "/bin/dvd+rw-mediainfo /dev/" + harddiskmanager.getCD() + cmd = "dvd+rw-mediainfo /dev/" + harddiskmanager.getCD() self.Console.ePopen(cmd, self.mediainfoCB) def format(self): @@ -186,7 +186,7 @@ class DVDformatTask(Task): Task.__init__(self, job, ("RW medium format")) self.toolbox = job.toolbox self.postconditions.append(DVDformatTaskPostcondition()) - self.setTool("/bin/dvd+rw-format") + self.setTool("dvd+rw-format") self.args += [ "/dev/" + harddiskmanager.getCD() ] self.end = 1100 self.retryargs = [ ] -- cgit v1.2.3 From 14b0f1f771ab3ece2f104a5bc6ec871e5b5f952d Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 1 Sep 2010 15:53:27 +0200 Subject: [NFIFlash] ask whether to run configuration backup after image download (add #480) --- .../Plugins/SystemPlugins/NFIFlash/downloader.py | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index 2c8b45db..27038e67 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -35,8 +35,8 @@ class ImageDownloadJob(Job): MountTask(self, device, mountpoint) ImageDownloadTask(self, url, mountpoint+filename) ImageDownloadTask(self, url[:-4]+".nfo", mountpoint+filename[:-4]+".nfo") - if device: - UmountTask(self, mountpoint) + #if device: + #UmountTask(self, mountpoint) def retry(self): self.tasks[0].args += self.tasks[0].retryargs @@ -611,11 +611,30 @@ class NFIDownload(Screen): print "[ImageDownloadCB]", ret # print job_manager.active_jobs, job_manager.failed_jobs, job_manager.job_classes, job_manager.in_background, job_manager.active_job if len(job_manager.failed_jobs) == 0: - self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) + self.session.openWithCallback(self.askBackupCB, MessageBox, _("The wizard can backup your current settings. Do you want to do a backup now?"), MessageBox.TYPE_YESNO) else: self.umountCallback = self.keyRed self.umount() + def askBackupCB(self, ret): + if ret: + from Plugins.SystemPlugins.SoftwareManager.BackupRestore import BackupScreen + + class USBBackupScreen(BackupScreen): + def __init__(self, session, usbmountpoint): + BackupScreen.__init__(self, session, runBackup = True) + self.backuppath = usbmountpoint + self.fullbackupfilename = self.backuppath + "/" + self.backupfile + + self.session.openWithCallback(self.showHint, USBBackupScreen, self.usbmountpoint) + else: + self.showHint() + + def showHint(self, ret=None): + self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) + self.umountCallback = self.keyRed + self.umount() + def getFeed(self): self.feedDownloader15 = feedDownloader(self.feed_base, self.box, OE_vers="1.5") self.feedDownloader16 = feedDownloader(self.feed_base, self.box, OE_vers="1.6") -- cgit v1.2.3 From 8535d7279ebd982dbcdaf4edc1d10fb56f9b826f Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 7 Sep 2010 14:06:41 +0200 Subject: NFIFlash: integrate configuration backup/restore, string corrections --- .../Plugins/SystemPlugins/NFIFlash/downloader.py | 10 ++--- .../Plugins/SystemPlugins/NFIFlash/flasher.py | 48 ++++++++++++++++++---- 2 files changed, 46 insertions(+), 12 deletions(-) (limited to 'lib/python/Plugins') diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py index 27038e67..296d3bca 100644 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py @@ -215,7 +215,7 @@ class CopyTask(Task): class NFOViewer(Screen): skin = """ - + """ @@ -631,7 +631,7 @@ class NFIDownload(Screen): self.showHint() def showHint(self, ret=None): - self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and plug in the bootable USB stick.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) + self.session.open(MessageBox, _("To update your Dreambox firmware, please follow these steps:\n1) Turn off your box with the rear power switch and make sure the bootable USB stick is plugged in.\n2) Turn mains back on and hold the DOWN button on the front panel pressed for 10 seconds.\n3) Wait for bootup and follow instructions of the wizard."), type = MessageBox.TYPE_INFO) self.umountCallback = self.keyRed self.umount() @@ -690,8 +690,8 @@ class NFIDownload(Screen): def askStartWizard(self): self.branch = STICK_WIZARD - message = _("""This plugin creates a USB stick which can be used to update the firmware of your Dreambox in case it has no network connection or only WLAN access. -First, you need to prepare a USB stick so that it is bootable. + message = _("""This plugin creates a USB stick which can be used to update the firmware of your Dreambox without the need for a network or WLAN connection. +First, a USB stick needs to be prepared so that it becomes bootable. In the next step, an NFI image file can be downloaded from the update server and saved on the USB stick. If you already have a prepared bootable USB stick, please insert it now. Otherwise plug in a USB stick with a minimum size of 64 MB!""") self.session.openWithCallback(self.wizardDeviceBrowserClosed, DeviceBrowser, None, message, showDirectories=True, showMountpoints=True, inhibitMounts=["/","/autofs/sr0/","/autofs/sda1/","/media/hdd/","/media/net/",self.usbmountpoint,"/media/dvd/"]) @@ -753,7 +753,7 @@ If you already have a prepared bootable USB stick, please insert it now. Otherwi def nfo_finished(self,nfodata=""): print "[nfo_finished] " + str(nfodata) - self["key_blue"].text = _("Changelog viewer") + self["key_blue"].text = _("Changelog") self.nfo = nfodata def md5verify(self, md5, path): diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py index 95c7eee9..ba96c071 100755 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/flasher.py @@ -2,6 +2,7 @@ from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Screens.ChoiceBox import ChoiceBox from Screens.Standby import TryQuitMainloop +from Screens.Console import Console from Components.ActionMap import ActionMap from Components.Sources.StaticText import StaticText from Components.Sources.Progress import Progress @@ -13,7 +14,7 @@ from Screens.TaskView import JobView from Tools.Directories import fileExists from Tools.HardwareInfo import HardwareInfo from os import system -from enigma import eConsoleAppContainer +from enigma import eConsoleAppContainer, quitMainloop from Components.About import about class md5Postcondition(Condition): @@ -95,11 +96,11 @@ class NFIFlash(Screen): self["key_green"] = StaticText() self["key_yellow"] = StaticText() self["key_blue"] = StaticText() - self.filelist = FileList(self.usbmountpoint, matchingPattern = "^.*\.(nfi|NFI)") + self.filelist = FileList(self.usbmountpoint, matchingPattern = "^.*\.(nfi|NFI)", showDirectories = False, showMountpoints = False) self["filelist"] = self.filelist - self["infolabel"] = StaticText("") + self["infolabel"] = StaticText() - self["status"] = StaticText("currently installed image: %s" % (about.getImageVersionString())) + self["status"] = StaticText(_("Please select an NFI file and press green key to flash!") + '\n' + _("currently installed image: %s") % (about.getImageVersionString())) self.job = None self["shortcuts"] = ActionMap(["OkCancelActions", "ColorActions", "ShortcutActions", "DirectionActions"], @@ -115,6 +116,15 @@ class NFIFlash(Screen): "right": self.keyRight }, -1) self.md5sum = "" + self.onShown.append(self.autostart) + + def autostart(self): + self.onShown.remove(self.autostart) + self.check_for_NFO() + print "[[layoutFinished]]", len(self["filelist"].getFileList()) + if len(self["filelist"].getFileList()) == 1: + print "==1" + self.keyOk() def keyUp(self): self["filelist"].up() @@ -176,6 +186,7 @@ class NFIFlash(Screen): def createJob(self): self.job = Job("Image flashing job") + self.job.afterEvent = "close" cwd = self["filelist"].getCurrentDirectory() md5verify(self.job, cwd, self.md5sum) writeNAND(self.job, [self.nfifile], self.box) @@ -183,13 +194,36 @@ class NFIFlash(Screen): self["key_yellow"].text = "" self["key_green"].text = "" job_manager.AddJob(self.job) - self.session.openWithCallback(self.flashed, JobView, self.job, cancelable = False, backgroundable = False) + self.session.openWithCallback(self.flashed, JobView, self.job, cancelable = False, backgroundable = False, afterEventChangeable = False) def flashed(self, bg): print "[flashed]" - self["key_yellow"].text = _("Reboot") + if self.job.status == self.job.FINISHED: + self["status"].text = _("NFI image flashing completed. Press Yellow to Reboot!") + filename = self.usbmountpoint+'enigma2settingsbackup.tar.gz' + if fileExists(filename): + import os.path, time + date = time.ctime(os.path.getmtime(filename)) + self.session.openWithCallback(self.askRestoreCB, MessageBox, _("The wizard found a configuration backup. Do you want to restore your old settings from %s?") % date, MessageBox.TYPE_YESNO) + else: + self.unlockRebootButton() + else: + self["status"].text = _("Flashing failed") + + def askRestoreCB(self, ret): + if ret: + from Plugins.SystemPlugins.SoftwareManager.BackupRestore import getBackupFilename + restorecmd = ["tar -xzvf " + self.usbmountpoint + getBackupFilename() + " -C /"] + self.session.openWithCallback(self.unlockRebootButton, Console, title = _("Restore is running..."), cmdlist = restorecmd, closeOnSuccess = True) + else: + self.unlockRebootButton() + + def unlockRebootButton(self, retval = None): + if self.job.status == self.job.FINISHED: + self["key_yellow"].text = _("Reboot") def reboot(self, ret=None): if self.job.status == self.job.FINISHED: self["status"].text = ("rebooting...") - TryQuitMainloop(self.session,2) + from os import system + system("/usr/lib/enigma2/python/Plugins/SystemPlugins/NFIFlash/kill_e2_reboot.sh") -- cgit v1.2.3 From ceaa41889d0e8959393b8c0fce601707b9494b73 Mon Sep 17 00:00:00 2001 From: acid-burn Date: Tue, 21 Sep 2010 21:29:48 +0200 Subject: Enigma2-meta: rework plugin meta files and prepare for inclusion into enigma2 translation. Meta.xml files are now only in english and translation is now easy possible for all languages over enigma2 translation project. This also reduces consumed space inside flash memory. Add missing TempFanControl plugin meta and LICENSE. DreamInfohandler.py,SoftwareManager: follow meta xml changes. fixes #578 --- Makefile.am | 8 +- configure.ac | 1 + lib/python/Components/DreamInfoHandler.py | 86 ++++++---------------- .../CutListEditor/meta/plugin_cutlisteditor.xml | 13 +--- .../Extensions/DVDBurn/meta/plugin_dvdburn.xml | 17 ++--- .../Extensions/DVDPlayer/meta/plugin_dvdplayer.xml | 13 +--- .../GraphMultiEPG/meta/plugin_graphmultiepg.xml | 13 +--- .../MediaPlayer/meta/plugin_mediaplayer.xml | 13 +--- .../MediaScanner/meta/plugin_mediascanner.xml | 14 +--- .../PicturePlayer/meta/plugin_pictureplayer.xml | 13 +--- .../Extensions/SocketMMI/meta/plugin_socketmmi.xml | 11 +-- .../TuxboxPlugins/meta/plugin_tuxboxplugins.xml | 11 +-- .../CleanupWizard/meta/plugin_cleanupwizard.xml | 18 +---- .../meta/plugin_commoninterfaceassignment.xml | 23 ++---- .../meta/plugin_crashlogautosubmit.xml | 17 +---- .../meta/plugin_defaultservicesscanner.xml | 16 +--- .../DiseqcTester/meta/plugin_diseqctester.xml | 16 +--- .../meta/plugin_frontprocessorupgrade.xml | 14 +--- .../SystemPlugins/Hotplug/meta/plugin_hotplug.xml | 15 +--- .../NFIFlash/meta/plugin_nfiflash.xml | 18 +---- .../NetworkWizard/meta/plugin_networkwizard.xml | 16 +--- .../meta/plugin_positionersetup.xml | 17 +---- .../meta/plugin_satelliteequipmentcontrol.xml | 16 +--- .../Satfinder/meta/plugin_satfinder.xml | 18 +---- .../SkinSelector/meta/plugin_skinselector.xml | 15 +--- .../SystemPlugins/SoftwareManager/SoftwareTools.py | 2 +- .../meta/plugin_softwaremanager.xml | 18 +---- .../SystemPlugins/SoftwareManager/plugin.py | 39 ++++------ .../Plugins/SystemPlugins/TempFanControl/LICENSE | 12 +++ .../SystemPlugins/TempFanControl/Makefile.am | 4 + .../SystemPlugins/TempFanControl/meta/Makefile.am | 3 + .../TempFanControl/meta/plugin_tempfancontrol.xml | 18 +++++ .../meta/plugin_videoenhancement.xml | 14 +--- .../VideoTune/meta/plugin_videotune.xml | 13 +--- .../Videomode/meta/plugin_videomode.xml | 14 +--- .../WirelessLan/meta/plugin_wirelesslan.xml | 12 +-- tools/genmetaindex.py | 12 ++- 37 files changed, 173 insertions(+), 420 deletions(-) mode change 100644 => 100755 lib/python/Plugins/Extensions/SocketMMI/meta/plugin_socketmmi.xml mode change 100644 => 100755 lib/python/Plugins/Extensions/TuxboxPlugins/meta/plugin_tuxboxplugins.xml mode change 100644 => 100755 lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/meta/plugin_frontprocessorupgrade.xml mode change 100644 => 100755 lib/python/Plugins/SystemPlugins/Hotplug/meta/plugin_hotplug.xml create mode 100755 lib/python/Plugins/SystemPlugins/TempFanControl/LICENSE mode change 100644 => 100755 lib/python/Plugins/SystemPlugins/TempFanControl/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/TempFanControl/meta/Makefile.am create mode 100755 lib/python/Plugins/SystemPlugins/TempFanControl/meta/plugin_tempfancontrol.xml (limited to 'lib/python/Plugins') diff --git a/Makefile.am b/Makefile.am index c517d9c5..bc1770b7 100755 --- a/Makefile.am +++ b/Makefile.am @@ -7,12 +7,8 @@ install_PYTHON = \ keyids.py keymapparser.py mytest.py skin.py timer.py tools.py GlobalActions.py \ e2reactor.py -LANGS := $(shell cat $(srcdir)/po/LINGUAS) - install-exec-hook: - for lang in $(LANGS); do \ - $(PYTHON) $(srcdir)/tools/genmetaindex.py $$lang $(DESTDIR)$(datadir)/meta/plugin_*.xml > $(DESTDIR)$(datadir)/meta/index-enigma2_$$lang.xml; \ - done + $(PYTHON) $(srcdir)/tools/genmetaindex.py $(DESTDIR)$(datadir)/meta/plugin_*.xml > $(DESTDIR)$(datadir)/meta/index-enigma2.xml uninstall-hook: - $(RM) $(DESTDIR)$(datadir)/meta/index-enigma2_*.xml + $(RM) $(DESTDIR)$(datadir)/meta/index-enigma2.xml diff --git a/configure.ac b/configure.ac index 05c3a8eb..35fad779 100755 --- a/configure.ac +++ b/configure.ac @@ -159,6 +159,7 @@ lib/python/Plugins/SystemPlugins/Hotplug/Makefile lib/python/Plugins/SystemPlugins/Hotplug/meta/Makefile lib/python/Plugins/SystemPlugins/Makefile lib/python/Plugins/SystemPlugins/TempFanControl/Makefile +lib/python/Plugins/SystemPlugins/TempFanControl/meta/Makefile lib/python/Plugins/SystemPlugins/NetworkWizard/Makefile lib/python/Plugins/SystemPlugins/NetworkWizard/meta/Makefile lib/python/Plugins/SystemPlugins/NFIFlash/Makefile diff --git a/lib/python/Components/DreamInfoHandler.py b/lib/python/Components/DreamInfoHandler.py index 85e2b533..dd140cbb 100755 --- a/lib/python/Components/DreamInfoHandler.py +++ b/lib/python/Components/DreamInfoHandler.py @@ -16,7 +16,7 @@ class InfoHandlerParseError(Exception): return repr(self.value) class InfoHandler(xml.sax.ContentHandler): - def __init__(self, prerequisiteMet, directory, language = None): + def __init__(self, prerequisiteMet, directory): self.attributes = {} self.directory = directory self.list = [] @@ -26,9 +26,6 @@ class InfoHandler(xml.sax.ContentHandler): self.validFileTypes = ["skin", "config", "services", "favourites", "package"] self.prerequisitesMet = prerequisiteMet self.data = "" - self.language = language - self.translatedPackageInfos = {} - self.foundTranslation = None def printError(self, error): print "Error in defaults xml files:", error @@ -52,15 +49,6 @@ class InfoHandler(xml.sax.ContentHandler): if name == "info": self.foundTranslation = None self.data = "" - if not attrs.has_key("language"): - print "info tag with no language attribute" - else: - if attrs["language"] == 'en': # read default translations - self.foundTranslation = False - self.data = "" - elif attrs["language"] == self.language: - self.foundTranslation = True - self.data = "" if name == "files": if attrs.has_key("type"): @@ -91,20 +79,17 @@ class InfoHandler(xml.sax.ContentHandler): if attrs.has_key("details"): self.attributes["details"] = str(attrs["details"]) if attrs.has_key("name"): - self.attributes["name"] = str(attrs["name"].encode("utf-8")) + self.attributes["name"] = str(attrs["name"]) if attrs.has_key("packagename"): - self.attributes["packagename"] = str(attrs["packagename"].encode("utf-8")) + self.attributes["packagename"] = str(attrs["packagename"]) if attrs.has_key("packagetype"): - self.attributes["packagetype"] = str(attrs["packagetype"].encode("utf-8")) + self.attributes["packagetype"] = str(attrs["packagetype"]) if attrs.has_key("shortdescription"): - self.attributes["shortdescription"] = str(attrs["shortdescription"].encode("utf-8")) + self.attributes["shortdescription"] = str(attrs["shortdescription"]) if name == "screenshot": if attrs.has_key("src"): - if self.foundTranslation is False: - self.attributes["screenshot"] = str(attrs["src"]) - elif self.foundTranslation is True: - self.translatedPackageInfos["screenshot"] = str(attrs["src"]) + self.attributes["screenshot"] = str(attrs["src"]) def endElement(self, name): #print "endElement", name @@ -124,7 +109,7 @@ class InfoHandler(xml.sax.ContentHandler): self.attributes[self.filetype].append({ "name": str(self.fileattrs["name"]), "directory": directory }) if name in ( "default", "package" ): - self.list.append({"attributes": self.attributes, 'prerequisites': self.globalprerequisites ,"translation": self.translatedPackageInfos}) + self.list.append({"attributes": self.attributes, 'prerequisites': self.globalprerequisites}) self.attributes = {} self.globalprerequisites = {} @@ -133,30 +118,13 @@ class InfoHandler(xml.sax.ContentHandler): self.attributes["author"] = str(data) if self.elements[-1] == "name": self.attributes["name"] = str(data) - if self.foundTranslation is False: - if self.elements[-1] == "author": - self.attributes["author"] = str(data) - if self.elements[-1] == "name": - self.attributes["name"] = str(data) - if self.elements[-1] == "packagename": - self.attributes["packagename"] = str(data.encode("utf-8")) - if self.elements[-1] == "shortdescription": - self.attributes["shortdescription"] = str(data.encode("utf-8")) - if self.elements[-1] == "description": - self.data += data.strip() - self.attributes["description"] = str(self.data.encode("utf-8")) - elif self.foundTranslation is True: - if self.elements[-1] == "author": - self.translatedPackageInfos["author"] = str(data) - if self.elements[-1] == "name": - self.translatedPackageInfos["name"] = str(data) - if self.elements[-1] == "description": - self.data += data.strip() - self.translatedPackageInfos["description"] = str(self.data.encode("utf-8")) - if self.elements[-1] == "name": - self.translatedPackageInfos["name"] = str(data.encode("utf-8")) - if self.elements[-1] == "shortdescription": - self.translatedPackageInfos["shortdescription"] = str(data.encode("utf-8")) + if self.elements[-1] == "packagename": + self.attributes["packagename"] = str(data) + if self.elements[-1] == "shortdescription": + self.attributes["shortdescription"] = str(data) + if self.elements[-1] == "description": + self.data += data + self.attributes["description"] = str(self.data) #print "characters", data @@ -166,13 +134,12 @@ class DreamInfoHandler: STATUS_ERROR = 2 STATUS_INIT = 4 - def __init__(self, statusCallback, blocking = False, neededTag = None, neededFlag = None, language = None): + def __init__(self, statusCallback, blocking = False, neededTag = None, neededFlag = None): self.hardware_info = HardwareInfo() self.directory = "/" self.neededTag = neededTag self.neededFlag = neededFlag - self.language = language # caution: blocking should only be used, if further execution in enigma2 depends on the outcome of # the installer! @@ -203,8 +170,8 @@ class DreamInfoHandler: #print handler.list def readIndex(self, directory, file): - print "Reading .xml meta index file", file - handler = InfoHandler(self.prerequisiteMet, directory, self.language) + print "Reading .xml meta index file", directory, file + handler = InfoHandler(self.prerequisiteMet, directory) try: xml.sax.parse(file, handler) for entry in handler.list: @@ -216,7 +183,7 @@ class DreamInfoHandler: def readDetails(self, directory, file): self.packageDetails = [] print "Reading .xml meta details file", file - handler = InfoHandler(self.prerequisiteMet, directory, self.language) + handler = InfoHandler(self.prerequisiteMet, directory) try: xml.sax.parse(file, handler) for entry in handler.list: @@ -225,7 +192,6 @@ class DreamInfoHandler: print "file", file, "ignored due to errors in the file" #print handler.list - # prerequisites = True: give only packages matching the prerequisites def fillPackagesList(self, prerequisites = True): self.packageslist = [] @@ -254,20 +220,14 @@ class DreamInfoHandler: self.directory = [self.directory] for indexfile in os.listdir(self.directory[0]): - if indexfile.startswith("index"): - if indexfile.endswith("_en.xml"): #we first catch all english indexfiles - indexfileList.append(os.path.splitext(indexfile)[0][:-3]) - + if indexfile.startswith("index-"): + if indexfile.endswith(".xml"): + indexfileList.append(indexfile) if len(indexfileList): for file in indexfileList: neededFile = self.directory[0] + "/" + file - if self.language is not None: - if os.path.exists(neededFile + '_' + self.language + '.xml' ): - #print "translated index file found",neededFile + '_' + self.language + '.xml' - self.readIndex(self.directory[0] + "/", neededFile + '_' + self.language + '.xml') - else: - #print "reading original index file" - self.readIndex(self.directory[0] + "/", neededFile + '_en.xml') + if os.path.isfile(neededFile): + self.readIndex(self.directory[0] + "/" , neededFile) if prerequisites: for package in self.packagesIndexlist[:]: diff --git a/lib/python/Plugins/Extensions/CutListEditor/meta/plugin_cutlisteditor.xml b/lib/python/Plugins/Extensions/CutListEditor/meta/plugin_cutlisteditor.xml index 1431caf4..7132ba02 100755 --- a/lib/python/Plugins/Extensions/CutListEditor/meta/plugin_cutlisteditor.xml +++ b/lib/python/Plugins/Extensions/CutListEditor/meta/plugin_cutlisteditor.xml @@ -2,23 +2,14 @@ - + Dream Multimedia CutListEditor enigma2-plugin-extensions-cutlisteditor - CutListEditor allows you to edit your movies. + CutListEditor allows you to edit your movies CutListEditor allows you to edit your movies.\nSeek to the start of the stuff you want to cut away. Press OK, select 'start cut'.\nThen seek to the end, press OK, select 'end cut'. That's it. - - Dream Multimedia - Schnitteditor - enigma2-plugin-extensions-cutlisteditor - Mit dem Schnitteditor können Sie Ihre Aufnahmen schneiden. - Mit dem Schnitteditor können Sie Ihre Aufnahmen schneiden.\nSpulen Sie zum Anfang des zu schneidenden Teils der Aufnahme. Drücken Sie dann OK und wählen Sie: 'start cut'.\nDann spulen Sie zum Ende, drücken OK und wählen 'end cut'. Das ist alles. - - - diff --git a/lib/python/Plugins/Extensions/DVDBurn/meta/plugin_dvdburn.xml b/lib/python/Plugins/Extensions/DVDBurn/meta/plugin_dvdburn.xml index 647d1cfd..c1e202a9 100755 --- a/lib/python/Plugins/Extensions/DVDBurn/meta/plugin_dvdburn.xml +++ b/lib/python/Plugins/Extensions/DVDBurn/meta/plugin_dvdburn.xml @@ -3,22 +3,17 @@ - + Dream Multimedia DVDBurn enigma2-plugin-extensions-dvdburn - With DVDBurn you can burn your recordings to a dvd. - With DVDBurn you can burn your recordings to a dvd.\nArchive all your favorite movies to recordable dvds with menus if wanted. + Burn your recordings to DVD + With DVDBurn you can make compilations of records from your Dreambox hard drive.\n + Optionally you can add customizable menus. You can record the compilation to a standard-compliant DVD that can be played on conventinal DVD players.\n + HDTV recordings can only be burned in proprietary dreambox format. - - Dream Multimedia - DVDBurn - enigma2-plugin-extensions-dvdburn - Mit DVDBurn brennen Sie ihre Aufnahmen auf DVD. - Mit DVDBurn brennen Sie ihre Aufnahmen auf DVD.\nArchivieren Sie Ihre Liblingsfilme auf DVD mit Menus wenn Sie es wünschen. - - + diff --git a/lib/python/Plugins/Extensions/DVDPlayer/meta/plugin_dvdplayer.xml b/lib/python/Plugins/Extensions/DVDPlayer/meta/plugin_dvdplayer.xml index 1353f7d2..6fc5a6f1 100755 --- a/lib/python/Plugins/Extensions/DVDPlayer/meta/plugin_dvdplayer.xml +++ b/lib/python/Plugins/Extensions/DVDPlayer/meta/plugin_dvdplayer.xml @@ -2,23 +2,14 @@ - + Dream Multimedia DVDPlayer enigma2-plugin-extensions-dvdplayer - DVDPlayer plays your DVDs on your Dreambox. + DVDPlayer plays your DVDs on your Dreambox DVDPlayer plays your DVDs on your Dreambox.\nWith the DVDPlayer you can play your DVDs on your Dreambox from a DVD or even from an iso file or video_ts folder on your harddisc or network. - - Dream Multimedia - DVDPlayer - enigma2-plugin-extensions-dvdplayer - Spielen Sie Ihre DVDs mit dem DVDPlayer auf Ihrer Dreambox ab. - Spielen Sie Ihre DVDs mit dem DVDPlayer auf Ihrer Dreambox ab.\nMit dem DVDPlayer können Sie Ihre DVDs auf Ihrer Dreambox abspielen. Dabei ist es egal ob Sie von DVD, iso-Datei oder sogar direkt von einer video_ts Ordnerstruktur von Ihrer Festplatte oder dem Netzwerk abspielen. - - - diff --git a/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml b/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml index 3e2a3f6e..d3a2edf8 100755 --- a/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml +++ b/lib/python/Plugins/Extensions/GraphMultiEPG/meta/plugin_graphmultiepg.xml @@ -3,23 +3,14 @@ - + Dream Multimedia GraphMultiEPG enigma2-plugin-extensions-graphmultiepg - GraphMultiEPG shows a graphical timeline EPG. + GraphMultiEPG shows a graphical timeline EPG GraphMultiEPG shows a graphical timeline EPG.\nShows a nice overview of all running und upcoming tv shows. - - Dream Multimedia - GraphMultiEPG - enigma2-plugin-extensions-graphmultiepg - Zeigt ein grafisches Zeitlinien-EPG. - Zeigt ein grafisches Zeitlinien-EPG.\nZeigt eine grafische Übersicht aller laufenden und kommenden Sendungen. - - - diff --git a/lib/python/Plugins/Extensions/MediaPlayer/meta/plugin_mediaplayer.xml b/lib/python/Plugins/Extensions/MediaPlayer/meta/plugin_mediaplayer.xml index 2f9f22bf..ffbb8e89 100755 --- a/lib/python/Plugins/Extensions/MediaPlayer/meta/plugin_mediaplayer.xml +++ b/lib/python/Plugins/Extensions/MediaPlayer/meta/plugin_mediaplayer.xml @@ -2,23 +2,14 @@ - + Dream Multimedia MediaPlayer enigma2-plugin-extensions-mediaplayer - Mediaplayer plays your favorite music and videos. + Plays your favorite music and videos Mediaplayer plays your favorite music and videos.\nPlay all your favorite music and video files, organize them in playlists, view cover and album information. - - Dream Multimedia - MediaPlayer - enigma2-plugin-extensions-mediaplayer - Mediaplayer spielt Ihre Musik und Videos. - Mediaplayer spielt Ihre Musik und Videos.\nSie können all Ihre Musik- und Videodateien abspielen, in Playlisten organisieren, Cover und Albuminformationen abrufen. - - - diff --git a/lib/python/Plugins/Extensions/MediaScanner/meta/plugin_mediascanner.xml b/lib/python/Plugins/Extensions/MediaScanner/meta/plugin_mediascanner.xml index eced924f..eb9de1b6 100755 --- a/lib/python/Plugins/Extensions/MediaScanner/meta/plugin_mediascanner.xml +++ b/lib/python/Plugins/Extensions/MediaScanner/meta/plugin_mediascanner.xml @@ -1,25 +1,15 @@ - - + Dream Multimedia MediaScanner enigma2-plugin-extensions-mediascanner - MediaScanner scans devices for playable media files. + Scan devices for playable media files MediaScanner scans devices for playable media files and displays a menu with possible actions like viewing pictures or playing movies. - - Dream Multimedia - MediaScanner - enigma2-plugin-extensions-mediascanner - MediaScanner durchsucht Geräte nach Mediendateien. - MediaScanner durchsucht Geräte nach Mediendateien und bietet Ihnen die dazu passenden Aktionen an wie z.B. Bilder betrachten oder Videos abspielen. - - - diff --git a/lib/python/Plugins/Extensions/PicturePlayer/meta/plugin_pictureplayer.xml b/lib/python/Plugins/Extensions/PicturePlayer/meta/plugin_pictureplayer.xml index faff9785..16e2ec90 100755 --- a/lib/python/Plugins/Extensions/PicturePlayer/meta/plugin_pictureplayer.xml +++ b/lib/python/Plugins/Extensions/PicturePlayer/meta/plugin_pictureplayer.xml @@ -2,23 +2,14 @@ - + Dream Multimedia PicturePlayer enigma2-plugin-extensions-pictureplayer - PicturePlayer displays your photos on the TV. + Display your photos on the TV The PicturePlayer displays your photos on the TV.\nYou can view them as thumbnails or slideshow. - - Dream Multimedia - Bildbetrachter - enigma2-plugin-extensions-pictureplayer - Der Bildbetrachter zeigt Ihre Bilder auf dem Fernseher an. - Der Bildbetrachter zeigt Ihre Bilder auf dem Fernseher an.\nSie können sich Ihre Bilder als Thumbnails, einzeln oder als Slideshow anzeigen lassen. - - - diff --git a/lib/python/Plugins/Extensions/SocketMMI/meta/plugin_socketmmi.xml b/lib/python/Plugins/Extensions/SocketMMI/meta/plugin_socketmmi.xml old mode 100644 new mode 100755 index acf8374d..3eaf8fc5 --- a/lib/python/Plugins/Extensions/SocketMMI/meta/plugin_socketmmi.xml +++ b/lib/python/Plugins/Extensions/SocketMMI/meta/plugin_socketmmi.xml @@ -2,20 +2,13 @@ - + Dream Multimedia SocketMMI enigma2-plugin-extensions-socketmmi - Python frontend for /tmp/mmi.socket. + Frontend for /tmp/mmi.socket Python frontend for /tmp/mmi.socket. - - Dream Multimedia - SocketMMI - enigma2-plugin-extensions-socketmmi - Python frontend für /tmp/mmi.socket. - Python frontend für /tmp/mmi.socket. - diff --git a/lib/python/Plugins/Extensions/TuxboxPlugins/meta/plugin_tuxboxplugins.xml b/lib/python/Plugins/Extensions/TuxboxPlugins/meta/plugin_tuxboxplugins.xml old mode 100644 new mode 100755 index 734c48f1..7ca10826 --- a/lib/python/Plugins/Extensions/TuxboxPlugins/meta/plugin_tuxboxplugins.xml +++ b/lib/python/Plugins/Extensions/TuxboxPlugins/meta/plugin_tuxboxplugins.xml @@ -2,20 +2,13 @@ - + Dream Multimedia TuxboxPlugins TuxboxPlugins - Allows the execution of TuxboxPlugins. + Execute TuxboxPlugins Allows the execution of TuxboxPlugins. - - Dream Multimedia - TuxboxPlugins - enigma2-plugin-extensions-tuxboxplugins - Erlaubt das Ausführen von TuxboxPlugins. - Erlaubt das Ausführen von TuxboxPlugins. - diff --git a/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml b/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml index 99add3d3..d0781af4 100755 --- a/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml +++ b/lib/python/Plugins/SystemPlugins/CleanupWizard/meta/plugin_cleanupwizard.xml @@ -2,26 +2,16 @@ - + Dream Multimedia CleanupWizard enigma2-plugin-systemplugins-cleanupwizard Automatically informs you on low internal memory - The CleanupWizard informs you when your internal free memory of your dreambox has droppen under 2MB. - You can use this wizard to remove some extensions. - + The CleanupWizard informs you when the internal free memory of your dreambox has dropped below a definable threshold. + You can use this wizard to remove some plugins. - - Dream Multimedia - CleanupWizard - enigma2-plugin-systemplugins-cleanupwizard - Informiert Sie automatisch wenn der interne Speicher Ihrer Dreambox voll wird. - Der CleanupWizard informiert Sie, wenn der interne freie Speicher Ihrer Dreambox unter 2MB fällt. - Sie können dann einige Erweiterungen deinstallieren um wieder Platz zu schaffen. - - - + diff --git a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/meta/plugin_commoninterfaceassignment.xml b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/meta/plugin_commoninterfaceassignment.xml index 9abc5986..f34f0a3c 100755 --- a/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/meta/plugin_commoninterfaceassignment.xml +++ b/lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/meta/plugin_commoninterfaceassignment.xml @@ -4,28 +4,17 @@ - + Dream Multimedia CommonInterfaceAssignment enigma2-plugin-systemplugins-commoninterfaceassignment - Assigning providers/services/caids to a dedicated CI module - With the CommonInterfaceAssignment extension it is possible to use different CI modules - in your Dreambox and assign to each of them dedicated providers/services or caids.\n - So it is then possible to watch a scrambled service while recording another one. - - - - - Dream Multimedia - CommonInterfaceAssignment - enigma2-plugin-systemplugins-commoninterfaceassignment - Zuweisen von Providern/Services/CAIDs an ein CI Modul - Mit der CommonInterfaceAssignment Erweiterung ist es möglich jedem CI Modul bestimmte Provider/Services/CAIDs zuzuweisen.\n - So ist es möglich mit einem CI einen Sender aufzunehmen\n - und mit einem anderen einen Sender zu schauen. - + Assigning providers/services/caids to a CI module + With the CommonInterfaceAssignment plugin it is possible to use different + CI modules in your Dreambox and assign dedicated providers/services or caids to each of them.\n + This allows watching a scrambled service while recording another one. + diff --git a/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/meta/plugin_crashlogautosubmit.xml b/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/meta/plugin_crashlogautosubmit.xml index a118ed7f..3140b15f 100755 --- a/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/meta/plugin_crashlogautosubmit.xml +++ b/lib/python/Plugins/SystemPlugins/CrashlogAutoSubmit/meta/plugin_crashlogautosubmit.xml @@ -2,26 +2,17 @@ - + Dream Multimedia CrashlogAutoSubmit enigma2-plugin-systemplugins-crashlogautosubmit Automatically send crashlogs to Dream Multimedia - With the CrashlogAutoSubmit extension it is possible to automatically send crashlogs - found on your Harddrive to Dream Multimedia + With the CrashlogAutoSubmit plugin it is possible to automatically + mail crashlogs found on your hard drive to Dream Multimedia. - - Dream Multimedia - CrashlogAutoSubmit - enigma2-plugin-systemplugins-crashlogautosubmit - Automatisches versenden von Crashlogs an Dream Multimedia - Mit dem CrashlogAutoSubmit Plugin ist es möglich auf Ihrer Festplatte - gefundene Crashlogs automatisch an Dream Multimedia zu versenden. - - - + diff --git a/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/meta/plugin_defaultservicesscanner.xml b/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/meta/plugin_defaultservicesscanner.xml index 41d41ed6..74b7886f 100755 --- a/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/meta/plugin_defaultservicesscanner.xml +++ b/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/meta/plugin_defaultservicesscanner.xml @@ -1,26 +1,18 @@ - + Dream Multimedia DefaultServicesScanner enigma2-plugin-systemplugins-defaultservicesscanner - Scans default lamedbs sorted by satellite with a connected dish positioner. - With the DefaultServicesScanner extension you can scan default lamedbs sorted by satellite with a connected dish positioner. - - - - - Dream Multimedia - DefaultServicesScanner - enigma2-plugin-systemplugins-defaultservicesscanner - Standard Sendersuche nach Satellit mit einem Rotor. - Mit der DefaultServicesScanner Erweiterung können Sie eine standard Sendersuche nach Satellit mit einem angeschlossenen Rotor durchführen. + Scans default lamedbs sorted by satellite + With the DefaultServicesScanner plugin you can scan default lamedbs sorted by satellite with a connected dish positioner. + diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/meta/plugin_diseqctester.xml b/lib/python/Plugins/SystemPlugins/DiseqcTester/meta/plugin_diseqctester.xml index 33808b3e..567618b2 100755 --- a/lib/python/Plugins/SystemPlugins/DiseqcTester/meta/plugin_diseqctester.xml +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/meta/plugin_diseqctester.xml @@ -3,24 +3,16 @@ - + Dream Multimedia DiseqcTester enigma2-plugin-systemplugins-diseqctester - Test your Diseqc equipment. - With the DiseqcTester extension you can test your satellite equipment for Diseqc compatibility and errors. + Test your DiSEqC equipment + With the DiseqcTester plugin you can test your satellite equipment for DiSEqC compatibility and errors. - - Dream Multimedia - DiseqcTester - enigma2-plugin-systemplugins-diseqctester - Testet Ihr Diseqc Equipment. - Mit der DiseqcTester Erweiterung können Sie Ihr Satelliten-Equipment nach Diseqc-Kompatibilität und Fehlern überprüfen. - - - + diff --git a/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/meta/plugin_frontprocessorupgrade.xml b/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/meta/plugin_frontprocessorupgrade.xml old mode 100644 new mode 100755 index 1763f67f..7b6fdca7 --- a/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/meta/plugin_frontprocessorupgrade.xml +++ b/lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/meta/plugin_frontprocessorupgrade.xml @@ -3,24 +3,16 @@ - + Dream Multimedia FrontprocessorUpgrade enigma2-plugin-systemplugins-frontprocessorupgrade internal - Internal firmware updater. + Internal firmware updater This system tool is internally used to program the hardware with firmware updates. - - Dream Multimedia - FrontprocessorUpgrade - enigma2-plugin-systemplugins-frontprocessorupgrade - internal - Interner Firmware-Upgrader. - Dieses Systemtool wird intern benutzt um Firmware-Upgrades für die Hardware aufzuspielen. - - + diff --git a/lib/python/Plugins/SystemPlugins/Hotplug/meta/plugin_hotplug.xml b/lib/python/Plugins/SystemPlugins/Hotplug/meta/plugin_hotplug.xml old mode 100644 new mode 100755 index 6c2824ca..610dfee6 --- a/lib/python/Plugins/SystemPlugins/Hotplug/meta/plugin_hotplug.xml +++ b/lib/python/Plugins/SystemPlugins/Hotplug/meta/plugin_hotplug.xml @@ -2,22 +2,15 @@ - + Dream Multimedia Hotplug enigma2-plugin-systemplugins-hotplug - Hotplugging for removeable devices. - The Hotplug extension notifies your system of newly added or removed devices. - - - - Dream Multimedia - Hotplug - enigma2-plugin-systemplugins-hotplug - Hotplugging für entfernbare Geräte. - Mit der Hotplug-Erweiterung wird Ihr System über neu angeschlossene oder entfernte Geräte informiert. + Hotplugging for removeable devices + The Hotplug plugin notifies your system of newly added or removed devices. + diff --git a/lib/python/Plugins/SystemPlugins/NFIFlash/meta/plugin_nfiflash.xml b/lib/python/Plugins/SystemPlugins/NFIFlash/meta/plugin_nfiflash.xml index c81f4ca5..f93f5c5a 100755 --- a/lib/python/Plugins/SystemPlugins/NFIFlash/meta/plugin_nfiflash.xml +++ b/lib/python/Plugins/SystemPlugins/NFIFlash/meta/plugin_nfiflash.xml @@ -2,28 +2,18 @@ - - + Dream Multimedia NFIFlash enigma2-plugin-systemplugins-nfiflash - Restore your Dreambox with a USB stick. - With the NFIFlash extension it is possible to prepare a USB stick with an Dreambox image.\n + Restore your Dreambox with a USB stick + With the NFIFlash plugin it is possible to prepare a USB stick with an Dreambox image.\n It is then possible to flash your Dreambox with the image on that stick. - - Dream Multimedia - NFIFlash - enigma2-plugin-systemplugins-nfiflash - Wiederherstellen Ihrer Dreambox mittels USB-Stick. - Mit der NFIFlash Erweiterung können Sie ein Dreambox Image auf einen USB-Stick laden.\ - Mit diesem USB-Stick ist es dann möglich Ihre Dreambox zu flashen. - - - + diff --git a/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml b/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml index 4d3adcbd..423365f1 100755 --- a/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml +++ b/lib/python/Plugins/SystemPlugins/NetworkWizard/meta/plugin_networkwizard.xml @@ -1,26 +1,18 @@ + - + Dream Multimedia NetworkWizard enigma2-plugin-systemplugins-networkwizard Step by step network configuration - With the NetworkWizard you can easy configure your network step by step. + With the NetworkWizard you can easily configure your network step by step. - - Dream Multimedia - NetzwerkWizard - enigma2-plugin-systemplugins-networkwizard - Schritt für Schritt Netzwerk konfiguration - Mit dem NetzwerkWizard können Sie Ihr Netzwerk konfigurieren. Sie werden Schritt - für Schritt durch die Konfiguration geleitet. - - - + diff --git a/lib/python/Plugins/SystemPlugins/PositionerSetup/meta/plugin_positionersetup.xml b/lib/python/Plugins/SystemPlugins/PositionerSetup/meta/plugin_positionersetup.xml index 2cb47c07..5e1db7ba 100755 --- a/lib/python/Plugins/SystemPlugins/PositionerSetup/meta/plugin_positionersetup.xml +++ b/lib/python/Plugins/SystemPlugins/PositionerSetup/meta/plugin_positionersetup.xml @@ -3,25 +3,16 @@ - + Dream Multimedia PositionerSetup enigma2-plugin-systemplugins-positionersetup - PositionerSetup helps you installing a motorized dish. - With the PositionerSetup extension it is easy to install and configure a motorized dish. - - - - - Dream Multimedia - PositionerSetup - enigma2-plugin-systemplugins-positionersetup - Unterstützt Sie beim installieren eines Rotors. - Die PositionerSetup Erweiterung unterstützt Sie beim einrichten - und konfigurieren einer motorgesteuerten Satellitenantenne. + PositionerSetup helps you installing a motorized dish + With the PositionerSetup plugin it is easy to install and configure a motorized dish. + diff --git a/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/meta/plugin_satelliteequipmentcontrol.xml b/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/meta/plugin_satelliteequipmentcontrol.xml index 4c0c7af7..904f9a2e 100755 --- a/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/meta/plugin_satelliteequipmentcontrol.xml +++ b/lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/meta/plugin_satelliteequipmentcontrol.xml @@ -3,25 +3,17 @@ - + Dream Multimedia SatelliteEquipmentControl SatelliteEquipmentControl enigma2-plugin-systemplugins-satelliteequipmentcontrol - SatelliteEquipmentControl allows you to fine-tune DiSEqC-settings. - With the SatelliteEquipmentControl extension it is possible to fine-tune DiSEqC-settings. - - - - - Dream Multimedia - SatelliteEquipmentControl - enigma2-plugin-systemplugins-satelliteequipmentcontrol - Fein-Einstellungen für DiSEqC - Die SatelliteEquipmentControl-Erweiterung unterstützt Sie beim Feintuning der DiSEqC Einstellungen. + SatelliteEquipmentControl allows you to fine-tune DiSEqC-settings + With the SatelliteEquipmentControl plugin it is possible to fine-tune DiSEqC-settings. + diff --git a/lib/python/Plugins/SystemPlugins/Satfinder/meta/plugin_satfinder.xml b/lib/python/Plugins/SystemPlugins/Satfinder/meta/plugin_satfinder.xml index e9453deb..fe0c901e 100755 --- a/lib/python/Plugins/SystemPlugins/Satfinder/meta/plugin_satfinder.xml +++ b/lib/python/Plugins/SystemPlugins/Satfinder/meta/plugin_satfinder.xml @@ -1,28 +1,18 @@ - + - + Dream Multimedia Satfinder enigma2-plugin-systemplugins-satfinder - Satfinder helps you to align your dish. - The Satfinder extension helps you to align your dish.\n + Satfinder helps you to align your dish + The Satfinder plugin helps you to align your dish.\n It shows you informations about signal rate and errors. - - Dream Multimedia - Satfinder - enigma2-plugin-systemplugins-satfinder - Satfinder unterstützt Sie beim ausrichten ihrer Satellitenanlage. - Die Satfinder-Erweiterung unterstützt Sie beim Ausrichten ihrer Satellitenanlage.\n - Es zeigt Ihnen Daten wie Signalstärke und Fehlerrate an. - - - diff --git a/lib/python/Plugins/SystemPlugins/SkinSelector/meta/plugin_skinselector.xml b/lib/python/Plugins/SystemPlugins/SkinSelector/meta/plugin_skinselector.xml index 717f732b..73544a56 100755 --- a/lib/python/Plugins/SystemPlugins/SkinSelector/meta/plugin_skinselector.xml +++ b/lib/python/Plugins/SystemPlugins/SkinSelector/meta/plugin_skinselector.xml @@ -1,28 +1,19 @@ - + Dream Multimedia SkinSelector enigma2-plugin-systemplugins-skinselector - SkinSelector shows a menu with selectable skins. + SkinSelector shows a menu with selectable skins The SkinSelector shows a menu with selectable skins.\n It's now easy to change the look and feel of your Dreambox. - - Dream Multimedia - SkinSelector - enigma2-plugin-systemplugins-skinselector - Der SkinSelector zeigt Ihnen ein Menu mit auswählbaren Skins. - Die SkinSelector Erweiterung zeigt Ihnen ein Menu mit auswählbaren Skins.\n - Sie können nun einfach das Aussehen der grafischen Oberfläche Ihrer Dreambox verändern. - - - + diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py index a29a5e99..879bec16 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/SoftwareTools.py @@ -69,7 +69,7 @@ class SoftwareTools(DreamInfoHandler): else: self.ImageVersion = 'Stable' self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" - DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, neededTag = 'ALL_TAGS', neededFlag = self.ImageVersion, language = self.language) + DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, neededTag = 'ALL_TAGS', neededFlag = self.ImageVersion) self.directory = resolveFilename(SCOPE_METADIR) self.hardware_info = HardwareInfo() self.list = List([]) diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/meta/plugin_softwaremanager.xml b/lib/python/Plugins/SystemPlugins/SoftwareManager/meta/plugin_softwaremanager.xml index cd425c33..4135a212 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/meta/plugin_softwaremanager.xml +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/meta/plugin_softwaremanager.xml @@ -3,27 +3,17 @@ - + Dream Multimedia SoftwareManager enigma2-plugin-systemplugins-softwaremanager - SoftwareManager manages your Dreambox software. + SoftwareManager manages your Dreambox software The SoftwareManager manages your Dreambox software.\n - It's easy to update your receiver's software, install or remove extensions or even backup and restore your system settings. + It's easy to update your receiver's software, install or remove plugins or even backup and restore your system settings. - - Dream Multimedia - SoftwareManager - enigma2-plugin-systemplugins-softwaremanager - Der SoftwareManager verwaltet Ihre Dreambox Software. - Der SoftwareManager verwaltet Ihre Dreambox Software.\n - Sie können nun einfach Ihre Dreambox-Software aktualisieren, neue Erweiterungen installieren oder entfernen, - oder ihre Einstellungen sichern und wiederherstellen. - - - + diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py index 99837678..0cc57776 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/plugin.py @@ -789,13 +789,13 @@ class PluginManager(Screen, DreamInfoHandler): status = "remove" else: status = "installed" - self.list.append(self.buildEntryComponent(name, details, description, packagename, status, selected = selectState)) + self.list.append(self.buildEntryComponent(name, _(details), _(description), packagename, status, selected = selectState)) else: if selectState == True: status = "install" else: status = "installable" - self.list.append(self.buildEntryComponent(name, details, description, packagename, status, selected = selectState)) + self.list.append(self.buildEntryComponent(name, _(details), _(description), packagename, status, selected = selectState)) if len(self.list): self.list.sort(key=lambda x: x[0]) self["list"].style = "default" @@ -1104,8 +1104,7 @@ class PluginDetails(Screen, DreamInfoHandler): self.skin_path = plugin_path self.language = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country" self.attributes = None - self.translatedAttributes = None - DreamInfoHandler.__init__(self, self.statusCallback, blocking = False, language = self.language) + DreamInfoHandler.__init__(self, self.statusCallback, blocking = False) self.directory = resolveFilename(SCOPE_METADIR) if packagedata: self.pluginname = packagedata[0] @@ -1143,8 +1142,6 @@ class PluginDetails(Screen, DreamInfoHandler): self.package = self.packageDetails[0] if self.package[0].has_key("attributes"): self.attributes = self.package[0]["attributes"] - if self.package[0].has_key("translation"): - self.translatedAttributes = self.package[0]["translation"] self.cmdList = [] self.oktext = _("\nAfter pressing OK, please wait!") @@ -1154,7 +1151,7 @@ class PluginDetails(Screen, DreamInfoHandler): self.onLayoutFinish.append(self.setInfos) def setWindowTitle(self): - self.setTitle(_("Details for extension: " + self.pluginname)) + self.setTitle(_("Details for plugin: ") + self.pluginname ) def exit(self): self.close(False) @@ -1169,34 +1166,26 @@ class PluginDetails(Screen, DreamInfoHandler): pass def setInfos(self): - if self.translatedAttributes.has_key("name"): - self.pluginname = self.translatedAttributes["name"] - elif self.attributes.has_key("name"): + if self.attributes.has_key("screenshot"): + self.loadThumbnail(self.attributes) + + if self.attributes.has_key("name"): self.pluginname = self.attributes["name"] else: self.pluginname = _("unknown") - if self.translatedAttributes.has_key("author"): - self.author = self.translatedAttributes["author"] - elif self.attributes.has_key("author"): + if self.attributes.has_key("author"): self.author = self.attributes["author"] else: self.author = _("unknown") - if self.translatedAttributes.has_key("description"): - self.description = self.translatedAttributes["description"] - elif self.attributes.has_key("description"): - self.description = self.attributes["description"] + if self.attributes.has_key("description"): + self.description = _(self.attributes["description"].replace("\\n", "\n")) else: self.description = _("No description available.") - if self.translatedAttributes.has_key("screenshot"): - self.loadThumbnail(self.translatedAttributes) - else: - self.loadThumbnail(self.attributes) - self["author"].setText(_("Author: ") + self.author) - self["detailtext"].setText(self.description.strip()) + self["detailtext"].setText(_(self.description)) if self.pluginstate in ('installable', 'install'): self["key_green"].setText(_("Install")) else: @@ -1206,6 +1195,10 @@ class PluginDetails(Screen, DreamInfoHandler): thumbnailUrl = None if entry.has_key("screenshot"): thumbnailUrl = entry["screenshot"] + if self.language == "de": + if thumbnailUrl[-7:] == "_en.jpg": + thumbnailUrl = thumbnailUrl[:-7] + "_de.jpg" + if thumbnailUrl is not None: self.thumbnail = "/tmp/" + thumbnailUrl.split('/')[-1] print "[PluginDetails] downloading screenshot " + thumbnailUrl + " to " + self.thumbnail diff --git a/lib/python/Plugins/SystemPlugins/TempFanControl/LICENSE b/lib/python/Plugins/SystemPlugins/TempFanControl/LICENSE new file mode 100755 index 00000000..99700593 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/TempFanControl/LICENSE @@ -0,0 +1,12 @@ +This plugin is licensed under the Creative Commons +Attribution-NonCommercial-ShareAlike 3.0 Unported +License. To view a copy of this license, visit +http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative +Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. + +Alternatively, this plugin may be distributed and executed on hardware which +is licensed by Dream Multimedia GmbH. + +This plugin is NOT free software. It is open source, you are allowed to +modify it (if you keep the license), but it may not be commercially +distributed other than under the conditions noted above. diff --git a/lib/python/Plugins/SystemPlugins/TempFanControl/Makefile.am b/lib/python/Plugins/SystemPlugins/TempFanControl/Makefile.am old mode 100644 new mode 100755 index 78ff11c3..cfdeb654 --- a/lib/python/Plugins/SystemPlugins/TempFanControl/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/TempFanControl/Makefile.am @@ -1,5 +1,9 @@ installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/TempFanControl +SUBDIRS = meta + install_PYTHON = \ __init__.py \ plugin.py + +dist_install_DATA = LICENSE \ No newline at end of file diff --git a/lib/python/Plugins/SystemPlugins/TempFanControl/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/TempFanControl/meta/Makefile.am new file mode 100755 index 00000000..da7be245 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/TempFanControl/meta/Makefile.am @@ -0,0 +1,3 @@ +installdir = $(datadir)/meta + +dist_install_DATA = plugin_tempfancontrol.xml diff --git a/lib/python/Plugins/SystemPlugins/TempFanControl/meta/plugin_tempfancontrol.xml b/lib/python/Plugins/SystemPlugins/TempFanControl/meta/plugin_tempfancontrol.xml new file mode 100755 index 00000000..a0bb5fa5 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/TempFanControl/meta/plugin_tempfancontrol.xml @@ -0,0 +1,18 @@ + + + + + + + + Dream Multimedia + TempFanControl + enigma2-plugin-systemplugins-tempfancontrol + Control your system fan + Control your internal system fan. + + + + + + diff --git a/lib/python/Plugins/SystemPlugins/VideoEnhancement/meta/plugin_videoenhancement.xml b/lib/python/Plugins/SystemPlugins/VideoEnhancement/meta/plugin_videoenhancement.xml index 208c7e0c..11b0c59f 100755 --- a/lib/python/Plugins/SystemPlugins/VideoEnhancement/meta/plugin_videoenhancement.xml +++ b/lib/python/Plugins/SystemPlugins/VideoEnhancement/meta/plugin_videoenhancement.xml @@ -6,22 +6,14 @@ - + Dream Multimedia VideoEnhancement enigma2-plugin-systemplugins-videoenhancement - VideoEnhancement provides advanced video enhancement settings. - The VideoEnhancement extension provides advanced video enhancement settings. + VideoEnhancement provides advanced video enhancement settings + The VideoEnhancement plugin provides advanced video enhancement settings. - - Dream Multimedia - Erweiterte A/V Einstellungen - enigma2-plugin-systemplugins-videoenhancement - Erweiterte A/V Einstellungen für Ihre Dreambox. - Erweiterte A/V Einstellungen für Ihre Dreambox. - - diff --git a/lib/python/Plugins/SystemPlugins/VideoTune/meta/plugin_videotune.xml b/lib/python/Plugins/SystemPlugins/VideoTune/meta/plugin_videotune.xml index c4609433..78b170ac 100755 --- a/lib/python/Plugins/SystemPlugins/VideoTune/meta/plugin_videotune.xml +++ b/lib/python/Plugins/SystemPlugins/VideoTune/meta/plugin_videotune.xml @@ -3,23 +3,14 @@ - + Dream Multimedia VideoTune enigma2-plugin-systemplugins-videotune - VideoTune helps fine-tuning your tv display. + VideoTune helps fine-tuning your tv display The VideoTune helps fine-tuning your tv display.\nYou can control brightness and contrast of your tv. - - Dream Multimedia - DE - VideoTune - DE - enigma2-plugin-systemplugins-videotune - VideoTune hilft beim fein-einstellen des Fernsehers. - VideoTune hilf beim fein-einstellen des Fernsehers.\nSie können Kontrast und Helligkeit fein-einstellen. - - - diff --git a/lib/python/Plugins/SystemPlugins/Videomode/meta/plugin_videomode.xml b/lib/python/Plugins/SystemPlugins/Videomode/meta/plugin_videomode.xml index fbb6e3f4..e16a7dc8 100755 --- a/lib/python/Plugins/SystemPlugins/Videomode/meta/plugin_videomode.xml +++ b/lib/python/Plugins/SystemPlugins/Videomode/meta/plugin_videomode.xml @@ -3,22 +3,14 @@ - + Dream Multimedia Videomode enigma2-plugin-systemplugins-videomode - Videomode provides advanced video modes. - The Videomode extension provides advanced video modes. + Videomode provides advanced video mode settings + The Videomode plugin provides advanced video mode settings. - - Dream Multimedia - Videomode - enigma2-plugin-systemplugins-videomode - Videomode bietet erweiterte Video Einstellungen. - Die Videomode-Erweiterung bietet erweiterte Video-Einstellungen. - - diff --git a/lib/python/Plugins/SystemPlugins/WirelessLan/meta/plugin_wirelesslan.xml b/lib/python/Plugins/SystemPlugins/WirelessLan/meta/plugin_wirelesslan.xml index 1f882b32..eca6c0f9 100755 --- a/lib/python/Plugins/SystemPlugins/WirelessLan/meta/plugin_wirelesslan.xml +++ b/lib/python/Plugins/SystemPlugins/WirelessLan/meta/plugin_wirelesslan.xml @@ -3,22 +3,14 @@ - + Dream Multimedia WirelessLan enigma2-plugin-systemplugins-wirelesslan Configure your WLAN network interface - The WirelessLan extensions helps you configuring your WLAN network interface. + The WirelessLan plugin helps you configuring your WLAN network interface. - - Dream Multimedia - WirelessLan - enigma2-plugin-systemplugins-wirelesslan - Konfigurieren Sie Ihr WLAN Netzwerk. - Die WirelessLan Erweiterung hilft Ihnen beim konfigurieren Ihres WLAN Netzwerkes.. - - diff --git a/tools/genmetaindex.py b/tools/genmetaindex.py index f7dc5b98..f42cefc2 100755 --- a/tools/genmetaindex.py +++ b/tools/genmetaindex.py @@ -1,25 +1,23 @@ -# usage: genmetaindex.py > index.xml +# usage: genmetaindex.py > index.xml import sys, os from xml.etree.ElementTree import ElementTree, Element -language = sys.argv[1] - root = Element("index") -for file in sys.argv[2:]: +for file in sys.argv[1:]: p = ElementTree() p.parse(file) package = Element("package") package.set("details", os.path.basename(file)) - # we need all prerequisuited + # we need all prerequisites package.append(p.find("prerequisites")) info = None - # we need some of the info, but only our locale + # we need some of the info, but not all for i in p.findall("info"): - if not info or i.get("language") == language: + if not info: info = i assert info -- cgit v1.2.3