WirelessLanSetup : fix skin for 750S
[vuplus_dvbapp] / lib / python / Plugins / Extensions / WebBrowser / plugin.py
index d4bf7b1..7626007 100644 (file)
@@ -19,6 +19,7 @@ from httplib import HTTPConnection, CannotSendRequest, BadStatusLine, HTTPExcept
 from Components.Button import Button
 from Components.Label import Label
 from Components.Pixmap import Pixmap
 from Components.Button import Button
 from Components.Label import Label
 from Components.Pixmap import Pixmap
+from Components.Language import language
 from Components.Sources.List import List
 from Components.ConfigList import ConfigListScreen
 from Components.Sources.StaticText import StaticText
 from Components.Sources.List import List
 from Components.ConfigList import ConfigListScreen
 from Components.Sources.StaticText import StaticText
@@ -365,7 +366,7 @@ class VuPlayerService:
                        if len(tmp) == 2 and tmp[0] == "http://www.youtube.com/watch":
                                tmp = tmp[1].split("&")
                                print tmp # ['v=BpThu778qB4', 'feature=related']
                        if len(tmp) == 2 and tmp[0] == "http://www.youtube.com/watch":
                                tmp = tmp[1].split("&")
                                print tmp # ['v=BpThu778qB4', 'feature=related']
-                               if len(tmp) == 2:
+                               if len(tmp) > 2:
                                        tmp = tmp[0].split("=")
                                        print tmp # ['v', 'BpThu778qB4']
                                        if len(tmp) == 2 and tmp[0] == "v":
                                        tmp = tmp[0].split("=")
                                        print tmp # ['v', 'BpThu778qB4']
                                        if len(tmp) == 2 and tmp[0] == "v":
@@ -404,15 +405,16 @@ class VuPlayerService:
 
 class BrowserLauncher(ConfigListScreen, Screen):
        skin=   """
 
 class BrowserLauncher(ConfigListScreen, Screen):
        skin=   """
-               <screen name="BrowserLauncher" position="center,center" size="309,478" title="Web Browser">
+               <screen name="BrowserLauncher" position="center,center" size="309,498" title="Web Browser">
                        <ePixmap pixmap="Vu_HD/buttons/red.png" position="4,0" size="40,40" alphatest="on" />
                        <ePixmap pixmap="Vu_HD/buttons/red.png" position="4,0" size="40,40" alphatest="on" />
-                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="100,0" size="40,40" alphatest="on" />
-                       <ePixmap pixmap="Vu_HD/buttons/button_off.png" position="200,0" size="40,40" alphatest="on" />
-                       <widget source="key_red" render="Label" position="15,0" zPosition="1" size="50,30" font="Regular;20" halign="right" valign="center" transparent="1" />
-                       <widget source="key_green" render="Label" position="120,0" zPosition="1" size="50,30" font="Regular;20" halign="right" valign="center" transparent="1" />
-                       <widget name="config" position="0,50" size="309,80" scrollbarMode="showOnDemand" />
-                       <ePixmap pixmap="Vu_HD/rc_wb_desc.png" position="0,130" size="309,296" alphatest="on" />
-                       <widget name="info" position="0,435" size="309,50" font="Regular;18" halign="center" foregroundColor="blue" transparent="1" />
+                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="154,0" size="40,40" alphatest="on" />
+
+                       <widget source="key_red" render="Label" position="30,0" zPosition="1" size="125,30" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget source="key_green" render="Label" position="180,0" zPosition="1" size="125,30" font="Regular;20" halign="center" valign="center" transparent="1" />
+
+                       <widget name="config" position="0,50" size="309,100" scrollbarMode="showOnDemand" />
+                       <ePixmap pixmap="Vu_HD/rc_wb_desc.png" position="0,150" size="309,296" alphatest="on" />
+                       <widget name="info" position="0,455" size="309,50" font="Regular;18" halign="center" foregroundColor="blue" transparent="1" />
                </screen>
                """
 
                </screen>
                """
 
@@ -424,7 +426,9 @@ class BrowserLauncher(ConfigListScreen, Screen):
 
                self.browser_root = "/usr/bin"
                self.browser_name = "arora"
 
                self.browser_root = "/usr/bin"
                self.browser_name = "arora"
-               self.conf_file = "/usr/lib/enigma2/python/Plugins/Extensions/WebBrowser/settings.conf"
+
+               from Tools.Directories import resolveFilename, SCOPE_PLUGINS
+               self.conf_file = resolveFilename(SCOPE_PLUGINS, "Extensions/WebBrowser/settings.conf")
                self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
                 {      "red": self.keyCancel,
                        "green": self.keyGo,
                self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
                 {      "red": self.keyCancel,
                        "green": self.keyGo,
@@ -438,6 +442,7 @@ class BrowserLauncher(ConfigListScreen, Screen):
                self.conf_alpha = ""
                self.conf_mouse = ""
                self.conf_keyboard = ""
                self.conf_alpha = ""
                self.conf_mouse = ""
                self.conf_keyboard = ""
+               self.conf_keymap = ""
 
                self.usb_mouse = None
                self.usb_keyboard = None
 
                self.usb_mouse = None
                self.usb_keyboard = None
@@ -456,6 +461,7 @@ class BrowserLauncher(ConfigListScreen, Screen):
                self.timer_exit_cond.callback.append(self.resetExitCond)
 
                self.test_cond = True
                self.timer_exit_cond.callback.append(self.resetExitCond)
 
                self.test_cond = True
+               self.current_lang_idx = language.getActiveLanguageIndex()
 
        def keyNone(self):
                None
 
        def keyNone(self):
                None
@@ -467,6 +473,7 @@ class BrowserLauncher(ConfigListScreen, Screen):
                excute_cmd("killall -15 %s"%(self.browser_name))
                excute_cmd("echo 60 > /proc/sys/vm/swappiness")
                enable_rc_mouse(False) #rc-mouse off
                excute_cmd("killall -15 %s"%(self.browser_name))
                excute_cmd("echo 60 > /proc/sys/vm/swappiness")
                enable_rc_mouse(False) #rc-mouse off
+               language.activateLanguageIndex(self.current_lang_idx)
                fbClass.getInstance().unlock()
                #eRCInput.getInstance().unlock()
                self.close()
                fbClass.getInstance().unlock()
                #eRCInput.getInstance().unlock()
                self.close()
@@ -499,7 +506,7 @@ class BrowserLauncher(ConfigListScreen, Screen):
        # mouse:keyboard:alpha_value
        def saveConfig(self):
                if is_process_running(self.browser_name) == False:
        # mouse:keyboard:alpha_value
        def saveConfig(self):
                if is_process_running(self.browser_name) == False:
-                       command = "echo \"%s:%s:%d\" > %s"%(self.mouse.value, self.keyboard.value, int(self.alpha.value), self.conf_file)
+                       command = "echo \"%s:%s:%d:%s\" > %s"%(self.mouse.value, self.keyboard.value, int(self.alpha.value), self.langs.value, self.conf_file)
                        excute_cmd(command)
 
        # mouse:keyboard:alpha_value
                        excute_cmd(command)
 
        # mouse:keyboard:alpha_value
@@ -511,6 +518,11 @@ class BrowserLauncher(ConfigListScreen, Screen):
                        self.conf_mouse         = config_list[0]
                        self.conf_keyboard      = config_list[1]
                        self.conf_alpha         = config_list[2]
                        self.conf_mouse         = config_list[0]
                        self.conf_keyboard      = config_list[1]
                        self.conf_alpha         = config_list[2]
+               elif len(config_list) == 4:
+                       self.conf_mouse         = config_list[0]
+                       self.conf_keyboard      = config_list[1]
+                       self.conf_alpha         = config_list[2]
+                       self.conf_keymap        = config_list[3]
                print "load config : ", config_list
 
        def resetExitCond(self):
                print "load config : ", config_list
 
        def resetExitCond(self):
@@ -537,22 +549,32 @@ class BrowserLauncher(ConfigListScreen, Screen):
 
                if self.conf_mouse == "" or self.getHandlerName(self.conf_mouse) is None:
                        self.conf_mouse = self.mouse_list[0][0]
 
                if self.conf_mouse == "" or self.getHandlerName(self.conf_mouse) is None:
                        self.conf_mouse = self.mouse_list[0][0]
+               self.mouse = ConfigSelection(default = self.conf_mouse, choices = self.mouse_list)
+               self.list.append(getConfigListEntry(_('Mouse'), self.mouse))            
+               
                if self.conf_keyboard == "" or self.getHandlerName(self.conf_keyboard) is None:
                        self.conf_keyboard = self.keyboard_list[0][0]
                if self.conf_keyboard == "" or self.getHandlerName(self.conf_keyboard) is None:
                        self.conf_keyboard = self.keyboard_list[0][0]
-               if self.conf_alpha == "":
-                       self.conf_alpha = "255"
+               self.keyboard = ConfigSelection(default = self.conf_keyboard, choices = self.keyboard_list)
+               self.list.append(getConfigListEntry(_('Keyboard'), self.keyboard))
 
 
-               self.mouse      = ConfigSelection(default = self.conf_mouse, choices = self.mouse_list)
-               self.keyboard   = ConfigSelection(default = self.conf_keyboard, choices = self.keyboard_list)
-               self.alpha      = ConfigSlider(default = int(self.conf_alpha), increment = 10, limits = (0, 255))
+               if self.conf_keymap == "":
+                       self.conf_keymap = self.getLanguage()
+               self.lang_list = [("rc_en", "English(RC)"), ("rc_ch", "German(RC)"), ("en", "English"), ("ch", "German")]
+               self.langs = ConfigSelection(default = self.conf_keymap, choices = self.lang_list)
+               self.list.append(getConfigListEntry(_("    - Type"), self.langs))
 
 
-               self.list.append(getConfigListEntry(_('Mouse'), self.mouse))            
-               self.list.append(getConfigListEntry(_('Keyboard'), self.keyboard))
+               if self.conf_alpha == "":
+                       self.conf_alpha = "255"
+               self.alpha = ConfigSlider(default = int(self.conf_alpha), increment = 10, limits = (0, 255))
                self.list.append(getConfigListEntry(_("Alpha Value"), self.alpha))
                self.list.append(getConfigListEntry(_("Alpha Value"), self.alpha))
-
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
+       def getLanguage(self, lang=language.getLanguage()):
+               if self.current_lang_idx == 1:
+                       return "rc_ch"
+               return "rc_en"
+
        def makeHandlerList(self, data):
                n = ""
                p = ""
        def makeHandlerList(self, data):
                n = ""
                p = ""
@@ -578,26 +600,28 @@ class BrowserLauncher(ConfigListScreen, Screen):
                                                event_list.append((h, _(h)))
                                                self.name_list.append((h, n))
                                                if n[1:].startswith("dream") and self.rc_mouse is None:
                                                event_list.append((h, _(h)))
                                                self.name_list.append((h, n))
                                                if n[1:].startswith("dream") and self.rc_mouse is None:
-                                                       self.rc_mouse = copy.deepcopy(h)
-                                                       self.rc_keyboard = copy.deepcopy(h)
-                                                       print "detected!! rc"
+                                                       for thl in h.split(" "):
+                                                               if thl.startswith("event"):
+                                                                       self.rc_mouse = copy.deepcopy(h)
+                                                                       self.rc_keyboard = copy.deepcopy(h)
+                                                                       print "detected!! rc:", h
                                                        continue
                                                if h.startswith("mouse") and self.usb_mouse is None:
                                                        self.usb_mouse = copy.deepcopy(h)
                                                        continue
                                                if h.startswith("mouse") and self.usb_mouse is None:
                                                        self.usb_mouse = copy.deepcopy(h)
-                                                       print "detected!! usb mouse"
+                                                       print "detected!! usb mouse:",h
                                                        continue
                                                if tn == -1 and self.usb_keyboard is None:
                                                        self.usb_keyboard = copy.deepcopy(h)
                                                        continue
                                                if tn == -1 and self.usb_keyboard is None:
                                                        self.usb_keyboard = copy.deepcopy(h)
-                                                       print "detected!! usb keyboard"
+                                                       print "detected!! usb keyboard:",h
                                elif line[0] == 'B' and line[3:].startswith("ABS") and p.startswith("usb-"):
                                        for h in h_list:
                                                if self.usb_mouse is not None:
                                                        break
                                                if self.usb_keyboard is not None and h == self.usb_keyboard[0]:
                                                        self.usb_keyboard = None
                                elif line[0] == 'B' and line[3:].startswith("ABS") and p.startswith("usb-"):
                                        for h in h_list:
                                                if self.usb_mouse is not None:
                                                        break
                                                if self.usb_keyboard is not None and h == self.usb_keyboard[0]:
                                                        self.usb_keyboard = None
-                                                       print "clean!! usb keyboard"
+                                                       print "clean!! usb keyboard:",h
                                                self.usb_mouse = copy.deepcopy(h)
                                                self.usb_mouse = copy.deepcopy(h)
-                                               print "detected!! usb mouse"
+                                               print "detected!! usb mouse:",h
 
                tmp = copy.deepcopy(event_list)
                if self.usb_mouse is not None:
 
                tmp = copy.deepcopy(event_list)
                if self.usb_mouse is not None:
@@ -625,7 +649,7 @@ class BrowserLauncher(ConfigListScreen, Screen):
 
                kbd_cmd = " "
                mouse_cmd = " "
 
                kbd_cmd = " "
                mouse_cmd = " "
-               extra_cmd = " " 
+               extra_cmd = "export VU_DOWNLOAD_DIR=/tmp; " 
                browser_cmd = "%s/%s -qws" % (self.browser_root, self.browser_name)
 
                mouse_param = self.mouse.value
                browser_cmd = "%s/%s -qws" % (self.browser_root, self.browser_name)
 
                mouse_param = self.mouse.value
@@ -643,7 +667,16 @@ class BrowserLauncher(ConfigListScreen, Screen):
                        enable_rc_mouse(True) #rc-mouse on
                if str(mouse_param).startswith("event"):
                        mouse_cmd = "export QWS_MOUSE_PROTO=LinuxInput:/dev/input/%s; " % (str(mouse_param))
                        enable_rc_mouse(True) #rc-mouse on
                if str(mouse_param).startswith("event"):
                        mouse_cmd = "export QWS_MOUSE_PROTO=LinuxInput:/dev/input/%s; " % (str(mouse_param))
-               kbd_cmd = "export QWS_KEYBOARD=LinuxInput:/dev/input/%s; " % (str(keyboard_param))
+
+               keymap_param = ""
+               if self.langs.value == "ch":
+                       keymap_param = ":keymap=/usr/share/keymaps/vuplus/ch.qmap"
+               elif self.langs.value == "rc_ch":
+                       keymap_param = ":keymap=/usr/share/keymaps/vuplus/de.qmap"
+               elif self.langs.value == "rc_en":
+                       keymap_param = ":keymap=/usr/share/keymaps/vuplus/us.qmap"
+
+               kbd_cmd = "export QWS_KEYBOARD=LinuxInput:/dev/input/%s%s; " % (str(keyboard_param), keymap_param)
 
                cmd = "%s%s%s%s" % (extra_cmd, kbd_cmd, mouse_cmd, browser_cmd)
                print "prepared command : [%s]" % cmd
 
                cmd = "%s%s%s%s" % (extra_cmd, kbd_cmd, mouse_cmd, browser_cmd)
                print "prepared command : [%s]" % cmd
@@ -666,6 +699,10 @@ class BrowserLauncher(ConfigListScreen, Screen):
                self.saveConfig()
                self.info.setText("Starting Webbrowser. Please wait...")
                if self.lock == False:
                self.saveConfig()
                self.info.setText("Starting Webbrowser. Please wait...")
                if self.lock == False:
+                       if self.langs.value == "ch" or self.langs.value == "rc_ch":
+                               language.activateLanguageIndex(1)
+                       else:
+                               language.activateLanguageIndex(0)
                        self.timer_start = eTimer()
                        self.timer_start.callback.append(self.startBrowser)
                        self.timer_start.start(10)
                        self.timer_start = eTimer()
                        self.timer_start.callback.append(self.startBrowser)
                        self.timer_start.start(10)
@@ -706,4 +743,3 @@ def Plugins(**kwargs):
                PluginDescriptor(name=_("Web Browser"), description="start web browser", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)]
 
 
                PluginDescriptor(name=_("Web Browser"), description="start web browser", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)]
 
 
-