Version 2.1 with MIME handling
authorThomas Perl <thp@thpinfo.com>
Mon, 28 Dec 2009 22:00:42 +0000 (23:00 +0100)
committerThomas Perl <thp@thpinfo.com>
Mon, 28 Dec 2009 22:00:42 +0000 (23:00 +0100)
debian/changelog
debian/control
feedhandler.vala
makefile

index adc3a76..2e2bd08 100644 (file)
@@ -1,3 +1,9 @@
+feedhandler (2.1) unstable; urgency=low
+
+  * Second release - better gPodder detection.
+
+ -- Thomas Perl <thp@thpinfo.com>  Mon, 28 Dec 2009 23:00:09 +0100
+
 feedhandler (2.0) unstable; urgency=low
 
   * Initial Release.
index 3e7ab4f..c3bb853 100644 (file)
@@ -9,8 +9,11 @@ Homepage: http://thpinfo.com/2009/feedhandler/
 Package: feedhandler
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}
+XSBC-Bugracker: mailto:thp@gpodder.org
 Description: RSS Feed Handler for the Maemo Browser
  This package provides a generic feed handler for
  the web browser. Users can choose the application
  with which to open a given RSS feed when the web
  browser requests a feed to be added.
+ .
+ Supported apps: RSS Reader, Google Reader, gPodder
index eadb220..06dd9fa 100644 (file)
@@ -6,6 +6,7 @@
 using Gtk;
 using GLib;
 using Osso;
+using Pango;
 
 public enum Reader {
     RSS = 1,
@@ -25,8 +26,22 @@ public class DesktopFile : GLib.KeyFile {
         }
     }
 
-    public string get_name() {
-        return get_string("Desktop Entry", "Name");
+    public string? get_name() {
+        try {
+            return get_string("Desktop Entry", "Name");
+        } catch (KeyFileError e) {
+            stderr.printf("Cannot read exec key: %s\n", e.message);
+        }
+        return null;
+    }
+
+    public string? get_executable() {
+        try {
+            return get_string("Desktop Entry", "Exec");
+        } catch (KeyFileError e) {
+            stderr.printf("Cannot read exec key: %s\n", e.message);
+        }
+        return null;
     }
 }
 
@@ -42,7 +57,12 @@ public class MimeCache : GLib.KeyFile {
     }
 
     public string [] get_desktop_files(string mimetype="application/news_reader") {
-        return get_string("MIME Cache", mimetype).split(";");
+        try {
+            return get_string("MIME Cache", mimetype).split(";");
+        } catch (KeyFileError e) {
+            stderr.printf("Cannot get desktop files for %s\n", mimetype);
+            return new string [0];
+        }
     }
 }
 
@@ -50,19 +70,27 @@ public class MimeCache : GLib.KeyFile {
 public class FeedHandler : GLib.Object {
     private MainLoop loop;
     private DBus.Connection conn;
-    private Context context;
+    private Osso.Context context;
     private string args_url;
+    private MimeCache mime_cache;
 
     public FeedHandler(MainLoop loop, DBus.Connection conn) {
         this.loop = loop;
         this.conn = conn;
         this.context = new Osso.Context("feedhandler", "2.0", false, null);
         this.args_url = null;
-
-        foreach (string file in (new MimeCache().get_desktop_files("text/plain"))) {
-            if (file == "") continue;
-            var desktop_file = new DesktopFile(file);
-            stderr.printf("%s\n", desktop_file.get_name());
+        this.mime_cache = new MimeCache();
+
+        foreach (string file in mime_cache.get_desktop_files("application/rss+xml")) {
+            if (file != "") {
+                var desktop_file = new DesktopFile(file);
+                var name = desktop_file.get_name();
+                var exec = desktop_file.get_executable();
+                if (name != null && exec != null) {
+                    stderr.printf("File in Mime CACHE: %s (%s)\n", name, exec);
+                    /* XXX: Add "Name" as option and on select, start exec + URL */
+                }
+            }
         }
     }
 
@@ -73,10 +101,14 @@ public class FeedHandler : GLib.Object {
         Gtk.Dialog dlg = new Gtk.Dialog();
         dlg.add_button("RSS Reader", Reader.RSS);
         dlg.add_button("Google Reader", Reader.GOOGLE);
-        dlg.add_button("gPodder", Reader.GPODDER);
+        if (FileUtils.test("/usr/bin/gpodder", FileTest.EXISTS)) {
+            dlg.add_button("gPodder", Reader.GPODDER);
+        }
         dlg.add_button("Cancel", Gtk.ResponseType.CLOSE);
         dlg.title = "Select application for handling this feed";
-        dlg.vbox.add(new Gtk.Label(url));
+        var label = new Gtk.Label(url);
+        label.ellipsize = Pango.EllipsizeMode.END;
+        dlg.vbox.add(label);
         dlg.show_all();
         result = dlg.run();
         dlg.destroy();
index f301058..3c2e7a6 100644 (file)
--- a/makefile
+++ b/makefile
@@ -3,7 +3,7 @@
 
 APP=feedhandler
 OBJS=feedhandler.o
-PACKAGES=glib-2.0 dbus-glib-1 gtk+-2.0 libosso
+PACKAGES=glib-2.0 dbus-glib-1 gtk+-2.0 libosso pango
 
 DESTDIR ?= /
 PREFIX ?= /usr