Fixed some dbus calls
authorYves Marcoz <yves@marcoz.org>
Mon, 15 Nov 2010 15:29:21 +0000 (07:29 -0800)
committerYves Marcoz <yves@marcoz.org>
Mon, 15 Nov 2010 15:29:21 +0000 (07:29 -0800)
src/FeedingIt-Web.py

index d261444..e03716e 100644 (file)
@@ -15,7 +15,7 @@ CONFIGDIR = "/home/user/.feedingit/"
 
 updatingFeeds = []
 #commands = [("addFeed","httpwww"), ("openFeed", "xxxx"), ("openArticle", ("feedid","artid"))]
-commands = [("openFeed", "1,", "61ac1458d761423344998dc76770e36e")]
+commands = []
 
 def unescape(text):
     def fixup(m):
@@ -70,6 +70,7 @@ class Download(Thread):
         self.keys = keys
         
     def run (self):
+        updateDbusHandler.UpdateStarted()
         for key in self.keys:
             print "Start update: %s" % key
             updatingFeeds.append(key)
@@ -83,15 +84,21 @@ class Download(Thread):
                 print "Error updating feed: %s" %key
             updatingFeeds.remove(key)
             print "End update: %s" % key
+        updateDbusHandler.UpdateFinished()
 
 class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
     def openTaskSwitch(self):
         import subprocess
         subprocess.Popen("dbus-send /com/nokia/hildon_desktop com.nokia.hildon_desktop.exit_app_view", shell=True)
         
-    def updateAll(self):
-        import subprocess
-        subprocess.Popen("FeedingIt update", shell=True)
+    def automaticUpdate(self):
+        feeds = []
+        for cat in listing.getListOfCategories():
+            for feed in listing.getSortedListOfKeys("Manual", category=cat):
+                feeds.append(feed)
+        print feeds
+        download = Download(listing, feeds)
+        download.start()
     
     def getCommands(self):
         
@@ -149,6 +156,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
         if markAllAsRead=="True":
             feed.markAllAsRead()
             listing.updateUnread(key)
+            updateDbusHandler.ArticleCountUpdated()
         xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml>"
         if onlyUnread == "False":
             onlyUnread = False
@@ -213,6 +221,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
             feed = listing.getFeed(key)
             feed.setEntryRead(article)
             listing.updateUnread(key)
+            updateDbusHandler.ArticleCountUpdated()
             self.send_response(200)
             self.send_header("Content-type", "text/html")
             self.end_headers()
@@ -251,13 +260,8 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
             download.start()
             xml = "<xml>OK</xml>"
         elif request[1]=="updateAll":
-            feeds = []
-            for cat in listing.getListOfCategories():
-                for feed in listing.getSortedListOfKeys("Manual", category=cat):
-                    feeds.append(feed)
-            print feeds
-            download = Download(listing, feeds)
-            download.start()
+            self.automaticUpdate()
+            updateDbusHandler.ArticleCountUpdated()
             xml = "<xml>OK</xml>"
         elif request[1] == "addCat":
             catName = request[2]
@@ -290,11 +294,13 @@ import thread
 thread.start_new_thread(start_server, ())
 
 from feedingitdbus import ServerObject
-#from updatedbus import UpdateServerObject, get_lock
+from updatedbus import UpdateServerObject, get_lock
 import gobject
 gobject.threads_init()
 import dbus.mainloop.glib
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
+app = App()
+dbusHandler = ServerObject(app)
+updateDbusHandler = UpdateServerObject(app)
 mainloop = gobject.MainLoop()
 mainloop.run()