Converter/Poll.py: fix suspend
[enigma2.git] / lib / python / Components / Converter / Poll.py
1 from enigma import eTimer
2
3 class Poll(object):
4         def __init__(self):
5                 self.__poll_timer = eTimer()
6                 self.__poll_timer.callback.append(self.poll)
7                 self.__interval = 1000
8                 self.__enabled = False
9
10         def __setInterval(self, interval):
11                 self.__interval = interval
12                 if self.__enabled:
13                         self.__poll_timer.start(self.__interval)
14                 else:
15                         self.__poll_timer.stop()
16         
17         def __setEnable(self, enabled):
18                 self.__enabled = enabled
19                 self.poll_interval = self.__interval
20
21         poll_interval = property(lambda self: self.__interval, __setInterval)
22         poll_enabled = property(lambda self: self.__enabled, __setEnable)
23
24         def poll(self):
25                 self.changed((self.CHANGED_POLL,))
26
27         def doSuspend(self, suspended):
28                 if self.__enabled:
29                         if suspended:
30                                 self.__poll_timer.stop()
31                         else:
32                                 self.poll()
33                                 self.poll_enabled = True
34
35         def destroy(self):
36                 self.__poll_timer.callback.remove(self.poll)