>From 7f17329c1e7c30d7c87adeafc5e20d777bc4f8c0 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Tue, 13 May 2008 17:38:55 +0100
Subject: [PATCH] Use dbus service activation, first pass
 Provide .conf and .service files for D-Bus to use,
 allowing fprintd to be autostarted

---
 Makefile.am                            |    2 +-
 configure.ac                           |    2 +-
 data/Makefile.am                       |   15 +++++++++++++++
 data/net.reactivated.Fprint.conf       |   19 +++++++++++++++++++
 data/net.reactivated.Fprint.service.in |    4 ++++
 src/Makefile.am                        |    2 +-
 6 files changed, 41 insertions(+), 3 deletions(-)
 create mode 100644 data/Makefile.am
 create mode 100644 data/net.reactivated.Fprint.conf
 create mode 100644 data/net.reactivated.Fprint.service.in

diff --git a/Makefile.am b/Makefile.am
index 34a4a3d..18e45a7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
 AUTOMAKE_OPTIONS = dist-bzip2
-SUBDIRS = src tests
+SUBDIRS = src data tests
 EXTRA_DIST = TODO
 
diff --git a/configure.ac b/configure.ac
index d25df8c..e038f33 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,6 @@ CFLAGS="$saved_cflags"
 AM_CFLAGS="-std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration -Wno-pointer-sign -Wshadow"
 AC_SUBST(AM_CFLAGS)
 
-AC_CONFIG_FILES([Makefile] [src/Makefile] [tests/Makefile])
+AC_CONFIG_FILES([Makefile] [src/Makefile] [data/Makefile] [tests/Makefile])
 AC_OUTPUT
 
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..bfb0e8c
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,15 @@
+
+dbus_servicesdir = $(datadir)/dbus-1/system-services
+dbus_confdir = $(sysconfdir)/dbus-1/system.d
+•
+dbus_services_in_files = org.gnome.ClockApplet.Mechanism.service.in
+
+dbus_services_DATA = $(dbus_services_in_files:.service.in=.service)•
+
+$(dbus_services_DATA): $(dbus_services_in_files)
+	sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@
+
+dbus_conf_DATA = org.gnome.ClockApplet.Mechanism.conf
+
+
+
diff --git a/data/net.reactivated.Fprint.conf b/data/net.reactivated.Fprint.conf
new file mode 100644
index 0000000..4cd5373
--- /dev/null
+++ b/data/net.reactivated.Fprint.conf
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
+
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+  <!-- Only root can own the service -->
+  <policy user="root">
+    <allow own="net.reactivated.Fprint.Manager"/>
+    <allow send_interface="net.reactivated.Fprint.Manager.GetDevices"/>
+  </policy>
+
+  <!-- Allow anyone to invoke methods on the interfaces -->
+  <policy context="default">
+    <allow send_interface="net.reactivated.Fprint.Manager.GetDevices"/>
+  </policy>
+
+</busconfig>
diff --git a/data/net.reactivated.Fprint.service.in b/data/net.reactivated.Fprint.service.in
new file mode 100644
index 0000000..a838d03
--- /dev/null
+++ b/data/net.reactivated.Fprint.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=net.reactivated.Fprint.Manager
+Exec=@LIBEXEC@/fprintd
+User=root
diff --git a/src/Makefile.am b/src/Makefile.am
index 6775178..77e4fee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,7 @@ noinst_HEADERS = $(BUILT_SOURCES)
 CLEANFILES = $(BUILT_SOURCES)
 EXTRA_DIST = fprintd.xml
 
-bin_PROGRAMS = fprintd
+libexec_PROGRAMS = fprintd
 
 fprintd_SOURCES = main.c manager.c device.c file_storage.c
 fprintd_LDADD = $(GLIB_LIBS) $(DBUS_GLIB_LIBS) $(FPRINT_LIBS)
-- 
1.5.4.5

