still no real function but let at least the list work again
[enigma2-plugins.git] / webinterface / src / WebComponents / Sources / AT.py
1 # Code for the AutoTimerPlugin
2 from Components.Sources.Source import Source
3
4 class AT( Source ):
5         LIST = 0
6         WRITE = 1
7
8         def __init__(self, session, func = LIST):
9                 print "AutoTimer: init: ", func
10                 Source.__init__(self)
11                 self.func = func
12                 self.session = session
13                 self.result = []
14
15         def handleCommand(self, cmd):
16                 print "AutoTimer: handleCommand: ", cmd
17                 if cmd is not None:
18                         self.cmd = cmd
19                         if self.func is self.LIST:
20                                 self.result = self.timerList(cmd)
21                         elif self.func is self.WRITE:
22                                 self.result = self.writeTimer(cmd)
23
24         def timerList(self):
25                 print "timerList"
26
27                 try:
28                         from Plugins.Extensions.AutoTimer.plugin import autotimer
29
30                         if not autotimer:
31                                 from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
32                                 autotimer = AutoTimer()
33                 except ImportError:
34                         return []
35
36                 returnList = []
37
38                 for timer in autotimer.getTimerList():
39                         print "TIMER: ", timer
40                         innerList = [
41                                 timer.getName(),
42                                 timer.getMatch()
43                         ]
44
45                         if timer.hasAfterEvent():
46                                 innerList.append(timer.getAfterEvent()) # 2
47                         else:
48                                 innerList.append("") # 2
49
50                         #excludes
51                         innerList.extend((
52                                 timer.getExcludedTitle(),
53                                 timer.getExcludedShort(),
54                                 timer.getExcludedDescription(),
55                                 timer.getExcludedDays(),
56                         ))
57
58                         #includes
59                         innerList.extend((
60                                 timer.getIncludedTitle(),
61                                 timer.getIncludedShort(),
62                                 timer.getIncludedDescription(),
63                                 timer.getIncludedDays(),
64                         ))
65
66                         # services
67                         innerList.extend((
68                                 timer.getServices(), # 11
69                                 timer.getBouquets() # 12
70                         ))
71
72                         if timer.hasTimespan():
73                                 innerList.extend((
74                                         timer.getTimespanBegin(), # 13
75                                         timer.getTimespanEnd() # 14
76                                 ))
77                         else:
78                                 innerList.extend(("", "")) # 13, 14
79
80                         if timer.hasDuration():
81                                 innerList.append(timer.getDuration()) # 15
82                         else:
83                                 innerList.append("") # 15
84
85                         if timer.hasCounter():
86                                 innerList.extend((
87                                         timer.getCounter(), # 16
88                                         timer.getCounterLeft() # 17
89                                 ))
90                         else:
91                                 innerList.extend((0, 0)) # 16, 17
92
93                         innerList.append(timer.getCounterLimit()) # 18
94
95                         if timer.hasDestination():
96                                 innerList.append(timer.destination) # 19
97                         else:
98                                 innerList.append("/hdd/movie/") # 19
99
100                         if timer.hasCounterFormatString():
101                                 innerList.append(timer.getCounterFormatString()) # 20
102                         else:
103                                 innerList.append("") # 20
104
105                         innerList.extend((
106                                 timer.getLastBegin(), # 21
107                                 timer.getJustplay(), # 22
108                                 timer.getAvoidDuplicateDescription() # 23
109                         ))
110
111                         if timer.hasTags():
112                                 innerList.append(timer.getTags()) # 24
113                         else:
114                                 innerList.append("") # 24
115
116                         print "Enabled", timer.getEnabled()
117                         innerList.append(timer.getEnabled()) # 25
118                         innerList.append("off") # 26
119
120                         returnList.append(innerList)
121
122                 return returnList
123
124         def writeTimer(self,param):
125                 print "writeTimer: ",param
126                 # TODO: fix error handling
127                 return
128
129         def command(self,param):
130                 print "command: ",param
131                 return
132
133                 param = int(param)
134
135                 # TODO: fix error handling
136
137         list = property(timerList)
138         lut = {"Name": 0
139                         ,"Match": 1
140                         ,"AfterEvent": 2
141                         ,"ExcludedTitle": 3
142                         ,"ExcludedShort": 4
143                         ,"ExcludedDescription": 5
144                         ,"ExcludedDays": 6
145                         ,"IncludedTitle": 7
146                         ,"IncludedShort": 8
147                         ,"IncludedDescription": 9
148                         ,"IncludedDays": 10
149                         ,"Services": 11
150                         ,"Bouquets": 12
151                         ,"TimespanBegin": 13
152                         ,"TimespanEnd": 14
153                         ,"Duration": 15
154                         ,"Counter": 16
155                         ,"CounterLeft": 17
156                         ,"CounterLimit": 18
157                         ,"Destination": 19
158                         ,"CounterFormatString": 20
159                         ,"LastBegin": 21
160                         ,"Justplay": 22
161                         ,"AvoidDuplicateDescription": 23
162                         ,"Tags": 24
163                         ,"Enabled": 25
164                         ,"toggleDisabledIMG": 26
165                         }