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