1 from Screens.Screen import Screen
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger
4 from Components.ActionMap import ActionMap
5 from Screens.MessageBox import MessageBox
6 from Components.Sources.StaticText import StaticText
7 from Plugins.Plugin import PluginDescriptor
8 from Tools.Directories import fileExists
9 from enigma import eTimer, quitMainloop
13 if fileExists("/proc/stb/info/vumodel"):
14 vumodel = open("/proc/stb/info/vumodel")
15 info=vumodel.read().strip()
21 def getRcuDefaultType():
22 if getModel() in ["uno4kse", "zero4k", "duo4k"]:
26 config.plugins.remotecontrolcode = ConfigSubsection()
27 config.plugins.remotecontrolcode.systemcode = ConfigSelection(default = "2", choices =
28 [ ("1", "1 "), ("2", "2 "), ("3", "3 "), ("4", "4 ") ] )
29 config.plugins.remotecontrolcode.replytimeout = ConfigInteger(default = 30, limits = (15,9999))
30 config.plugins.remotecontrolcode.rcuType = ConfigSelection(default = getRcuDefaultType(), choices =
31 [ ("legacy", "Legacy Vu+ Universal RCU"), ("new", "New Vu+ DarkBrown/Bluetooth RCU") ] )
33 class RemoteControlCodeInit:
35 self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
37 def setSystemCode(self, type = 2):
38 if not fileExists("/proc/stb/fp/remote_code"):
40 print "<RemoteControlCode> Write Remote Control Code : %d" % type
41 f = open("/proc/stb/fp/remote_code", "w")
46 def checkModelSupport(self):
49 if model not in ["duo", "solo"]:
54 class RemoteControlCode(Screen,ConfigListScreen,RemoteControlCodeInit):
56 <screen position="center,center" size="400,250" title="Remote Control System Code Setting" >
57 <ePixmap pixmap="skin_default/buttons/red.png" position="30,10" size="140,40" alphatest="on" />
58 <ePixmap pixmap="skin_default/buttons/green.png" position="230,10" size="140,40" alphatest="on" />
60 <widget source="key_red" render="Label" position="30,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
61 <widget source="key_green" render="Label" position="230,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
63 <widget name="config" zPosition="2" position="5,70" size="380,180" scrollbarMode="showOnDemand" transparent="1" />
67 def __init__(self,session):
68 Screen.__init__(self,session)
69 self.session = session
70 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
73 "cancel": self.keyCancel,
74 "red": self.keyCancel,
75 "green": self.keySave,
78 ConfigListScreen.__init__(self, self.list,session = self.session)
79 self["key_red"] = StaticText(_("Cancel"))
80 self["key_green"] = StaticText(_("Ok"))
81 self.replytext_1 ="The remote control code will be reset to previous setting, set your R/C's code and select 'keep'"
82 self.replytext_2 ="\n\n<Code set manual>"
83 self.replytext_2 +="\n1. Press Digit 2 and Digit 7 simultaneously for 3 seconds. After 3 seconds LED turns on. "
84 self.replytext_2 +="\n2. Press the <HELP> key. LED is blinked and turns on."
85 self.replytext_2 +="\n3. Enter a 4 digit code(ex. code 2 is '0002')"
87 self.replytext_newrcu_2 ="\n\n<Code set manual>"
88 self.replytext_newrcu_2 +="\n1. Press <OK> and <STB> simultaneously for 3 seconds. After 3 seconds LED turns on. "
89 self.replytext_newrcu_2 +="\n2. Enter a 5 digit code(ex. code 2 is '00002')"
90 self.replytext_newrcu_2 +="\n3. Press the <OK> key. LED is blinked and turns on."
93 self.onLayoutFinish.append(self.checkModel)
94 self.checkModelTimer = eTimer()
95 self.checkModelTimer.callback.append(self.invalidmodel)
98 if not self.checkModelSupport():
99 self.checkModelTimer.start(1000,True)
101 def invalidmodel(self):
102 self.session.openWithCallback(self.close, MessageBox, _("This Plugin doesn't support on SOLO/DUO"), MessageBox.TYPE_ERROR)
104 def createSetup(self):
106 self.rcuTypeEntry = getConfigListEntry(_("Remote Control Type"), config.plugins.remotecontrolcode.rcuType)
107 self.rcsctype = getConfigListEntry(_("Remote Control System Code"), config.plugins.remotecontrolcode.systemcode)
108 self.replytimeout = getConfigListEntry(_("Reply timeout"), config.plugins.remotecontrolcode.replytimeout)
109 self.list.append( self.rcuTypeEntry )
110 self.list.append( self.rcsctype )
111 self.list.append( self.replytimeout )
112 self["config"].list = self.list
113 self["config"].l.setList(self.list)
116 print "<RemoteControlCode> Selected System Code : ",config.plugins.remotecontrolcode.systemcode.value
117 ret = self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
120 self.session.openWithCallback(self.close, MessageBox, _("FILE NOT EXIST : /proc/stb/fp/remote_code"), MessageBox.TYPE_ERROR)
122 timeout = config.plugins.remotecontrolcode.replytimeout.value
123 text1 = self.replytext_1
124 text2 = self.replytext_2
125 if config.plugins.remotecontrolcode.rcuType.value == "new":
126 text2 = self.replytext_newrcu_2
128 self.session.openWithCallback(self.MessageBoxConfirmCodeCallback, MessageBoxConfirmCode, text1, text2, MessageBox.TYPE_YESNO, timeout = timeout, default = False)
130 def restoreCode(self):
131 for x in self["config"].list:
134 def MessageBoxConfirmCodeCallback(self,ret):
137 self.session.openWithCallback(self.restartCallback, MessageBox, _("GUI restart now, press 'OK' button."), MessageBox.TYPE_INFO)
140 self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
142 def restartCallback(self,result):
145 class MessageBoxConfirmCode(MessageBox):
147 <screen position="center,center" size="620,10" title="Message">
148 <widget name="text" position="65,8" size="420,0" font="Regular;20" />
149 <widget name="ErrorPixmap" pixmap="skin_default/icons/input_error.png" position="5,5" size="53,53" alphatest="blend" />
150 <widget name="QuestionPixmap" pixmap="skin_default/icons/input_question.png" position="5,5" size="53,53" alphatest="blend" />
151 <widget name="InfoPixmap" pixmap="skin_default/icons/input_info.png" position="5,5" size="53,53" alphatest="blend" />
152 <widget name="list" position="100,100" size="380,375" transparent="1" />
153 <applet type="onLayoutFinish">
154 # this should be factored out into some helper code, but currently demonstrates applets.
155 from enigma import eSize, ePoint
157 orgwidth = self.instance.size().width()
158 orgheight = self.instance.size().height()
159 orgpos = self.instance.position()
160 textsize = self["text"].getSize()
162 # y size still must be fixed in font stuff...
163 textsize = (textsize[0] + 50, textsize[1] + 50)
165 if self.type == self.TYPE_YESNO:
167 wsizex = textsize[0] + 60
168 wsizey = textsize[1] + offset
169 if (280 > wsizex):
171 wsize = (wsizex, wsizey)
174 self.instance.resize(eSize(*wsize))
177 self["text"].instance.resize(eSize(*textsize))
180 listsize = (wsizex, 50)
181 self["list"].instance.move(ePoint(0, textsize[1]))
182 self["list"].instance.resize(eSize(*listsize))
187 window_posx = orgpos.x() + (orgwidth - newwidth)/2
188 window_posy = orgpos.y() + (orgheight - newheight)/2
189 if (150 > window_posy):
191 self.instance.move(ePoint(window_posx, window_posy))
196 def __init__(self, session, replytext_1="", replytext_2="", type = MessageBox.TYPE_YESNO, timeout = -1, close_on_any_key = False, default = True, enable_input = True, msgBoxID = None):
197 self.replytext_1 = replytext_1
198 self.replytext_2 = replytext_2
199 MessageBox.__init__(self,session,self.replytext_1 + "\n" + self.replytext_2,type,timeout,close_on_any_key,default,enable_input,msgBoxID)
200 if type == MessageBox.TYPE_YESNO:
201 self.list = [ (_("Keep"), 0), (_("Restore"), 1) ]
202 self["list"].setList(self.list)
207 self["text"].setText(self.replytext_1 + " in %d seconds."%self.timeout + self.replytext_2)
208 if self.timeout == 0:
210 self.timerRunning = False
211 self.timeoutCallback()
213 def move(self, direction):
214 if self.close_on_any_key:
216 self["list"].instance.moveSelection(direction)
218 self["selectedChoice"].setText(self["list"].getCurrent()[0])
221 def timeoutCallback(self):
224 def main(session, **kwargs):
225 session.open(RemoteControlCode)
227 def Plugins(**kwargs):
228 return [PluginDescriptor(name=_("RemoteControlCode"), description="setup Remote Control System Code Type", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]
230 remotecontrolcodeinit = RemoteControlCodeInit()