#
# Copyright (c) 2007-2008 INdT.
+# Copyright (c) 2011 Neal H. Walfield
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
import dbus
import dbus.service
+import sys
+import logging
+logger = logging.getLogger(__name__)
class ServerObject(dbus.service.Object):
def __init__(self, app):
# Here the service name
- bus_name = dbus.service.BusName('org.maemo.feedingit',bus=dbus.SessionBus())
+ bus = dbus.SessionBus()
+ try:
+ bus_name = dbus.service.BusName(
+ 'org.maemo.feedingit', bus=bus, do_not_queue=True)
+ except dbus.NameExistsException:
+ try:
+ logger.info("FeedingIt appears to already be running. "
+ + "Sending other instance to front.")
+
+ proxy = bus.get_object('org.maemo.feedingit',
+ '/org/maemo/feedingit')
+ iface = dbus.Interface(proxy, 'org.maemo.feedingit')
+ iface.GrabFocus()
+ finally:
+ sys.exit(0)
+
# Here the object path
dbus.service.Object.__init__(self, bus_name, '/org/maemo/feedingit')
self.app = app
@dbus.service.method('org.maemo.feedingit')
def GetStatus(self):
return self.app.getStatus()
+
+ @dbus.service.method('org.maemo.feedingit')
+ def OpenFeed(self, key):
+ #self.app.buttonFeedClicked(None, self.app, None, key)
+ self.app.openFeed(key)
+ return "Done"
@dbus.service.method('org.maemo.feedingit')
- def Update(self):
- self.app.automaticUpdate()
+ def OpenArticle(self, key, id):
+ #self.app.buttonFeedClicked(None, self.app, None, key)
+ self.app.openArticle(key, id)
return "Done"
@dbus.service.method('org.maemo.feedingit')
- def OpenFeed(self, key):
- self.app.buttonFeedClicked(None, self.app, None, key)
- return "Done"
-
- # A signal that will be exported to dbus
- @dbus.service.signal('org.maemo.feedingit', signature='')
- def ArticleCountUpdated(self):
- pass
+ def GrabFocus(self):
+ self.app.grabFocus()
+ return "Done"
+