0.2.1-2 - Threaded download of images
authorYves <ymarcoz@n900-sdk.(none)>
Wed, 13 Jan 2010 07:03:32 +0000 (23:03 -0800)
committerYves <ymarcoz@n900-sdk.(none)>
Wed, 13 Jan 2010 07:03:32 +0000 (23:03 -0800)
Fixed feeds with non-dated articles

debian/changelog
debian/control
src/FeedingIt.py
src/rss.py

index 0a9d377..2167aa0 100644 (file)
@@ -1,3 +1,16 @@
+feedingit (0.2.1-2) unstable; urgency=low
+
+  * Fixed issue with feeds without dates (#5019)
+  * Improved threading of image download
+  
+ -- Yves <yves@marcoz.org>  Tue, 12 Jan 2010 18:43:19 -0800
+
+feedingit (0.2.0-4) unstable; urgency=low
+
+  * Fixed AddFeed dialog typo
+  
+ -- Yves <yves@marcoz.org>  Sun, 10 Jan 2010 12:06:19 -0800
+
 feedingit (0.2.0-3) unstable; urgency=low
 
   * Removed horizontal scrolling of articles
index 3666136..c6d0da0 100644 (file)
@@ -1,15 +1,17 @@
 Source: feedingit
 Section: user/network
-Priority: extra
+Priority: optional
 Maintainer: Yves <yves@marcoz.org>
 Build-Depends: debhelper (>= 5)
 Standards-Version: 3.7.2
+XB-Maemo-Display-Name: FeedingIt                                                                                                                      
+XSBC-Bugtracker: https://garage.maemo.org/tracker/?func=browse&group_id=1202&atid=4512
 
 Package: feedingit
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, python-gtkhtml2, python, python-hildon, libgtkhtml2-0, python-dbus
 Description: Simple RSS Reader
- Simple RSS Reader, with portrait mode support
+ Simple RSS Reader, with portrait mode support, and swipe gestures in articles
 XB-Maemo-Icon-26:
  iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IArs4c
  6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0
index 9360b50..2c96374 100644 (file)
@@ -38,6 +38,7 @@ import urllib2
 import gobject
 from portrait import FremantleRotation
 import threading
+import thread
 from feedingitdbus import ServerObject
 
 from rss import *
@@ -59,8 +60,10 @@ class AddWidgetWizard(hildon.WizardDialog):
         self.urlEntry = hildon.Entry(gtk.HILDON_SIZE_AUTO)
         self.urlEntry.set_placeholder("Enter a URL")
         self.urlEntry.set_text(urlIn)
+        self.urlEntry.select_region(0,-1)
+        
         vbox = gtk.VBox(False,10)
-        label = gtk.Label("Enter Feed Name:")
+        label = gtk.Label("Enter Feed URL:")
         vbox.pack_start(label)
         vbox.pack_start(self.urlEntry)
         self.notebook.append_page(vbox, None)
@@ -96,7 +99,17 @@ class AddWidgetWizard(hildon.WizardDialog):
             return False
         else:
             return True
-        
+
+class GetImage(threading.Thread):
+    def __init__(self, url):
+        threading.Thread.__init__(self)
+        self.url = url
+    
+    def run(self):
+        f = urllib2.urlopen(self.url)
+        self.data = f.read()
+        f.close()
+
         
 class Download(threading.Thread):
     def __init__(self, listing, key):
@@ -104,7 +117,7 @@ class Download(threading.Thread):
         self.listing = listing
         self.key = key
         
-    def run ( self ):
+    def run (self):
         self.listing.updateFeed(self.key)
 
         
@@ -287,7 +300,8 @@ class DisplayArticle(hildon.StackableWindow):
         self.index = index
         self.text = text
         self.set_title(title)
-
+        self.images = []
+        
         # Init the article display    
         self.view = gtkhtml2.View()
         self.pannable_article = hildon.PannableArea()
@@ -296,7 +310,8 @@ class DisplayArticle(hildon.StackableWindow):
         self.pannable_article.connect('horizontal-movement', self.gesture)
         self.document = gtkhtml2.Document()
         self.view.set_document(self.document)
-        
+        self.document.connect("link_clicked", self._signal_link_clicked)
+        self.document.connect("request-url", self._signal_request_url)
         self.document.clear()
         self.document.open_stream("text/html")
         self.document.write_stream(self.text)
@@ -316,40 +331,42 @@ class DisplayArticle(hildon.StackableWindow):
         
         self.show_all()
         
-        self.document.connect("link_clicked", self._signal_link_clicked)
-        self.document.connect("request-url", self._signal_request_url)
         self.destroyId = self.connect("destroy", self.destroyWindow)
         self.timeout_handler_id = gobject.timeout_add(300, self.reloadArticle)
         
     def gesture(self, widget, direction, startx, starty):
-        #self.disconnect(self.destroyId)
         if (direction == 3):
             self.emit("article-next", self.index)
         if (direction == 2):
             self.emit("article-previous", self.index)
-        #self.emit("article-closed", self.index)
         self.timeout_handler_id = gobject.timeout_add(200, self.destroyWindow)
-        
+
     def destroyWindow(self, *args):
         self.emit("article-closed", self.index)
         self.destroy()
         
     def reloadArticle(self, *widget):
-        self.document.open_stream("text/html")
-        self.document.write_stream(self.text)
-        self.document.close_stream()
+        if threading.activeCount() > 1:
+            # Image thread are still running, come back in a bit
+            return True
+        else:
+            for (stream, imageThread) in self.images:
+                imageThread.join()
+                stream.write(imageThread.data)
+                stream.close()
+            return False
+        self.show_all()
 
     def _signal_link_clicked(self, object, link):
         bus = dbus.SystemBus()
         proxy = bus.get_object("com.nokia.osso_browser", "/com/nokia/osso_browser/request")
         iface = dbus.Interface(proxy, 'com.nokia.osso_browser')
-        #webbrowser.open(link)
         iface.open_new_window(link)
 
     def _signal_request_url(self, object, url, stream):
-        f = urllib2.urlopen(url)
-        stream.write(f.read())
-        stream.close()
+        imageThread = GetImage(url)
+        imageThread.start()
+        self.images.append((stream, imageThread))
 
 
 class DisplayFeed(hildon.StackableWindow):
@@ -535,7 +552,6 @@ class FeedingIt:
         if self.show_confirmation_note(self.window, current_selection):
             self.listing.removeFeed(self.mapping[current_selection])
             self.listing.saveConfig()
-            
         del self.mapping
         self.displayListing()
 
@@ -585,6 +601,7 @@ class FeedingIt:
     def run(self):
         self.window.connect("destroy", gtk.main_quit)
         gtk.main()
+        self.listing.saveConfig()
 
 
 if __name__ == "__main__":
index fe91c53..fef2ad1 100644 (file)
@@ -84,7 +84,12 @@ class Feed:
     
     def getUniqueId(self,index):
         entry = self.entries[index]
-        return getId(time.strftime("%a, %d %b %Y %H:%M:%S",entry["updated_parsed"]) + entry["title"])
+        if entry.has_key("updated_parsed"):
+            return getId(time.strftime("%a, %d %b %Y %H:%M:%S",entry["updated_parsed"]) + entry["title"])
+        elif entry.has_key("link"):
+            return getId(entry["link"] + entry["title"])
+        else:
+            return getId(entry["title"])
     
     def getUpdateTime(self):
         return self.updateTime
@@ -123,7 +128,12 @@ class Feed:
         content = self.getContent(index)
 
         link = entry.get('link', 'NoLink')
-        date = time.strftime("%a, %d %b %Y %H:%M:%S",entry["updated_parsed"])
+        if entry.has_key("updated_parsed"):
+            date = time.strftime("%a, %d %b %Y %H:%M:%S",entry["updated_parsed"])
+        elif entry.has_key("published_parsed"):
+            date = time.strftime("%a, %d %b %Y %H:%M:%S", entry["published_parsed"])
+        else:
+            date = ""
         #text = '''<div style="color: black; background-color: white;">'''
         text = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
         text = text + '<div><a href=\"' + link + '\">' + title + "</a>"
@@ -143,27 +153,26 @@ class Listing:
             file.close()
         else:
             self.listOfFeeds = {getId("Slashdot"):{"title":"Slashdot", "url":"http://rss.slashdot.org/Slashdot/slashdot"}, }
-        print self.listOfFeeds.has_key("feedingit-order")
         if self.listOfFeeds.has_key("feedingit-order"):
             self.sortedKeys = self.listOfFeeds["feedingit-order"]
         else:
             self.sortedKeys = self.listOfFeeds.keys()
             self.sortedKeys.sort(key=lambda obj: self.getFeedTitle(obj))
         for key in self.sortedKeys:
+            self.loadFeed(key)
+        #self.saveConfig()
+        
+    def loadFeed(self, key):
             if isfile(CONFIGDIR+key):
                 file = open(CONFIGDIR+key)
                 self.feeds[key] = pickle.load(file)
                 file.close()
             else:
                 self.feeds[key] = Feed(self.listOfFeeds[key]["title"], self.listOfFeeds[key]["url"])
-        self.saveConfig()
         
     def updateFeeds(self):
-        print self.sortedKeys
         for key in self.getListOfFeeds():
-            print key, self.sortedKeys
             self.feeds[key].updateFeed()
-        print self.sortedKeys
             
     def updateFeed(self, key):
         self.feeds[key].updateFeed()