psa: remove old event feed items
[feedingit] / src / FeedingIt.py
index b143b0b..f9ab155 100644 (file)
@@ -149,6 +149,28 @@ def notify(message):
         get_iface()
         doit()
 
+def open_in_browser(link):
+    bus = dbus.SessionBus()
+    b_proxy = bus.get_object("com.nokia.osso_browser",
+                             "/com/nokia/osso_browser/request")
+    b_iface = dbus.Interface(b_proxy, 'com.nokia.osso_browser')
+
+    notify("Opening %s" % link)
+
+    # We open the link asynchronously: if the web browser is not
+    # already running, this can take a while.
+    def error_handler():
+        """
+        Something went wrong opening the URL.
+        """
+        def e(exception):
+            notify("Error opening %s: %s" % (link, str(exception)))
+        return e
+
+    b_iface.open_new_window(link,
+                            reply_handler=lambda *args: None,
+                            error_handler=error_handler())
+
 ##
 # Removes HTML or XML character references and entities from a text string.
 #
@@ -804,26 +826,7 @@ class DisplayArticle(hildon.StackableWindow):
         if link == None:
             link = self.currentUrl
 
-        bus = dbus.SessionBus()
-        b_proxy = bus.get_object("com.nokia.osso_browser",
-                                 "/com/nokia/osso_browser/request")
-        b_iface = dbus.Interface(b_proxy, 'com.nokia.osso_browser')
-
-        notify("Opening %s" % link)
-
-        # We open the link asynchronously: if the web browser is not
-        # already running, this can take a while.
-        def error_handler():
-            """
-            Something went wrong opening the URL.
-            """
-            def e(exception):
-                notify("Error opening %s: %s" % (link, str(exception)))
-            return e
-
-        b_iface.open_new_window(link,
-                                reply_handler=lambda *args: None,
-                                error_handler=error_handler())
+        open_in_browser(link)
 
 class DisplayFeed(hildon.StackableWindow):
     def __init__(self, listing, config):
@@ -1256,15 +1259,52 @@ class FeedingIt:
 
         # Check whether auto-update is enabled.
         self.autoupdate = False
-        self.checkAutoUpdate()
+        #self.checkAutoUpdate()
 
         gobject.idle_add(self.build_feed_display)
+        gobject.idle_add(self.check_for_woodchuck)
 
     def build_feed_display(self):
         if not hasattr(self, 'disp'):
             self.disp = DisplayFeed(self.listing, self.config)
             self.disp.connect("feed-closed", self.onFeedClosed)
 
+    def check_for_woodchuck(self):
+        if self.config.getAskedAboutWoodchuck():
+            return
+
+        try:
+            import woodchuck
+            # It is already installed successfully.
+            self.config.setAskedAboutWoodchuck(True)
+            return
+        except ImportError:
+            pass
+
+        note = hildon.hildon_note_new_confirmation(
+            self.window,
+            "\nFeedingIt can use Woodchuck, a network transfer "
+            + "daemon, to schedule transfers more intelligently.\n"
+            + "You can also use the FeedingIt widget for time-based\n"
+            + "updates.\n\n"
+            + "Install Woodchuck?\n")
+        note.set_button_texts("Install", "Cancel")
+        note.add_button("Learn More", 42)
+
+        while True:
+            response = gtk.Dialog.run(note)
+            if response == 42:
+                open_in_browser("http://hssl.cs.jhu.edu/~neal/woodchuck")
+                continue
+
+            break
+
+        note.destroy()
+
+        if response == gtk.RESPONSE_OK:
+            open_in_browser("http://maemo.org/downloads/product/raw/Maemo5/murmeltier?get_installfile")
+        self.config.setAskedAboutWoodchuck(True)
+
     def button_markAll(self, button):
         for key in self.listing.getListOfFeeds():
             feed = self.listing.getFeed(key)