diff -u ../src5/bluez-utils-3.26/input/Makefile.am bluez-utils-3.26/input/Makefile.am --- ../src5/bluez-utils-3.26/input/Makefile.am 2007-12-08 14:04:42.000000000 -0500 +++ bluez-utils-3.26/input/Makefile.am 2008-05-21 19:24:31.000000000 -0400 @@ -22,6 +22,6 @@ INCLUDES = -I$(top_srcdir)/common -EXTRA_DIST = input.service input-api.txt test-input +EXTRA_DIST = input.conf input.service input-api.txt test-input MAINTAINERCLEANFILES = Makefile.in diff -u ../src5/bluez-utils-3.26/input/device.c bluez-utils-3.26/input/device.c --- ../src5/bluez-utils-3.26/input/device.c 2008-02-01 18:16:33.000000000 -0500 +++ bluez-utils-3.26/input/device.c 2008-05-21 19:41:06.000000000 -0400 @@ -69,6 +69,7 @@ struct device { bdaddr_t src; bdaddr_t dst; + int timeout; char *name; uint8_t major; uint8_t minor; @@ -86,7 +87,8 @@ GSList *devices = NULL; -static struct device *device_new(bdaddr_t *src, bdaddr_t *dst, uint8_t subclass) +static struct device *device_new(bdaddr_t *src, bdaddr_t *dst, + uint8_t subclass, int timeout) { struct device *idev; uint32_t cls; @@ -107,6 +109,7 @@ bacpy(&idev->src, src); bacpy(&idev->dst, dst); + idev->timeout = timeout; read_device_name(src, dst, &idev->name); @@ -578,11 +581,11 @@ } static int hidp_connadd(bdaddr_t *src, bdaddr_t *dst, - int ctrl_sk, int intr_sk, const char *name) + int ctrl_sk, int intr_sk, int timeout, const char *name) { struct hidp_connadd_req req; char addr[18]; - int ctl, err, timeout = 30; + int ctl, err; ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HIDP); if (ctl < 0) { @@ -596,7 +599,7 @@ req.ctrl_sock = ctrl_sk; req.intr_sock = intr_sk; req.flags = 0; - req.idle_to = timeout * 60; + req.idle_to = timeout; err = get_stored_device_info(src, dst, &req); if (err < 0) { @@ -666,7 +669,8 @@ idev->intr_sk = isk; err = hidp_connadd(&idev->src, &idev->dst, - idev->ctrl_sk, idev->intr_sk, idev->name); + idev->ctrl_sk, idev->intr_sk, + idev->timeout, idev->name); if (err < 0) goto failed; @@ -1095,7 +1099,7 @@ const char *path; int err; - idev = device_new(src, dst, hid->subclass); + idev = device_new(src, dst, hid->subclass, hid->idle_to); if (!idev) return -EINVAL; @@ -1125,7 +1129,7 @@ const char *path; int err; - idev = device_new(src, dst, 0); + idev = device_new(src, dst, 0, 0); if (!idev) return -EINVAL; @@ -1328,7 +1332,8 @@ if (!idev) return -ENOENT; - err = hidp_connadd(src, dst, idev->ctrl_sk, idev->intr_sk, idev->name); + err = hidp_connadd(src, dst, idev->ctrl_sk, idev->intr_sk, + idev->timeout, idev->name); if (err < 0) { close(idev->ctrl_sk); close(idev->intr_sk); Only in bluez-utils-3.26/input/: input.conf diff -u ../src5/bluez-utils-3.26/input/main.c bluez-utils-3.26/input/main.c --- ../src5/bluez-utils-3.26/input/main.c 2008-02-01 18:16:33.000000000 -0500 +++ bluez-utils-3.26/input/main.c 2008-05-21 19:51:43.000000000 -0400 @@ -43,6 +43,23 @@ static GMainLoop *main_loop; +static GKeyFile *load_config_file(const char *file) +{ + GKeyFile *keyfile; + GError *err = NULL; + + keyfile = g_key_file_new(); + + if (!g_key_file_load_from_file(keyfile, file, 0, &err)) { + error("Parsing %s failed: %s", file, err->message); + g_error_free(err); + g_key_file_free(keyfile); + return NULL; + } + + return keyfile; +} + static void sig_term(int sig) { g_main_loop_quit(main_loop); @@ -50,6 +67,8 @@ int main(int argc, char *argv[]) { + GKeyFile *config; + DBusConnection *conn; struct sigaction sa; @@ -75,12 +94,17 @@ exit(1); } - if (input_init(conn) < 0) { + config = load_config_file(CONFIGDIR "/input.conf"); + + if (input_init(conn, config) < 0) { dbus_connection_unref(conn); g_main_loop_unref(main_loop); exit(1); } + if (config) + g_key_file_free(config); + if (argc > 1 && !strcmp(argv[1], "-s")) register_external_service(conn, "input", "Input service", ""); diff -u ../src5/bluez-utils-3.26/input/manager.c bluez-utils-3.26/input/manager.c --- ../src5/bluez-utils-3.26/input/manager.c 2008-02-01 18:16:33.000000000 -0500 +++ bluez-utils-3.26/input/manager.c 2008-05-21 20:00:25.000000000 -0400 @@ -68,6 +68,8 @@ int ctrl_sock; }; +static int idle_timeout = 0; + static GSList *device_paths = NULL; /* Input registered paths */ static DBusConnection *connection = NULL; @@ -318,6 +320,8 @@ goto failed; } + hidp.idle_to = idle_timeout * 60; + extract_hid_record(pr->hid_rec, &hidp); if (pr->pnp_rec) extract_pnp_record(pr->pnp_rec, &hidp); @@ -1160,9 +1164,18 @@ { NULL, NULL } }; -int input_init(DBusConnection *conn) +int input_init(DBusConnection *conn, GKeyFile *config) { - dbus_connection_set_exit_on_disconnect(conn, TRUE); + GError *err = NULL; + + if (config) { + idle_timeout = g_key_file_get_integer(config, "General", + "IdleTimeout", &err); + if (err) { + debug("input.conf: %s", err->message); + g_error_free(err); + } + } if (!dbus_connection_create_object_path(conn, INPUT_PATH, NULL, manager_unregister)) { diff -u ../src5/bluez-utils-3.26/input/manager.h bluez-utils-3.26/input/manager.h --- ../src5/bluez-utils-3.26/input/manager.h 2008-02-01 18:16:33.000000000 -0500 +++ bluez-utils-3.26/input/manager.h 2008-05-21 20:01:26.000000000 -0400 @@ -24,5 +24,5 @@ #define INPUT_PATH "/org/bluez/input" #define INPUT_MANAGER_INTERFACE "org.bluez.input.Manager" -int input_init(DBusConnection *conn); +int input_init(DBusConnection *conn, GKeyFile *config); void input_exit(void);