Add support for FeedingIt
[feedhandler] / feedhandler.vala
index 06dd9fa..162009f 100644 (file)
@@ -8,10 +8,14 @@ using GLib;
 using Osso;
 using Pango;
 
+public static const string FEEDINGIT_SERVICE =
+    "/usr/share/dbus-1/services/feedingit.service";
+
 public enum Reader {
     RSS = 1,
     GOOGLE,
     GPODDER,
+    FEEDINGIT,
 }
 
 public class DesktopFile : GLib.KeyFile {
@@ -104,6 +108,9 @@ public class FeedHandler : GLib.Object {
         if (FileUtils.test("/usr/bin/gpodder", FileTest.EXISTS)) {
             dlg.add_button("gPodder", Reader.GPODDER);
         }
+        if (FileUtils.test(FEEDINGIT_SERVICE, FileTest.EXISTS)) {
+            dlg.add_button("FeedingIt", Reader.FEEDINGIT);
+        }
         dlg.add_button("Cancel", Gtk.ResponseType.CLOSE);
         dlg.title = "Select application for handling this feed";
         var label = new Gtk.Label(url);
@@ -131,6 +138,9 @@ public class FeedHandler : GLib.Object {
                     stderr.printf("Can't launch: %s\n", e.message);
                 }
                 break;
+            case Reader.FEEDINGIT:
+                add_to_feedingit(url);
+                break;
         }
 
         message("URL received: %s", url);
@@ -152,6 +162,15 @@ public class FeedHandler : GLib.Object {
         obj.mime_open(url);
     }
 
+    private void add_to_feedingit(string url)
+    {
+        dynamic DBus.Object obj = conn.get_object(
+            "org.maemo.feedingit",
+            "/org/maemo/feedingit",
+            "org.maemo.feedingit");
+        obj.AddFeed(url);
+    }
+
     private void open_browser(string url)
     {
         context.rpc_run_with_defaults("osso_browser",