diff options
| -rw-r--r-- | transfer/Makefile.am | 8 | ||||
| -rw-r--r-- | transfer/bluetooth-transfer.conf | 8 | ||||
| -rw-r--r-- | transfer/main.c | 70 | 
3 files changed, 86 insertions, 0 deletions
diff --git a/transfer/Makefile.am b/transfer/Makefile.am index babe164e..8749fde2 100644 --- a/transfer/Makefile.am +++ b/transfer/Makefile.am @@ -1,5 +1,11 @@  if OBEX +if CONFIGFILES +dbusdir = $(sysconfdir)/dbus-1/system.d + +dbus_DATA = bluetooth-transfer.conf +endif +  noinst_PROGRAMS = transferd  transferd_SOURCES = main.c @@ -12,4 +18,6 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @OPENOBEX_CFLAGS@ @DBUS_CFLAGS@  INCLUDES = -I$(top_srcdir)/common +EXTRA_DIST = bluetooth-transfer.conf +  MAINTAINERCLEANFILES = Makefile.in diff --git a/transfer/bluetooth-transfer.conf b/transfer/bluetooth-transfer.conf new file mode 100644 index 00000000..835f1557 --- /dev/null +++ b/transfer/bluetooth-transfer.conf @@ -0,0 +1,8 @@ +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> + +<busconfig> +  <policy context="mandatory"> +    <allow own="org.bluez.transfer"/> +  </policy> +</busconfig> diff --git a/transfer/main.c b/transfer/main.c index 5b2536ec..39bd9248 100644 --- a/transfer/main.c +++ b/transfer/main.c @@ -25,7 +25,77 @@  #include <config.h>  #endif +#include <string.h> +#include <signal.h> +#include <sys/stat.h> + +#include <dbus/dbus.h> + +#include "glib-ectomy.h" + +#include "logging.h" +#include "dbus.h" + +static GMainLoop *main_loop; + +static DBusConnection *system_bus; + +static void sig_term(int sig) +{ +	g_main_loop_quit(main_loop); +} + +static void sig_hup(int sig) +{ +} + +static void sig_debug(int sig) +{ +	toggle_debug(); +} +  int main(int argc, char *argv[])  { +	struct sigaction sa; + +	umask(0077); + +	start_logging("transfer", "Bluetooth transfer service ver %s", VERSION); + +	memset(&sa, 0, sizeof(sa)); +	sa.sa_flags = SA_NOCLDSTOP; +	sa.sa_handler = sig_term; +	sigaction(SIGTERM, &sa, NULL); +	sigaction(SIGINT,  &sa, NULL); +	sa.sa_handler = sig_hup; +	sigaction(SIGHUP, &sa, NULL); + +	sa.sa_handler = sig_debug; +	sigaction(SIGUSR2, &sa, NULL); + +	sa.sa_handler = SIG_IGN; +	sigaction(SIGCHLD, &sa, NULL); +	sigaction(SIGPIPE, &sa, NULL); + +	enable_debug(); + +	main_loop = g_main_loop_new(NULL, FALSE); + +	system_bus = init_dbus("org.bluez.transfer", NULL, NULL); +	if (!system_bus) { +		g_main_loop_unref(main_loop); +		exit(1); +	} + +	g_main_loop_run(main_loop); + +	dbus_connection_unref(system_bus); + +	g_main_loop_unref(main_loop); + +	info("Exit"); + +	stop_logging(); +  	return 0;  }  | 
