Qml support for harmattan version improved
[feedingit] / src / feedingitdbus.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.5.4
24 # Description : Simple RSS Reader
25 # ============================================================================
26
27 import dbus
28 import dbus.service
29 import sys
30 import logging
31 logger = logging.getLogger(__name__)
32
33 class ServerObject(dbus.service.Object):
34     def __init__(self, app):
35         # Here the service name
36         bus = dbus.SessionBus()
37         try:
38             bus_name = dbus.service.BusName(
39                 'org.maemo.feedingit', bus=bus, do_not_queue=True)
40         except dbus.NameExistsException:
41             try:
42                 logger.info("FeedingIt appears to already be running.  "
43                             + "Sending other instance to front.")
44
45                 proxy = bus.get_object('org.maemo.feedingit',
46                                        '/org/maemo/feedingit')
47                 iface = dbus.Interface(proxy, 'org.maemo.feedingit')
48                 iface.GrabFocus()
49             finally:
50                 sys.exit(0)
51
52         # Here the object path
53         dbus.service.Object.__init__(self, bus_name, '/org/maemo/feedingit')
54         self.app = app
55
56     # Here the interface name, and the method is named same as on dbus.
57     @dbus.service.method('org.maemo.feedingit')
58     def AddFeed(self, url):
59         self.app.addFeed(url)
60         return "Done"
61     
62     @dbus.service.method('org.maemo.feedingit')
63     def GetStatus(self):
64         return self.app.getStatus()
65
66     @dbus.service.method('org.maemo.feedingit')
67     def OpenFeed(self, key):
68         #self.app.buttonFeedClicked(None, self.app, None, key)
69         self.app.openFeed(key)
70         return "Done"
71     
72     @dbus.service.method('org.maemo.feedingit')
73     def OpenArticle(self, key, id):
74         #self.app.buttonFeedClicked(None, self.app, None, key)
75         self.app.openArticle(key, id)
76         return "Done"
77
78     @dbus.service.method('org.maemo.feedingit')
79     def GrabFocus(self):
80         self.app.grabFocus()
81         return "Done"
82