Merge branch 'vuplus_experimental' of /opt/repository/enigma2 into vuplus_experimental
authorChang.H.S <jhs@dev3>
Wed, 5 Oct 2011 10:25:52 +0000 (19:25 +0900)
committerChang.H.S <jhs@dev3>
Wed, 5 Oct 2011 10:25:52 +0000 (19:25 +0900)
23 files changed:
configure.ac
lib/python/Plugins/Extensions/Makefile.am
lib/python/Plugins/Extensions/WebBrowser/Makefile.am [new file with mode: 0755]
lib/python/Plugins/Extensions/WebBrowser/__init__.py [new file with mode: 0644]
lib/python/Plugins/Extensions/WebBrowser/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/Extensions/WebBrowser/meta/plugin_webbrowser.xml [new file with mode: 0755]
lib/python/Plugins/Extensions/WebBrowser/plugin.py [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/Makefile.am
lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/RemoteControlCode/__init__.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/plugin_remotecontrolcode.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/RemoteControlCode/plugin.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UI3DSetup/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UI3DSetup/__init__.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UI3DSetup/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UI3DSetup/meta/plugin_ui3dsetup.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UI3DSetup/plugin.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UIPositionSetup/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UIPositionSetup/__init__.py [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/plugin_uipositionsetup.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/UIPositionSetup/plugin.py [new file with mode: 0755]

index 27beb1e..ac69b2a 100644 (file)
@@ -161,6 +161,8 @@ lib/python/Plugins/Extensions/SocketMMI/meta/Makefile
 lib/python/Plugins/Extensions/SocketMMI/src/Makefile
 lib/python/Plugins/Extensions/TuxboxPlugins/Makefile
 lib/python/Plugins/Extensions/TuxboxPlugins/meta/Makefile
+lib/python/Plugins/Extensions/WebBrowser/Makefile
+lib/python/Plugins/Extensions/WebBrowser/meta/Makefile
 lib/python/Plugins/SystemPlugins/CleanupWizard/Makefile
 lib/python/Plugins/SystemPlugins/CleanupWizard/meta/Makefile
 lib/python/Plugins/SystemPlugins/CommonInterfaceAssignment/Makefile
@@ -211,6 +213,12 @@ lib/python/Plugins/SystemPlugins/ManualFancontrol/Makefile
 lib/python/Plugins/SystemPlugins/ManualFancontrol/meta/Makefile
 lib/python/Plugins/SystemPlugins/Blindscan/Makefile
 lib/python/Plugins/SystemPlugins/Blindscan/meta/Makefile
+lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile
+lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile
+lib/python/Plugins/SystemPlugins/UI3DSetup/Makefile
+lib/python/Plugins/SystemPlugins/UI3DSetup/meta/Makefile
+lib/python/Plugins/SystemPlugins/UIPositionSetup/Makefile
+lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/Makefile
 lib/python/Tools/Makefile
 lib/service/Makefile
 lib/components/Makefile
index 7a3a9be..85d3872 100755 (executable)
@@ -1,6 +1,6 @@
 installdir = $(pkglibdir)/python/Plugins/Extensions
 
-SUBDIRS = TuxboxPlugins CutListEditor PicturePlayer MediaScanner MediaPlayer GraphMultiEPG SocketMMI DVDBurn Modem
+SUBDIRS = TuxboxPlugins CutListEditor PicturePlayer MediaScanner MediaPlayer GraphMultiEPG SocketMMI DVDBurn Modem WebBrowser 
 
 if HAVE_LIBDDVD
 SUBDIRS += DVDPlayer
diff --git a/lib/python/Plugins/Extensions/WebBrowser/Makefile.am b/lib/python/Plugins/Extensions/WebBrowser/Makefile.am
new file mode 100755 (executable)
index 0000000..82d426a
--- /dev/null
@@ -0,0 +1,8 @@
+installdir = $(pkglibdir)/python/Plugins/Extensions/WebBrowser
+
+SUBDIRS = meta
+
+install_PYTHON =        \
+       __init__.py \
+       plugin.py 
+
diff --git a/lib/python/Plugins/Extensions/WebBrowser/__init__.py b/lib/python/Plugins/Extensions/WebBrowser/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/python/Plugins/Extensions/WebBrowser/meta/Makefile.am b/lib/python/Plugins/Extensions/WebBrowser/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..2be2e3d
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_webbrowser.xml
diff --git a/lib/python/Plugins/Extensions/WebBrowser/meta/plugin_webbrowser.xml b/lib/python/Plugins/Extensions/WebBrowser/meta/plugin_webbrowser.xml
new file mode 100755 (executable)
index 0000000..7c81d17
--- /dev/null
@@ -0,0 +1,26 @@
+<default>
+         <prerequisites>
+                    <tag type="Network" />
+         </prerequisites>
+          <info>
+                    <author>kos</author>
+                    <name>WebBrowser</name>
+                    <packagename>enigma2-plugin-extensions-webbrowser</packagename>
+                    <shortdescription>webbrowser launcher</shortdescription>
+                    <description>webbrowser launcher</description>
+          </info>
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-extensions-webbrowser" />
+                <file type="package" name="python-gdata" />
+                <file type="package" name="libqtwebkite4" />
+                <file type="package" name="vuplus-webbrowser-utils" />
+                <file type="package" name="qt4-embedded-fonts" />
+                <file type="package" name="qt4-embedded-plugin-imageformat-gif" />
+                <file type="package" name="qt4-embedded-plugin-imageformat-ico" /> 
+                <file type="package" name="qt4-embedded-plugin-imageformat-jpeg" />
+                <file type="package" name="qt4-embedded-plugin-imageformat-mng" />
+                <file type="package" name="qt4-embedded-plugin-imageformat-svg" />
+                <file type="package" name="qt4-embedded-plugin-imageformat-tiff" />
+                <file type="package" name="qt4-embedded-plugin-iconengine-svgicon" />
+         </files>
+</default>
diff --git a/lib/python/Plugins/Extensions/WebBrowser/plugin.py b/lib/python/Plugins/Extensions/WebBrowser/plugin.py
new file mode 100644 (file)
index 0000000..5e041b9
--- /dev/null
@@ -0,0 +1,631 @@
+from Plugins.Plugin import PluginDescriptor
+
+import time, os, socket, thread, socket
+from socket import gaierror, error
+from os import path as os_path, remove as os_remove
+
+import gdata.youtube
+import gdata.youtube.service
+from gdata.service import BadAuthentication
+
+from twisted.web import client
+from twisted.internet import reactor
+
+from urlparse import parse_qs
+from urllib import quote, unquote_plus, unquote
+from urllib2 import Request, URLError, urlopen as urlopen2
+from httplib import HTTPConnection, CannotSendRequest, BadStatusLine, HTTPException
+
+from Components.Button import Button
+from Components.Label import Label
+from Components.Pixmap import Pixmap
+from Components.Sources.List import List
+from Components.ConfigList import ConfigListScreen
+from Components.Sources.StaticText import StaticText
+from Components.ActionMap import NumberActionMap, ActionMap
+from Components.ServiceEventTracker import ServiceEventTracker
+from Components.config import config, ConfigSelection, getConfigListEntry
+
+from Screens.Screen import Screen
+from Screens.ChoiceBox import ChoiceBox
+from Screens.MessageBox import MessageBox
+from Screens.DefaultWizard import DefaultWizard
+from Screens.InfoBarGenerics import InfoBarNotifications
+
+from enigma import eTimer, eServiceReference, iPlayableService, fbClass, eRCInput, eConsoleAppContainer
+
+HTTPConnection.debuglevel = 1
+
+lock = False
+def wb_lock():
+       global lock
+       lock = True
+       fbClass.getInstance().unlock()
+
+def wb_unlock():
+       global lock
+       fbClass.getInstance().lock()
+       lock = False
+
+def wb_islock():
+       global lock
+       return lock
+
+class VuPlayer(Screen, InfoBarNotifications):
+       skin =  """
+               <screen name="VuPlayer" flags="wfNoBorder" position="center,620" size="455,53" title="VuPlayer" backgroundColor="transparent">
+                       <ePixmap pixmap="Vu_HD/mp_wb_background.png" position="0,0" zPosition="-1" size="455,53" />
+                       <ePixmap pixmap="Vu_HD/icons/mp_wb_buttons.png" position="40,23" size="30,13" alphatest="on" />
+
+                       <widget source="session.CurrentService" render="PositionGauge" position="80,25" size="220,10" zPosition="2" pointer="skin_default/position_pointer.png:540,0" transparent="1" foregroundColor="#20224f">
+                               <convert type="ServicePosition">Gauge</convert>
+                       </widget>
+                       
+                       <widget source="session.CurrentService" render="Label" position="310,20" size="50,20" font="Regular;18" halign="center" valign="center" backgroundColor="#4e5a74" transparent="1" >
+                               <convert type="ServicePosition">Position</convert>
+                       </widget>
+                       <widget name="sidebar" position="362,20" size="10,20" font="Regular;18" halign="center" valign="center" backgroundColor="#4e5a74" transparent="1" />
+                       <widget source="session.CurrentService" render="Label" position="374,20" size="50,20" font="Regular;18" halign="center" valign="center" backgroundColor="#4e5a74" transparent="1" > 
+                               <convert type="ServicePosition">Length</convert>
+                       </widget>
+               </screen>
+               """
+       PLAYER_IDLE     = 0
+       PLAYER_PLAYING  = 1
+       PLAYER_PAUSED   = 2
+
+       def __init__(self, session, service, lastservice):
+               Screen.__init__(self, session)
+               InfoBarNotifications.__init__(self)
+
+               self.session     = session
+               self.service     = service
+               self.lastservice = lastservice
+               self["actions"] = ActionMap(["OkCancelActions", "InfobarSeekActions", "MediaPlayerActions", "MovieSelectionActions"],
+               {
+                       "ok": self.doInfoAction,
+                       "cancel": self.doExit,
+                       "stop": self.doExit,
+                       "playpauseService": self.playpauseService,
+               }, -2)
+               self["sidebar"] = Label(_("/"))
+
+               self.__event_tracker = ServiceEventTracker(screen = self, eventmap =
+               {
+                       iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged,
+                       iPlayableService.evStart: self.__serviceStarted,
+                       iPlayableService.evEOF: self.__evEOF,
+               })
+
+               self.hidetimer = eTimer()
+               self.hidetimer.timeout.get().append(self.doInfoAction)
+
+               self.state = self.PLAYER_PLAYING
+               self.lastseekstate = self.PLAYER_PLAYING
+               self.__seekableStatusChanged()
+       
+               self.onClose.append(self.__onClose)
+               self.doPlay()
+
+       def __onClose(self):
+               self.session.nav.stopService()
+
+       def __seekableStatusChanged(self):
+               service = self.session.nav.getCurrentService()
+               if service is not None:
+                       seek = service.seek()
+                       if seek is None or not seek.isCurrentlySeekable():
+                               self.setSeekState(self.PLAYER_PLAYING)
+
+       def __serviceStarted(self):
+               self.state = self.PLAYER_PLAYING
+               self.__seekableStatusChanged()
+
+       def __evEOF(self):
+               self.doExit()
+
+       def __setHideTimer(self):
+               self.hidetimer.start(5000)
+
+       def doExit(self):
+               list = ((_("Yes"), "y"), (_("No, but play video again"), "n"),)
+               self.session.openWithCallback(self.cbDoExit, ChoiceBox, title=_("Stop playing this movie?"), list = list)
+
+       def cbDoExit(self, answer):
+               answer = answer and answer[1]
+               if answer == "y":
+                       wb_unlock()
+                       self.close()
+               elif answer == "n":
+                       if self.state != self.PLAYER_IDLE:
+                               self.session.nav.stopService()
+                               self.state = self.PLAYER_IDLE
+                       self.doPlay()
+
+       def setSeekState(self, wantstate):
+               service = self.session.nav.getCurrentService()
+               if service is None:
+                       print "No Service found"
+                       return
+
+               pauseable = service.pause()
+               if pauseable is not None:
+                       if wantstate == self.PLAYER_PAUSED:
+                               pauseable.pause()
+                               self.state = self.PLAYER_PAUSED
+                               if not self.shown:
+                                       self.hidetimer.stop()
+                                       self.show()
+                       elif wantstate == self.PLAYER_PLAYING:
+                               pauseable.unpause()
+                               self.state = self.PLAYER_PLAYING
+                               if self.shown:
+                                       self.__setHideTimer()
+               else:
+                       self.state = self.PLAYER_PLAYING
+
+       def doInfoAction(self):
+               if self.shown:
+                       self.hide()
+                       self.hidetimer.stop()
+               else:
+                       self.show()
+                       if self.state == self.PLAYER_PLAYING:
+                               self.__setHideTimer()
+
+       def doPlay(self):
+               if self.state == self.PLAYER_PAUSED:
+                       if self.shown:
+                               self.__setHideTimer()   
+               self.state = self.PLAYER_PLAYING
+               self.session.nav.playService(self.service)
+               if self.shown:
+                       self.__setHideTimer()
+
+       def playpauseService(self):
+               if self.state == self.PLAYER_PLAYING:
+                       self.setSeekState(self.PLAYER_PAUSED)
+               elif self.state == self.PLAYER_PAUSED:
+                       self.setSeekState(self.PLAYER_PLAYING)
+
+VIDEO_FMT_PRIORITY_MAP = {
+       '38' : 1, #MP4 Original (HD)
+       '37' : 2, #MP4 1080p (HD)
+       '22' : 3, #MP4 720p (HD)
+       '18' : 4, #MP4 360p
+       '35' : 5, #FLV 480p
+       '34' : 6, #FLV 360p
+}
+std_headers = {
+       'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6',
+       'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
+       'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
+       'Accept-Language': 'en-us,en;q=0.5',
+}
+
+class VuPlayerLauncher:
+       def getVideoUrl(self, video_id):
+               video_url = None
+
+               if video_id is None or video_id == "":
+                       return video_url
+
+               # Getting video webpage
+               watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id
+               watchrequest = Request(watch_url, None, std_headers)
+               try:
+                       #print "trying to find out if a HD Stream is available",watch_url
+                       watchvideopage = urlopen2(watchrequest).read()
+               except (URLError, HTTPException, socket.error), err:
+                       print "Error: Unable to retrieve watchpage - Error code: ", str(err)
+                       return video_url
+
+               # Get video info
+               for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
+                       info_url = ('http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (video_id, el))
+                       request = Request(info_url, None, std_headers)
+                       try:
+                               infopage = urlopen2(request).read()
+                               videoinfo = parse_qs(infopage)
+                               if ('url_encoded_fmt_stream_map' or 'fmt_url_map') in videoinfo:
+                                       break
+                       except (URLError, HTTPException, socket.error), err:
+                               print "Error: unable to download video infopage",str(err)
+                               return video_url
+
+               if ('url_encoded_fmt_stream_map' or 'fmt_url_map') not in videoinfo:
+                       if 'reason' not in videoinfo:
+                               print 'Error: unable to extract "fmt_url_map" or "url_encoded_fmt_stream_map" parameter for unknown reason'
+                       else:
+                               reason = unquote_plus(videoinfo['reason'][0])
+                               print 'Error: YouTube said: %s' % reason.decode('utf-8')
+                       return video_url
+
+               video_fmt_map = {}
+               fmt_infomap = {}
+               if videoinfo.has_key('url_encoded_fmt_stream_map'):
+                       tmp_fmtUrlDATA = videoinfo['url_encoded_fmt_stream_map'][0].split(',url=')
+               else:
+                       tmp_fmtUrlDATA = videoinfo['fmt_url_map'][0].split(',')
+               for fmtstring in tmp_fmtUrlDATA:
+                       if videoinfo.has_key('url_encoded_fmt_stream_map'):
+                               (fmturl, fmtid) = fmtstring.split('&itag=')
+                               if fmturl.find("url=") !=-1:
+                                       fmturl = fmturl.replace("url=","")
+                       else:
+                               (fmtid,fmturl) = fmtstring.split('|')
+                       if VIDEO_FMT_PRIORITY_MAP.has_key(fmtid):
+                               video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) }
+                       fmt_infomap[int(fmtid)] = unquote_plus(fmturl)
+               print "got",sorted(fmt_infomap.iterkeys())
+               if video_fmt_map and len(video_fmt_map):
+                       video_url = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmturl'].split(';')[0]
+                       #print "found best available video format:",video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid']
+                       #print "found best available video url:",video_url
+               return video_url
+
+       def run(self, tubeid, session, service):
+               try:
+                       myurl = self.getVideoUrl(tubeid)
+                       print "Playing URL", myurl
+                       if myurl is None:
+                               session.open(MessageBox, _("Sorry, video is not available!"), MessageBox.TYPE_INFO)
+                               return
+
+                       wb_lock()
+                       myreference = eServiceReference(4097, 0, myurl)
+                       session.open(VuPlayer, myreference, service)
+               except Exception, msg:
+                       wb_unlock()
+                       print "Error >>", msg
+
+class VuPlayerService:
+       def __init__(self, session):
+               self.enable = False
+               self.socket_timeout = 0
+               self.max_buffer_size = 1024
+               self.uds_file = "/tmp/vuplus.tmp"
+               self.session = session
+               try:
+                       os.remove(self.uds_file)
+               except OSError:
+                       pass
+       
+       def start(self, timeout = 1):
+               self.socket_timeout = timeout
+               thread.start_new_thread(self.run, (True,))
+
+       def stop(self):
+               self.enable = False
+
+       def isRunning(self):
+               return self.enable
+
+       def run(self, e = True):
+               if self.enable:
+                       return
+               print "VuPlayerService start!!"
+               self.enable = e
+               self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+               self.sock.settimeout(self.socket_timeout)
+               self.sock.bind(self.uds_file)
+               self.sock.listen(1)
+               while(self.enable):
+                       try:
+                               conn, addr = self.sock.accept()
+                               self.parseHandle(conn, addr)
+                       except socket.timeout:
+                               #print "[socket timeout]"
+                               pass
+               print "VuPlayerService stop!!"
+
+       def parseHandle(self, conn, addr):
+               # [http://www.youtube.com/watch?v=BpThu778qB4&feature=related]
+               data = conn.recv(self.max_buffer_size)
+               print "[%s]" % (data)
+               if data.startswith("http://www.youtube.com"):
+                       tmp = data.split("?")
+                       print tmp # ['http://www.youtube.com/watch', 'v=BpThu778qB4&feature=related']
+                       service = self.session.nav.getCurrentlyPlayingServiceReference()
+                       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:
+                                       tmp = tmp[0].split("=")
+                                       print tmp # ['v', 'BpThu778qB4']
+                                       if len(tmp) == 2 and tmp[0] == "v":
+                                               player = VuPlayerLauncher()
+                                               player.run(tmp[1], self.session, service)
+                                               while wb_islock():
+                                                       time.sleep(1)
+                                               self.session.nav.playService(service)
+                                               data = "ok$"
+                                       else:
+                                               data = "nok$parsing fail"
+                               else:
+                                       data = "nok$parsing fail"
+                       else:
+                               data = "nok$parsing fail"
+                       self.sendResponse(conn, data)
+
+       def sendResponse(self, conn, data):
+               conn.send(data)
+               conn.close()
+
+class BrowserLauncher(ConfigListScreen, Screen):
+       skin=   """
+               <screen name="BrowserLauncher" position="center,center" size="309,458" title="Web Browser">
+                       <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,60" scrollbarMode="showOnDemand" />
+                       <ePixmap pixmap="Vu_HD/rc_wb_desc.png" position="0,110" size="309,296" alphatest="on" />
+                       <widget name="info" position="0,415" size="309,50" font="Regular;18" halign="center" foregroundColor="blue" transparent="1" />
+               </screen>
+               """
+
+       def __init__(self, session): 
+               Screen.__init__(self, session)
+                self.session = session
+
+               self.browser_root = "/usr/bin"
+               self.browser_name = "arora"
+               self.mouse_cond = "/proc/stb/fp/mouse"
+               self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "WizardActions", "ColorActions", "SetupActions", ],
+                {      "red": self.keyCancel,
+                       "green": self.keyGo,
+                       "cancel": self.keyExit,
+                }, -2)
+               self.info = Label(_("If you want to quit the Browser,\nPress RED and EXIT."))
+               self["info"] = self.info
+               self["key_red"] = StaticText(_("Exit"))
+               self["key_green"] = StaticText(_("Start"))
+
+               self.list = []
+               ConfigListScreen.__init__(self, self.list)
+
+               self.devices_string = ""
+               self.mouse_choice_list = []
+               self.mouse_device_list = []
+               self.keyboard_choice_list = []
+               self.keyboard_device_list = []
+               self.makeConfig()
+               #time.sleep(2)
+
+               self.lock = False
+               self.vu_service = VuPlayerService(self.session)
+               self.vu_service.start(timeout=5)
+
+               self.exit_wait_cond = False
+               self.timer_exit_cond = eTimer()
+               self.timer_exit_cond.callback.append(self.resetExitCond)
+
+       def enableRCMouse(self, mode): #mode=[0|1]|[False|True]
+               if os.path.exists(self.mouse_cond):
+                       self.cmd("echo %d > %s" % (mode, self.mouse_cond))
+
+       def cmd(self, cmd):
+               print "prepared cmd:", cmd
+               os.system(cmd)
+
+       def keyNone(self):
+               None
+
+       def doExit(self):
+               self.vu_service.stop()
+               self.cmd("killall -9 %s"%(self.browser_name))
+               self.cmd("echo 60 > /proc/sys/vm/swappiness")
+               if self.mouse.value == 0:
+                       self.enableRCMouse(False) #rc-mouse off
+               fbClass.getInstance().unlock()
+               #eRCInput.getInstance().unlock()
+               self.close()
+
+       def keyExit(self):
+               if self.exit_wait_cond:
+                       self.doExit()
+               if self.isProcessRunable() == False:
+                       self.doExit()
+
+       def keyCancel(self):
+               if self.isProcessRunable() == False:
+                       self.doExit()
+               self.exit_wait_cond = True
+               self.timer_exit_cond.start(5000)
+
+       def resetExitCond(self):
+               self.timer_exit_cond.stop()
+               self.exit_wait_cond = False
+
+       def isProcessRunable(self):
+               cmd = "/bin/ps -ef | grep %s | grep -v grep | awk \'{print $5}\'"%(self.browser_name)
+               for line in os.popen(cmd).readlines():
+                       return True
+               return False
+
+       def makeConfig(self):
+               self.devices = eConsoleAppContainer()
+               self.devices.dataAvail.append(self.callbackDevicesDataAvail)
+               self.devices.appClosed.append(self.callbakcDevicesAppClose)
+               self.devices.execute(_("cat /proc/bus/input/devices"))
+
+       def callbackDevicesDataAvail(self, ret_data):
+               self.devices_string = self.devices_string + ret_data
+
+       def callbakcDevicesAppClose(self, retval):
+               self.parseDeviceData(self.devices_string)
+               self.makeHandlerList()
+
+               # none : -1, rc : 0, usb : 1
+               self.mouse_choice_list.append((2, _("None")))
+               self.keyboard_choice_list.append((2, _("None")))
+               
+               print self.mouse_choice_list
+               print self.keyboard_choice_list
+               print self.mouse_device_list
+               print self.keyboard_device_list
+
+               self.mouse = ConfigSelection(default = self.mouse_choice_list[0][0], choices = self.mouse_choice_list)
+               self.keyboard = ConfigSelection(default = self.mouse_choice_list[0][0], choices = self.keyboard_choice_list)
+               
+               self.list.append(getConfigListEntry(_('Mouse'), self.mouse))            
+               self.list.append(getConfigListEntry(_('Keyboard'), self.keyboard))
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def parseDeviceData(self, data):
+               n = ""
+               p = ""
+               h = ""
+               self.devices=[]
+               lines=data.split('\n')
+               for line in lines:
+                       if line == None or line == "":
+                               if h != None and len(h) != 0:
+                                       print "find driver >> name[%s], phys[%s], handler[%s]" % (n, p, h)
+                                       self.devices.append([n, p, h])
+                               n = ""
+                               p = ""
+                               h = ""
+                               continue
+                       if line[0] == 'N':
+                               n = line[8:].strip()
+                       elif line[0] == 'P':
+                               p = line[8:].strip()
+                       elif line[0] == 'H':
+                               h = line[12:].strip()
+
+       def makeHandlerList(self):
+               if self.devices == None or self.devices == []:
+                       return False
+
+               mouse_pc_h = []
+               mouse_rc_h = []
+               keyboard_pc_h = []
+               keyboard_rc_h = []
+               for dev in self.devices:
+                       n = dev[0]
+                       p = dev[1]
+                       h = dev[2]
+                       if p.startswith("usb-ohci-brcm"):
+                               if h.rfind("mouse") >= 0:
+                                       mouse_pc_h = [(1, _("USB Mouse")), self.getHandlerName(h, "mouse")]
+                               else:
+                                       if len(keyboard_pc_h) == 0:
+                                               keyboard_pc_h = [(1, _("USB Keyboard")), self.getHandlerName(h, "event")]
+                       else:
+                               if n[1:].startswith("dreambox") and os.path.exists(self.mouse_cond) :
+                                       mouse_rc_h    = [(0, _("RemoteControl")), self.getHandlerName(h, "event")]
+                                       keyboard_rc_h = [(0, _("RemoteControl")), self.getHandlerName(h, "event")]
+               if len(mouse_rc_h) > 0:
+                       self.mouse_choice_list.append(mouse_rc_h[0])
+                       self.mouse_device_list.append(mouse_rc_h[1])
+               if len(mouse_pc_h) > 0:
+                       self.mouse_choice_list.append(mouse_pc_h[0])
+                       self.mouse_device_list.append(mouse_pc_h[1])
+
+               if len(keyboard_rc_h) > 0:
+                       self.keyboard_choice_list.append(keyboard_rc_h[0])
+                       self.keyboard_device_list.append(keyboard_rc_h[1])
+               if len(keyboard_pc_h) > 0:
+                       self.keyboard_choice_list.append(keyboard_pc_h[0])
+                       self.keyboard_device_list.append(keyboard_pc_h[1])
+               return True
+
+       def getHandlerName(self, h, s):
+               if h is None or len(h) == 0:
+                       return ""
+
+               handles = h.split()                                                
+               #print "handles >> ", handles
+               for tmp_h in handles:                                                                                                    
+                       #print "handle_item >> ", tmp_h
+                       if tmp_h.startswith(s):          
+                               #print "detected : [%s]" % tmp_h
+                               return tmp_h
+               return ""
+
+       def startBrowser(self):
+               self.timer_start.stop()
+
+               self.lock = True
+               self.cmd("killall -9 %s"%(self.browser_name))
+               self.cmd("echo 0 > /proc/sys/vm/swappiness")
+
+               kbd_cmd = ""
+               mouse_cmd = ""
+               extra_cmd = "" 
+               browser_cmd = "%s/%s -qws" % (self.browser_root, self.browser_name)
+       
+               fbClass.getInstance().lock()
+               #eRCInput.getInstance().lock()
+
+               if self.mouse.value == 0:
+                       self.enableRCMouse(True) #rc-mouse on
+                       idx = self.getListIndex(self.mouse_choice_list, 0)
+                       mouse_cmd = "export QWS_MOUSE_PROTO=LinuxInput:/dev/input/%s; " % (self.mouse_device_list[idx])
+               elif self.mouse.value == 1:
+                       mouse_cmd = " "
+                       #mouse_cmd = "export QWS_MOUSE_PROTO=Auto:/dev/input/%s; " % (m)
+               elif self.mouse.value == 2:
+                       mouse_cmd = "export QWS_MOUSE_PROTO=None; "
+
+               if self.keyboard.value == 0:
+                       idx = self.getListIndex(self.keyboard_choice_list, 0)
+                       kbd_cmd = "export QWS_KEYBOARD=LinuxInput:/dev/input/%s; " % (self.keyboard_device_list[idx])
+               elif self.keyboard.value == 1:
+                       idx = self.getListIndex(self.keyboard_choice_list, 1)
+                       kbd_cmd = "export QWS_KEYBOARD=LinuxInput:/dev/input/%s; " % (self.keyboard_device_list[idx])
+               elif self.keyboard.value == 2:
+                       kbd_cmd = " "
+               print "mouse cmd >>", mouse_cmd, " >> ", self.mouse.value
+               print "keyboard cmd >>", kbd_cmd, " >> ", self.keyboard.value
+
+               cmd = "%s%s%s%s" % (extra_cmd, kbd_cmd, mouse_cmd, browser_cmd)
+               print "prepared command : [%s]" % cmd
+
+               self.launcher = eConsoleAppContainer()
+               self.launcher.appClosed.append(self.callbackLauncherAppClosed)
+               self.launcher.dataAvail.append(self.callbackLauncherDataAvail)
+               self.launcher.execute(cmd)
+               print "started browser..."
+
+       def keyGo(self):
+               self.info.setText("Starting Webbrowser. Please wait...")
+               if self.lock == False:
+                       self.timer_start = eTimer()
+                       self.timer_start.callback.append(self.startBrowser)
+                       self.timer_start.start(10)
+
+       def getListIndex(self, l, v):
+               idx = 0
+               for i in l:
+                       if i[0] == v:
+                               return idx;
+                       idx = idx + 1
+               return -1
+
+       def callbackLauncherDataAvail(self, ret_data):
+               print ret_data
+               if ret_data.startswith("--done--"):
+                       self.lock = False
+                       self.doExit()
+
+       def callbackLauncherAppClosed(self, retval = 1):
+               self.lock = False
+
+def sessionstart(session, **kwargs):
+       if os.path.exists("/proc/stb/fp/mouse"):
+               os.system("echo 0 > /proc/stb/fp/mouse")
+
+def main(session, **kwargs):
+       session.open(BrowserLauncher)
+
+def Plugins(**kwargs):
+       return [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, needsRestart = False, fnc=sessionstart),
+               PluginDescriptor(name=_("Web Browser"), description="start web browser", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)]
+
+
+
index ab4883e..28c3d94 100755 (executable)
@@ -5,7 +5,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \
-       Blindscan
+       Blindscan RemoteControlCode UI3DSetup UIPositionSetup
 
 install_PYTHON =       \
        __init__.py
diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile.am b/lib/python/Plugins/SystemPlugins/RemoteControlCode/Makefile.am
new file mode 100755 (executable)
index 0000000..384f3e5
--- /dev/null
@@ -0,0 +1,7 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/RemoteControlCode
+
+SUBDIRS = meta
+
+install_PYTHON =  \
+       __init__.py \
+       plugin.py
diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/__init__.py b/lib/python/Plugins/SystemPlugins/RemoteControlCode/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..5f2b922
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_remotecontrolcode.xml
diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/plugin_remotecontrolcode.xml b/lib/python/Plugins/SystemPlugins/RemoteControlCode/meta/plugin_remotecontrolcode.xml
new file mode 100755 (executable)
index 0000000..8301530
--- /dev/null
@@ -0,0 +1,16 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info>
+                    <author>hschang</author>
+                    <name>RemoteControlCode</name>
+                    <packagename>enigma2-plugin-systemplugins-remotecontrolcode</packagename>
+                    <shortdescription>Change Remote Control Code</shortdescription>
+                    <description>Change Remote Control Code</description>
+          </info>
+
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-remotecontrolcode" />
+       </files>
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/RemoteControlCode/plugin.py b/lib/python/Plugins/SystemPlugins/RemoteControlCode/plugin.py
new file mode 100755 (executable)
index 0000000..699d4ad
--- /dev/null
@@ -0,0 +1,180 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection
+from Components.ActionMap import ActionMap
+from Screens.MessageBox import MessageBox
+from Components.Sources.StaticText import StaticText
+from Plugins.Plugin import PluginDescriptor
+from Tools.Directories import fileExists
+from enigma import eTimer
+
+config.plugins.remotecontrolcode = ConfigSubsection()
+config.plugins.remotecontrolcode.systemcode = ConfigSelection(default = "2", choices = 
+       [ ("1", "1 "), ("2", "2 "), ("3", "3 "), ("4", "4 ") ] )
+
+class RemoteControlCodeInit:
+       def __init__(self):
+               self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
+
+       def setSystemCode(self, type = 2):
+               if not fileExists("/proc/stb/fp/remote_code"):
+                       return -1
+               print "<RemoteControlCode> Write Remote Control Code : %d" % type
+               f = open("/proc/stb/fp/remote_code", "w")
+               f.write("%d" % type)
+               f.close()
+               return 0
+
+       def getModel(self):
+               if fileExists("/proc/stb/info/vumodel"):
+                       vumodel = open("/proc/stb/info/vumodel")
+                       info=vumodel.read().strip()
+                       vumodel.close()
+                       if info in ["uno", "ultimo"]:
+                               return True
+                       else:
+                               return False
+               else:
+                       return False
+
+class RemoteControlCode(Screen,ConfigListScreen,RemoteControlCodeInit):
+       skin = """
+                       <screen name="RemoteControlCode" position="center,center" size="560,300" title="Remote Control System Code Setting" >
+                       <ePixmap pixmap="Vu_HD/buttons/red.png" position="10,10" size="25,25" alphatest="on" />
+                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="290,10" size="25,25" alphatest="on" />
+                       <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget source="key_green" render="Label" position="320,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget name="config" zPosition="2" position="5,50" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
+                       </screen>"""
+
+       def __init__(self,session):
+               Screen.__init__(self,session)
+               self.session = session
+               self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
+               {
+                       "ok": self.keySave,
+                       "cancel": self.keyCancel,
+                       "red": self.keyCancel,
+                       "green": self.keySave,
+               }, -2)
+               self.list = []
+               ConfigListScreen.__init__(self, self.list,session = self.session)
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("Save"))
+               self.createSetup()
+               self.onLayoutFinish.append(self.checkModel)
+               self.checkModelTimer = eTimer()
+               self.checkModelTimer.callback.append(self.invalidmodel)
+
+       def checkModel(self):
+               if not self.getModel():
+                       self.checkModelTimer.start(1000,True)
+
+       def invalidmodel(self):
+                       self.session.openWithCallback(self.close, MessageBox, _("This Plugin only support for UNO/ULTIMO"), MessageBox.TYPE_ERROR)
+
+       def createSetup(self):
+               self.list = []
+               self.rcsctype = getConfigListEntry(_("Remote Control System Code"), config.plugins.remotecontrolcode.systemcode)
+               self.list.append( self.rcsctype )
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def keySave(self):
+               print "<RemoteControlCode> Selected System Code : ",config.plugins.remotecontrolcode.systemcode.value
+               ret = self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
+               if ret == -1:
+                       self.restoreCode()
+                       self.session.openWithCallback(self.close, MessageBox, _("FILE NOT EXIST : /proc/stb/fp/remote_code"), MessageBox.TYPE_ERROR)
+               else:
+                       self.session.openWithCallback(self.MessageBoxConfirmCodeCallback, MessageBoxConfirmCode, _("The remote control code will be reset to previous setting"), MessageBox.TYPE_YESNO, timeout = 10, default = False)
+
+       def restoreCode(self):
+               for x in self["config"].list:
+                       x[1].cancel()
+
+       def MessageBoxConfirmCodeCallback(self,ret):
+               if ret:
+                       ConfigListScreen.keySave(self)
+               else:
+                       self.restoreCode()
+                       self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
+
+class MessageBoxConfirmCode(MessageBox):
+       skin = """
+               <screen position="center,center" size="600,10" title="Message">
+               <widget name="text" position="65,8" size="420,0" font="Regular;22" />
+               <widget name="ErrorPixmap" pixmap="Vu_HD/icons/input_error.png" position="5,5" size="53,53" alphatest="blend" />
+               <widget name="QuestionPixmap" pixmap="Vu_HD/icons/input_question.png" position="5,5" size="53,53" alphatest="blend" />
+               <widget name="InfoPixmap" pixmap="Vu_HD/icons/input_info.png" position="5,5" size="53,53" alphatest="blend" />
+               <widget name="list" position="100,100" size="380,375" transparent="1" backgroundColor="darkgrey" />
+               <applet type="onLayoutFinish">
+# this should be factored out into some helper code, but currently demonstrates applets.
+from enigma import eSize, ePoint
+
+orgwidth = self.instance.size().width()
+orgpos = self.instance.position()
+textsize = self[&quot;text&quot;].getSize()
+
+# y size still must be fixed in font stuff...
+textsize = (textsize[0] + 50, textsize[1] + 50)
+offset = 0
+if self.type == self.TYPE_YESNO:
+       offset = 60
+wsizex = textsize[0] + 60
+wsizey = textsize[1] + offset
+if (280 &gt; wsizex):
+       wsizex = 280
+wsize = (wsizex, wsizey)
+
+
+# resize
+self.instance.resize(eSize(*wsize))
+
+# resize label
+self[&quot;text&quot;].instance.resize(eSize(*textsize))
+
+# move list
+listsize = (wsizex, 50)
+self[&quot;list&quot;].instance.move(ePoint(0, textsize[1]))
+self[&quot;list&quot;].instance.resize(eSize(*listsize))
+
+# center window
+newwidth = wsize[0]
+self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
+               </applet>
+       </screen>"""
+
+       def __init__(self, session, text, type = MessageBox.TYPE_YESNO, timeout = -1, close_on_any_key = False, default = True, enable_input = True, msgBoxID = None):
+               MessageBox.__init__(self,session,text,type,timeout,close_on_any_key,default,enable_input,msgBoxID)
+               if type == MessageBox.TYPE_YESNO:
+                       self.list = [ (_("Keep"), 0), (_("Restore"), 1) ]
+                       self["list"].setList(self.list)
+
+       def timerTick(self):
+               if self.execing:
+                       self.timeout -= 1
+                       self["text"].setText(self.text + " in %d seconds." %self.timeout)
+                       if self.timeout == 0:
+                               self.timer.stop()
+                               self.timerRunning = False
+                               self.timeoutCallback()
+
+       def move(self, direction):
+               if self.close_on_any_key:
+                       self.close(True)
+               self["list"].instance.moveSelection(direction)
+               if self.list:
+                       self["selectedChoice"].setText(self["list"].getCurrent()[0])
+#              self.stopTimer()
+
+       def timeoutCallback(self):
+               self.close(False)
+
+def main(session, **kwargs):
+       session.open(RemoteControlCode)
+
+def Plugins(**kwargs):
+       return [PluginDescriptor(name=_("RemoteControlCode"), description="setup Remote Control System Code Type", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]
+
+remotecontrolcodeinit = RemoteControlCodeInit()
diff --git a/lib/python/Plugins/SystemPlugins/UI3DSetup/Makefile.am b/lib/python/Plugins/SystemPlugins/UI3DSetup/Makefile.am
new file mode 100755 (executable)
index 0000000..84f738b
--- /dev/null
@@ -0,0 +1,7 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/UI3DSetup
+
+SUBDIRS = meta
+
+install_PYTHON = \
+       __init__.py \
+       plugin.py
diff --git a/lib/python/Plugins/SystemPlugins/UI3DSetup/__init__.py b/lib/python/Plugins/SystemPlugins/UI3DSetup/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/UI3DSetup/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/UI3DSetup/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..f8c6be0
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_ui3dsetup.xml
diff --git a/lib/python/Plugins/SystemPlugins/UI3DSetup/meta/plugin_ui3dsetup.xml b/lib/python/Plugins/SystemPlugins/UI3DSetup/meta/plugin_ui3dsetup.xml
new file mode 100755 (executable)
index 0000000..946e6ff
--- /dev/null
@@ -0,0 +1,16 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info>
+                    <author>hschang</author>
+                    <name>UI3DSetup</name>
+                    <packagename>enigma2-plugin-systemplugins-ui3dsetup</packagename>
+                    <shortdescription>Adjust 3D settings</shortdescription>
+                    <description>Adjust 3D settings</description>
+          </info>
+
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-ui3dsetup" />
+       </files>
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/UI3DSetup/plugin.py b/lib/python/Plugins/SystemPlugins/UI3DSetup/plugin.py
new file mode 100755 (executable)
index 0000000..645b829
--- /dev/null
@@ -0,0 +1,119 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigSlider, getConfigListEntry
+from Components.Sources.StaticText import StaticText
+
+modelist = {"off": _("Off"), "auto": _("Auto"), "sidebyside": _("Side by Side"), "topandbottom": _("Top and Bottom")}
+setmodelist = {"mode1": _("Mode 1"), "mode2": _("Mode 2")}
+
+config.plugins.UI3DSetup = ConfigSubsection()
+config.plugins.UI3DSetup.mode = ConfigSelection(choices = modelist, default = "auto")
+config.plugins.UI3DSetup.znorm = ConfigInteger(default = 0)
+config.plugins.UI3DSetup.setmode = ConfigSelection(choices = setmodelist, default = "mode1")
+
+class UI3DSetupScreen(Screen, ConfigListScreen):
+       skin = """
+               <screen position="center,center" size="560,300" title="UI 3D setup" >
+                       <ePixmap pixmap="Vu_HD/buttons/red.png" position="10,10" size="25,25" alphatest="on" />
+                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="290,10" size="25,25" alphatest="on" />
+                       <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget source="key_green" render="Label" position="320,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget name="config" zPosition="2" position="5,50" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
+               </screen>"""
+
+       def __init__(self, session):
+               self.skin = UI3DSetupScreen.skin
+               Screen.__init__(self, session)
+
+               from Components.ActionMap import ActionMap
+               from Components.Button import Button
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("Save"))
+
+               self["actions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "ok": self.keyGo,
+                       "save": self.keyGo,
+                       "cancel": self.keyCancel,
+                       "green": self.keyGo,
+                       "red": self.keyCancel,
+               }, -2)
+
+               self.list = []
+               ConfigListScreen.__init__(self, self.list, session = self.session)
+
+               mode = config.plugins.UI3DSetup.mode.value
+               znorm = config.plugins.UI3DSetup.znorm.value
+               setmode = config.plugins.UI3DSetup.setmode.value
+
+               self.mode = ConfigSelection(choices = modelist, default = mode)
+               self.znorm = ConfigSlider(default = znorm + 50, increment = 1, limits = (0, 100))
+               self.setmode = ConfigSelection(choices = setmodelist, default = setmode)
+               self.list.append(getConfigListEntry(_("Setup mode"), self.setmode))
+               self.list.append(getConfigListEntry(_("3d mode"), self.mode))
+               self.list.append(getConfigListEntry(_("Depth"), self.znorm))
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.setPreviewSettings()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.setPreviewSettings()
+
+       def setPreviewSettings(self):
+               applySettings(self.mode.value, int(self.znorm.value) - 50, self.setmode.value)
+
+       def keyGo(self):
+               config.plugins.UI3DSetup.mode.value = self.mode.value
+               config.plugins.UI3DSetup.znorm.value = int(self.znorm.value) - 50
+               config.plugins.UI3DSetup.setmode.value = self.setmode.value
+               config.plugins.UI3DSetup.save()
+               self.close()
+
+       def keyCancel(self):
+               setConfiguredSettings()
+               self.close()
+
+def applySettings(mode, znorm, setmode):
+       try:
+               if setmode == "mode1":
+                       file = open("/proc/stb/fb/3dmode", "w")
+                       file.write(mode)
+                       file.close()
+                       file = open("/proc/stb/fb/znorm", "w")
+                       file.write('%d' % znorm)
+                       file.close()
+               elif setmode == "mode2":
+                       file = open("/proc/stb/fb/primary/3d","w")
+                       if mode == "sidebyside" :
+                               mode = "sbs"
+                       elif mode == "topandbottom":
+                               mode = "tab"
+                       file.write(mode)
+                       file.close()
+                       file = open("/proc/stb/fb/primary/zoffset","w")
+                       file.write('%d' % znorm)
+                       file.close()
+       except:
+               return
+
+def setConfiguredSettings():
+       applySettings(config.plugins.UI3DSetup.mode.value, 
+               int(config.plugins.UI3DSetup.znorm.value), config.plugins.UI3DSetup.setmode.value)
+
+def main(session, **kwargs):
+       session.open(UI3DSetupScreen)
+
+def startup(reason, **kwargs):
+       setConfiguredSettings()
+
+def Plugins(**kwargs):
+       from os import path
+       if path.exists("/proc/stb/fb/3dmode") or path.exists("/proc/stb/fb/primary/3d"):
+               from Plugins.Plugin import PluginDescriptor
+               return [PluginDescriptor(name = "UI 3D setup", description = _("Adjust 3D settings"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main),
+                                       PluginDescriptor(name = "UI 3D setup", description = "", where = PluginDescriptor.WHERE_SESSIONSTART, fnc = startup)]
+       return []
diff --git a/lib/python/Plugins/SystemPlugins/UIPositionSetup/Makefile.am b/lib/python/Plugins/SystemPlugins/UIPositionSetup/Makefile.am
new file mode 100755 (executable)
index 0000000..44132bb
--- /dev/null
@@ -0,0 +1,7 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/UIPositionSetup
+
+SUBDIRS = meta
+
+install_PYTHON = \
+       __init__.py \
+       plugin.py
diff --git a/lib/python/Plugins/SystemPlugins/UIPositionSetup/__init__.py b/lib/python/Plugins/SystemPlugins/UIPositionSetup/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..0aa214b
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_uipositionsetup.xml
diff --git a/lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/plugin_uipositionsetup.xml b/lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/plugin_uipositionsetup.xml
new file mode 100755 (executable)
index 0000000..603880c
--- /dev/null
@@ -0,0 +1,16 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info>
+                    <author>hschang</author>
+                    <name>UIPositionSetup</name>
+                    <packagename>enigma2-plugin-systemplugins-uipositionsetup</packagename>
+                    <shortdescription>Adjust screen position</shortdescription>
+                    <description>Adjust screen position</description>
+          </info>
+
+         <files type="package"> <!-- without version, without .ipk -->
+               <file type="package" name="enigma2-plugin-systemplugins-uipositionsetup" />
+       </files>
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/UIPositionSetup/plugin.py b/lib/python/Plugins/SystemPlugins/UIPositionSetup/plugin.py
new file mode 100755 (executable)
index 0000000..0ad18d0
--- /dev/null
@@ -0,0 +1,135 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger, ConfigSlider
+from Components.ActionMap import ActionMap
+from Screens.MessageBox import MessageBox
+from Components.Sources.StaticText import StaticText
+from Plugins.Plugin import PluginDescriptor
+from Tools.Directories import fileExists
+from enigma import eTimer
+from Plugins.Plugin import PluginDescriptor
+
+config.plugins.UIPositionSetup = ConfigSubsection()
+config.plugins.UIPositionSetup.dst_left = ConfigInteger(default = 0)
+config.plugins.UIPositionSetup.dst_width = ConfigInteger(default = 720)
+config.plugins.UIPositionSetup.dst_top = ConfigInteger(default = 0)
+config.plugins.UIPositionSetup.dst_height = ConfigInteger(default = 576)
+
+class UIPositionSetupInit:
+       def __init__(self):
+               self.setPosition(int(config.plugins.UIPositionSetup.dst_left.value), int(config.plugins.UIPositionSetup.dst_width.value), int(config.plugins.UIPositionSetup.dst_top.value), int(config.plugins.UIPositionSetup.dst_height.value))
+
+       def setPosition(self,dst_left, dst_width, dst_top, dst_height):
+               if dst_left + dst_width > 720:
+                       dst_width = 720 - dst_left
+               if dst_top + dst_height > 576:
+                       dst_height = 576 - dst_top
+               print "[UIPositionSetup] write dst_left : ",dst_left
+               print "[UIPositionSetup] write dst_width : ",dst_width
+               print "[UIPositionSetup] write dst_top : ",dst_top
+               print "[UIPositionSetup] write dst_height : ",dst_height
+               try:
+                       file = open("/proc/stb/fb/dst_left", "w")
+                       file.write('%X' % dst_left)
+                       file.close()
+                       file = open("/proc/stb/fb/dst_width", "w")
+                       file.write('%X' % dst_width)
+                       file.close()
+                       file = open("/proc/stb/fb/dst_top", "w")
+                       file.write('%X' % dst_top)
+                       file.close()
+                       file = open("/proc/stb/fb/dst_height", "w")
+                       file.write('%X' % dst_height)
+                       file.close()
+               except:
+                       return
+
+uipositionsetupinit = UIPositionSetupInit()
+
+class UIPositionSetup(Screen, ConfigListScreen, UIPositionSetupInit):
+       def __init__(self,session):
+               size_w = session.desktop.size().width()
+               size_h = session.desktop.size().height()
+               xpos = (size_w-500)/2
+               ypos = (size_h-300)/2
+               self.skin=""
+               self.skin += "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" title=\"Screen Position Setup\" backgroundColor=\"#27d8dee2\">"
+               self.skin += "<ePixmap pixmap=\"Vu_HD/buttons/red.png\" position=\""+str(xpos+10) + "," + str(ypos+10) + "\" size=\"25,25\" alphatest=\"on\" />"
+               self.skin += "<ePixmap pixmap=\"Vu_HD/buttons/green.png\" position=\""+str(xpos+290) + "," + str(ypos+10) + "\" size=\"25,25\" alphatest=\"on\" />"
+               self.skin += "<widget source=\"key_red\" render=\"Label\" position=\""+str(xpos+40) + "," + str(ypos+10) + "\" zPosition=\"1\" size=\"140,25\" font=\"Regular;20\" halign=\"center\" valign=\"center\" foregroundColor=\"#1c1c1c\" transparent=\"1\" />"
+               self.skin += "<widget source=\"key_green\" render=\"Label\" position=\""+str(xpos+320) + "," + str(ypos+10) + "\" zPosition=\"1\" size=\"140,25\" font=\"Regular;20\" halign=\"center\" valign=\"center\" foregroundColor=\"#1c1c1c\" transparent=\"1\" />"
+               self.skin += "<widget name=\"config\" zPosition=\"2\" position=\""+str(xpos+5) + "," + str(ypos+50) + "\" size=\"550,200\" scrollbarMode=\"showOnDemand\" foregroundColor=\"#1c1c1c\" transparent=\"1\" />"
+               self.skin += "</screen>"
+
+               Screen.__init__(self,session)
+               self.session = session
+               self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
+               {
+                       "ok": self.keyOk,
+                       "cancel": self.keyCancel,
+                       "red": self.keyCancel,
+                       "green": self.keyOk,
+               }, -2)
+               self.list = []
+               ConfigListScreen.__init__(self, self.list,session = self.session)
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("Save"))
+               self["current"] = StaticText(_(" "))
+               self.createSetup()
+
+       def createSetup(self):
+               self.list = []
+
+               left = config.plugins.UIPositionSetup.dst_left.value
+               width = config.plugins.UIPositionSetup.dst_width.value
+               top = config.plugins.UIPositionSetup.dst_top.value
+               height = config.plugins.UIPositionSetup.dst_height.value
+
+               self.dst_left = ConfigSlider(default = left, increment = 5, limits = (0, 720))
+               self.dst_width = ConfigSlider(default = width, increment = 5, limits = (0, 720))
+               self.dst_top = ConfigSlider(default = top, increment = 5, limits = (0, 576))
+               self.dst_height = ConfigSlider(default = height, increment = 5, limits = (0, 576))
+
+               self.list.append(getConfigListEntry(_("left"), self.dst_left))
+               self.list.append(getConfigListEntry(_("width"), self.dst_width))
+               self.list.append(getConfigListEntry(_("top"), self.dst_top))
+               self.list.append(getConfigListEntry(_("height"), self.dst_height))
+
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.setPosition(int(self.dst_left.value), int(self.dst_width.value), int(self.dst_top.value), int(self.dst_height.value))
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.setPosition(int(self.dst_left.value), int(self.dst_width.value), int(self.dst_top.value), int(self.dst_height.value))
+
+       def keyOk(self):
+               config.plugins.UIPositionSetup.dst_left.value = self.dst_left.value
+               config.plugins.UIPositionSetup.dst_width.value = self.dst_width.value
+               config.plugins.UIPositionSetup.dst_top.value = self.dst_top.value
+               config.plugins.UIPositionSetup.dst_height.value = self.dst_height.value
+               config.plugins.UIPositionSetup.save()
+               self.close()
+
+       def keyCancel(self):
+               if self["config"].isChanged():
+                       self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
+               else:
+                       self.close()
+
+       def cancelConfirm(self,ret):
+               if ret:
+                       self.setPosition(int(config.plugins.UIPositionSetup.dst_left.value), int(config.plugins.UIPositionSetup.dst_width.value), int(config.plugins.UIPositionSetup.dst_top.value), int(config.plugins.UIPositionSetup.dst_height.value))
+                       self.close()
+
+def main(session, **kwargs):
+       session.open(UIPositionSetup)
+
+def Plugins(**kwargs):
+       if fileExists("/proc/stb/fb/dst_left"):
+               return [PluginDescriptor(name = "UI position setup", description = "Adjust screen position", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main)]
+       return []
+