psa: remove old event feed items
[feedingit] / src / feedingitdbus.py
index c6875e6..77869b7 100644 (file)
@@ -2,6 +2,7 @@
 
 # 
 # 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
 # ============================================================================
 # Name        : FeedingIt.py
 # Author      : Yves Marcoz
-# Version     : 0.4.3
+# Version     : 0.5.4
 # Description : Simple RSS Reader
 # ============================================================================
 
 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
@@ -43,3 +62,21 @@ class ServerObject(dbus.service.Object):
     @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 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 GrabFocus(self):
+        self.app.grabFocus()
+        return "Done"
+