From 41b411a39152e39b4fa150d42ee33dda028e2267 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 9 Dec 2012 23:58:51 +0100 Subject: [PATCH] core: Add stub for systemd notification integration --- Makefile.am | 1 + src/main.c | 8 ++++++++ src/systemd.c | 38 ++++++++++++++++++++++++++++++++++++++ src/systemd.h | 28 ++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 src/systemd.c create mode 100644 src/systemd.h diff --git a/Makefile.am b/Makefile.am index 5e0a5bed0..9902ac7aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -137,6 +137,7 @@ src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \ $(attrib_sources) $(btio_sources) \ src/bluetooth.ver \ src/main.c src/log.h src/log.c \ + src/systemd.h src/systemd.c \ src/rfkill.c src/hcid.h src/sdpd.h \ src/sdpd-server.c src/sdpd-request.c \ src/sdpd-service.c src/sdpd-database.c \ diff --git a/src/main.c b/src/main.c index 0b2809aea..f985332a3 100644 --- a/src/main.c +++ b/src/main.c @@ -55,6 +55,7 @@ #include "agent.h" #include "manager.h" #include "mgmt.h" +#include "systemd.h" #define BLUEZ_NAME "org.bluez" @@ -471,6 +472,8 @@ int main(int argc, char *argv[]) __btd_log_init(option_debug, option_detach); + sd_notify(0, "STATUS=Starting up"); + config = load_config(CONFIGDIR "/main.conf"); parse_config(config); @@ -506,8 +509,13 @@ int main(int argc, char *argv[]) DBG("Entering main loop"); + sd_notify(0, "STATUS=Running"); + sd_notify(0, "READY=1"); + g_main_loop_run(event_loop); + sd_notify(0, "STATUS=Quitting"); + g_source_remove(signal); plugin_cleanup(); diff --git a/src/systemd.c b/src/systemd.c new file mode 100644 index 000000000..4bb2f1c6a --- /dev/null +++ b/src/systemd.c @@ -0,0 +1,38 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "systemd.h" + +int sd_listen_fds(int unset_environment) +{ + return 0; +} + +int sd_notify(int unset_environment, const char *state) +{ + return 0; +} diff --git a/src/systemd.h b/src/systemd.h new file mode 100644 index 000000000..0ef7c82a9 --- /dev/null +++ b/src/systemd.h @@ -0,0 +1,28 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#define SD_LISTEN_FDS_START 3 + +int sd_listen_fds(int unset_environment); + +int sd_notify(int unset_environment, const char *state); -- 2.47.3