psa: remove old event feed items
[feedingit] / src / updatedbus.py
1 #!/usr/bin/env python2.5
2
3
4 # Copyright (c) 2007-2008 INdT.
5 # Copyright (c) 2011 Neal H. Walfield
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 #  This program is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public License
17 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 # ============================================================================
21 # Name        : FeedingIt.py
22 # Author      : Yves Marcoz
23 # Version     : 0.6.1
24 # Description : Simple RSS Reader
25 # ============================================================================
26
27 import dbus.service
28 import logging
29 logger = logging.getLogger(__name__)
30
31 _update_server_object = None
32 def update_server_object():
33     global _update_server_object
34     assert _update_server_object is not None, \
35         "No UpdateServerObject instantiated!"
36     return _update_server_object
37
38 class UpdateServerObject(dbus.service.Object):
39     def __init__(self, bus_name):
40         """
41         Start listening for requests.
42         """
43         global _update_server_object
44         assert _update_server_object is None, \
45             "Attempt to instantiate multiple UpdateServerObject objects."
46         _update_server_object = self
47
48         dbus.service.Object.__init__(self, bus_name,
49                                      '/org/marcoz/feedingit/update')
50
51     @dbus.service.method('org.marcoz.feedingit')
52     def StopUpdate(self):
53         logger.debug("Stop update called.")
54
55     @dbus.service.method('org.marcoz.feedingit')
56     def UpdateAll(self):
57         logger.debug("UpdateAll called.")
58
59     @dbus.service.method('org.marcoz.feedingit', in_signature='s')
60     def Update(self, feed):
61         logger.debug("Update(%s) called." % feed)
62     
63     # A signal that will be exported to dbus
64     @dbus.service.signal('org.marcoz.feedingit', signature='')
65     def ArticleCountUpdated(self):
66         pass
67
68     # A signal that will be exported to dbus
69     @dbus.service.signal('org.marcoz.feedingit', signature='uuuuttus')
70     def UpdateProgress(self, percent_complete,
71                        feeds_downloaded, feeds_downloading, feeds_pending,
72                        bytes_downloaded, bytes_uploaded, bytes_per_second,
73                        updated_feed):
74         pass
75
76     # A signal that will be exported to dbus
77     @dbus.service.signal('org.marcoz.feedingit', signature='')
78     def UpdateStarted(self):
79         pass
80     
81     # A signal that will be exported to dbus
82     @dbus.service.signal('org.marcoz.feedingit', signature='')
83     def UpdateFinished(self):
84         pass
85
86