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
11 config.plugins.remotecontrolcode = ConfigSubsection()
12 config.plugins.remotecontrolcode.systemcode = ConfigSelection(default = "2", choices =
13 [ ("1", "1 "), ("2", "2 "), ("3", "3 "), ("4", "4 ") ] )
14 config.plugins.remotecontrolcode.replytimeout = ConfigInteger(default = 30, limits = (15,9999))
16 class RemoteControlCodeInit:
18 self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
20 def setSystemCode(self, type = 2):
21 if not fileExists("/proc/stb/fp/remote_code"):
23 print "<RemoteControlCode> Write Remote Control Code : %d" % type
24 f = open("/proc/stb/fp/remote_code", "w")
30 if fileExists("/proc/stb/info/vumodel"):
31 vumodel = open("/proc/stb/info/vumodel")
32 info=vumodel.read().strip()
34 if info in ["uno", "ultimo"]:
41 class RemoteControlCode(Screen,ConfigListScreen,RemoteControlCodeInit):
43 <screen position="center,center" size="560,250" title="Remote Control System Code Setting" >
44 <ePixmap pixmap="skin_default/buttons/red.png" position="110,10" size="140,40" alphatest="on" />
45 <ePixmap pixmap="skin_default/buttons/green.png" position="310,10" size="140,40" alphatest="on" />
47 <widget source="key_red" render="Label" position="110,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
48 <widget source="key_green" render="Label" position="310,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
50 <widget name="config" zPosition="2" position="5,70" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
54 def __init__(self,session):
55 Screen.__init__(self,session)
56 self.session = session
57 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
60 "cancel": self.keyCancel,
61 "red": self.keyCancel,
62 "green": self.keySave,
65 ConfigListScreen.__init__(self, self.list,session = self.session)
66 self["key_red"] = StaticText(_("Cancel"))
67 self["key_green"] = StaticText(_("Ok"))
68 self.replytext_1 ="The remote control code will be reset to previous setting, set your R/C's code and select 'keep'"
69 self.replytext_2 ="\n\n<Code set manual>"
70 self.replytext_2 +="\n1. Press Digit 2 and Digit 7 simultaneously for 3 seconds. After 3 seconds LED turns on. "
71 self.replytext_2 +="\n2. Press the <HELP> key. LED is blinked and turns on."
72 self.replytext_2 +="\n3. Enter a 4 digit code(ex. code 2 is '0002')"
74 self.onLayoutFinish.append(self.checkModel)
75 self.checkModelTimer = eTimer()
76 self.checkModelTimer.callback.append(self.invalidmodel)
79 if not self.getModel():
80 self.checkModelTimer.start(1000,True)
82 def invalidmodel(self):
83 self.session.openWithCallback(self.close, MessageBox, _("This Plugin only support for UNO/ULTIMO"), MessageBox.TYPE_ERROR)
85 def createSetup(self):
87 self.rcsctype = getConfigListEntry(_("Remote Control System Code"), config.plugins.remotecontrolcode.systemcode)
88 self.replytimeout = getConfigListEntry(_("Reply timeout"), config.plugins.remotecontrolcode.replytimeout)
89 self.list.append( self.rcsctype )
90 self.list.append( self.replytimeout )
91 self["config"].list = self.list
92 self["config"].l.setList(self.list)
95 print "<RemoteControlCode> Selected System Code : ",config.plugins.remotecontrolcode.systemcode.value
96 ret = self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
99 self.session.openWithCallback(self.close, MessageBox, _("FILE NOT EXIST : /proc/stb/fp/remote_code"), MessageBox.TYPE_ERROR)
101 timeout = config.plugins.remotecontrolcode.replytimeout.value
102 self.session.openWithCallback(self.MessageBoxConfirmCodeCallback, MessageBoxConfirmCode, self.replytext_1,self.replytext_2 ,MessageBox.TYPE_YESNO, timeout = timeout, default = False)
104 def restoreCode(self):
105 for x in self["config"].list:
108 def MessageBoxConfirmCodeCallback(self,ret):
111 self.session.openWithCallback(self.restartCallback, MessageBox, _("GUI restart now, press 'OK' button."), MessageBox.TYPE_INFO)
114 self.setSystemCode(int(config.plugins.remotecontrolcode.systemcode.value))
116 def restartCallback(self,result):
119 class MessageBoxConfirmCode(MessageBox):
121 <screen position="center,center" size="620,10" title="Message">
122 <widget name="text" position="65,8" size="420,0" font="Regular;20" />
123 <widget name="ErrorPixmap" pixmap="skin_default/icons/input_error.png" position="5,5" size="53,53" alphatest="blend" />
124 <widget name="QuestionPixmap" pixmap="skin_default/icons/input_question.png" position="5,5" size="53,53" alphatest="blend" />
125 <widget name="InfoPixmap" pixmap="skin_default/icons/input_info.png" position="5,5" size="53,53" alphatest="blend" />
126 <widget name="list" position="100,100" size="380,375" transparent="1" />
127 <applet type="onLayoutFinish">
128 # this should be factored out into some helper code, but currently demonstrates applets.
129 from enigma import eSize, ePoint
131 orgwidth = self.instance.size().width()
132 orgheight = self.instance.size().height()
133 orgpos = self.instance.position()
134 textsize = self["text"].getSize()
136 # y size still must be fixed in font stuff...
137 textsize = (textsize[0] + 50, textsize[1] + 50)
139 if self.type == self.TYPE_YESNO:
141 wsizex = textsize[0] + 60
142 wsizey = textsize[1] + offset
143 if (280 > wsizex):
145 wsize = (wsizex, wsizey)
148 self.instance.resize(eSize(*wsize))
151 self["text"].instance.resize(eSize(*textsize))
154 listsize = (wsizex, 50)
155 self["list"].instance.move(ePoint(0, textsize[1]))
156 self["list"].instance.resize(eSize(*listsize))
161 self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y() + (orgheight - newheight)/2))
166 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):
167 self.replytext_1 = replytext_1
168 self.replytext_2 = replytext_2
169 MessageBox.__init__(self,session,self.replytext_1 + "\n" + self.replytext_2,type,timeout,close_on_any_key,default,enable_input,msgBoxID)
170 if type == MessageBox.TYPE_YESNO:
171 self.list = [ (_("Keep"), 0), (_("Restore"), 1) ]
172 self["list"].setList(self.list)
177 self["text"].setText(self.replytext_1 + " in %d seconds."%self.timeout + self.replytext_2)
178 if self.timeout == 0:
180 self.timerRunning = False
181 self.timeoutCallback()
183 def move(self, direction):
184 if self.close_on_any_key:
186 self["list"].instance.moveSelection(direction)
188 self["selectedChoice"].setText(self["list"].getCurrent()[0])
191 def timeoutCallback(self):
194 def main(session, **kwargs):
195 session.open(RemoteControlCode)
197 def Plugins(**kwargs):
198 return [PluginDescriptor(name=_("RemoteControlCode"), description="setup Remote Control System Code Type", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]
200 remotecontrolcodeinit = RemoteControlCodeInit()