From: Thomas Perl Date: Thu, 1 Oct 2009 09:23:38 +0000 (+0200) Subject: initial commit (remove welcome, add code) X-Git-Tag: 2.2~11 X-Git-Url: http://git.maemo.org/git/?p=feedhandler;a=commitdiff_plain;h=adb84e7ba94697bb4910419b59c8e249e35c320d;hp=29a827b19c1e771d459548238febf8ee75169546 initial commit (remove welcome, add code) --- diff --git a/feedhandler.vala b/feedhandler.vala new file mode 100644 index 0000000..d7d0a4f --- /dev/null +++ b/feedhandler.vala @@ -0,0 +1,54 @@ +/** + * Feed Handler + * Copyright © 2009 Thomas Perl + **/ + +using Gtk; +using GLib; + +[DBus (name="org.maemo.garage.feedhandler")] +public class FeedHandler : GLib.Object { + private MainLoop loop; + + public FeedHandler(MainLoop loop) { + this.loop = loop; + } + + [DBus (name = "mime_open")] + public void mime_open(string url) { + Gtk.Dialog dlg = new Gtk.Dialog(); + dlg.add_button("Subscribe", Gtk.ResponseType.YES); + dlg.add_button("Cancel", Gtk.ResponseType.CLOSE); + dlg.title = "feedhandler received a URL"; + dlg.vbox.add(new Gtk.Label(url)); + dlg.show_all(); + dlg.run(); + dlg.destroy(); + message("URL received: %s", url); + loop.quit(); + } +} + +static int main(string [] args) { + MainLoop loop = new MainLoop(null, false); + Gtk.init(ref args); + try { + var conn = DBus.Bus.get(DBus.BusType.SESSION); + dynamic DBus.Object bus = conn.get_object("org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus"); + uint request_name_result = bus.RequestName( + "org.maemo.garage.feedhandler", (uint)0); + if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) { + FeedHandler server = new FeedHandler(loop); + conn.register_object("/org/maemo/garge/feedhandler", server); + loop.run(); + } + + } + catch (Error e) { + stderr.printf("OOps: %s\n", e.message); + } + return 0; +} + diff --git a/makefile b/makefile new file mode 100644 index 0000000..a836597 --- /dev/null +++ b/makefile @@ -0,0 +1,21 @@ +# Feed Handler +# Copyright © 2009 Thomas Perl + +APP=feedhandler +OBJS=feedhandler.o +PACKAGES=glib-2.0 dbus-glib-1 gtk+-2.0 + +VALAFLAGS=$(addprefix --pkg=,$(PACKAGES)) +CFLAGS=`pkg-config --cflags $(PACKAGES)` +LDFLAGS=`pkg-config --libs $(PACKAGES)` + +$(APP): $(OBJS) + +%.c: %.vala + valac $(VALAFLAGS) --ccode $< + # Workaround for Vala bug 595578 + sed -i -e 's/MimeOpen/mime_open/g' $@ + +clean: + rm -f $(OBJS) $(APP) + diff --git a/welcome b/welcome deleted file mode 100644 index e69de29..0000000