diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-01-14 03:14:29 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-01-14 03:14:29 +0000 |
commit | 3878608eb72003883d2398e18f75354a9089e66c (patch) | |
tree | 3f5064efa7ed5f3d353ee684c85a34902daf8b19 /transfer/main.c | |
parent | 6807e26a08e866f2e958169b97e4279112830542 (diff) |
Add D-Bus skeleton
Diffstat (limited to 'transfer/main.c')
-rw-r--r-- | transfer/main.c | 70 |
1 files changed, 70 insertions, 0 deletions
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; } |