diff options
Diffstat (limited to 'input')
-rw-r--r-- | input/Makefile.am | 18 | ||||
-rw-r--r-- | input/input.service | 5 | ||||
-rw-r--r-- | input/main.c | 71 | ||||
-rw-r--r-- | input/manager.c | 4 | ||||
-rw-r--r-- | input/manager.h | 4 |
5 files changed, 27 insertions, 75 deletions
diff --git a/input/Makefile.am b/input/Makefile.am index cb56f812..52a46a74 100644 --- a/input/Makefile.am +++ b/input/Makefile.am @@ -1,16 +1,10 @@ if INPUTSERVICE -if CONFIGFILES -confdir = $(sysconfdir)/bluetooth +plugindir = $(libdir)/bluetooth/plugins -conf_DATA = input.service -endif - -servicedir = $(libdir)/bluetooth +plugin_LTLIBRARIES = libinput.la -service_PROGRAMS = bluetoothd-service-input - -bluetoothd_service_input_SOURCES = main.c \ +libinput_la_SOURCES = main.c \ manager.h manager.c \ server.h server.c device.h device.c storage.h storage.c \ fakehid.c fakehid.h @@ -19,10 +13,12 @@ LDADD = $(top_builddir)/common/libhelper.a \ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ endif +AM_LDFLAGS = -module -avoid-version -export-symbols-regex bluetooth_plugin_desc + AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ -INCLUDES = -I$(top_srcdir)/common +INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/hcid -EXTRA_DIST = input.service input-api.txt test-input +EXTRA_DIST = input-api.txt test-input MAINTAINERCLEANFILES = Makefile.in diff --git a/input/input.service b/input/input.service deleted file mode 100644 index f5a105f8..00000000 --- a/input/input.service +++ /dev/null @@ -1,5 +0,0 @@ -[Bluetooth Service] -Identifier=input -Name=Input service -Description=Bluetooth HID based Input service -Autostart=true diff --git a/input/main.c b/input/main.c index a3d83ff6..4589cc33 100644 --- a/input/main.c +++ b/input/main.c @@ -25,76 +25,37 @@ #include <config.h> #endif -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> #include <errno.h> -#include <signal.h> #include <dbus/dbus.h> -#include <glib.h> - +#include "plugin.h" #include "dbus.h" -#include "logging.h" - #include "manager.h" -static GMainLoop *main_loop; - -static void sig_term(int sig) -{ - g_main_loop_quit(main_loop); -} +static DBusConnection *conn; -int main(int argc, char *argv[]) +static int input_init(void) { - DBusConnection *conn; - struct sigaction sa; - - start_logging("input", "Bluetooth Input daemon"); + conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); + if (conn == NULL) + return -EIO; - 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_IGN; - sigaction(SIGCHLD, &sa, NULL); - sigaction(SIGPIPE, &sa, NULL); - - enable_debug(); - - main_loop = g_main_loop_new(NULL, FALSE); - - conn = dbus_bus_system_setup_with_main_loop(NULL, NULL, NULL); - if (!conn) { - g_main_loop_unref(main_loop); - exit(1); - } - - if (input_init(conn) < 0) { + if (input_manager_init(conn) < 0) { dbus_connection_unref(conn); - g_main_loop_unref(main_loop); - exit(1); + return -EIO; } - if (argc > 1 && !strcmp(argv[1], "-s")) - register_external_service(conn, "input", "Input service", ""); + register_external_service(conn, "input", "Input service", ""); - g_main_loop_run(main_loop); + return 0; +} - input_exit(); +static void input_exit(void) +{ + input_manager_exit(); dbus_connection_unref(conn); - - g_main_loop_unref(main_loop); - - info("Exit"); - - stop_logging(); - - return 0; } + +BLUETOOTH_PLUGIN_DEFINE("input", input_init, input_exit) diff --git a/input/manager.c b/input/manager.c index a717c909..953b44ac 100644 --- a/input/manager.c +++ b/input/manager.c @@ -1160,7 +1160,7 @@ static DBusSignalVTable manager_signals[] = { { NULL, NULL } }; -int input_init(DBusConnection *conn) +int input_manager_init(DBusConnection *conn) { dbus_connection_set_exit_on_disconnect(conn, TRUE); @@ -1192,7 +1192,7 @@ int input_init(DBusConnection *conn) return 0; } -void input_exit(void) +void input_manager_exit(void) { dbus_connection_destroy_object_path(connection, INPUT_PATH); diff --git a/input/manager.h b/input/manager.h index d55bb191..cccff683 100644 --- a/input/manager.h +++ b/input/manager.h @@ -24,5 +24,5 @@ #define INPUT_PATH "/org/bluez/input" #define INPUT_MANAGER_INTERFACE "org.bluez.input.Manager" -int input_init(DBusConnection *conn); -void input_exit(void); +int input_manager_init(DBusConnection *conn); +void input_manager_exit(void); |