diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-05-15 10:57:22 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-05-15 11:19:32 +0300 |
commit | f8a0c50bc6632455d1533d322935e9ebff6f4432 (patch) | |
tree | 46f57e0035be45a760092fe228a9a6c454fed61e /plugins/policy.c | |
parent | 86f4b55232de3c8c1be87f22ad3a404316afb110 (diff) | |
download | bluez-f8a0c50bc6632455d1533d322935e9ebff6f4432.tar.gz |
plugins/policy: Add support to retreive ReconnectUUIDs from main.conf
Diffstat (limited to 'plugins/policy.c')
-rw-r--r-- | plugins/policy.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/plugins/policy.c b/plugins/policy.c index 7d6579771..b72467e7d 100644 --- a/plugins/policy.c +++ b/plugins/policy.c @@ -40,6 +40,7 @@ #include "src/device.h" #include "src/service.h" #include "src/profile.h" +#include "src/hcid.h" #define CONTROL_CONNECT_TIMEOUT 2 #define SOURCE_RETRY_TIMEOUT 2 @@ -535,6 +536,13 @@ static void service_cb(struct btd_service *service, target_cb(service, old_state, new_state); /* + * Return if the reconnection feature is not enabled (all + * subsequent code in this function is about that). + */ + if (!reconnect_uuids) + return; + + /* * We're only interested in reconnecting profiles which have set * auto_connect to true. */ @@ -660,14 +668,30 @@ static void conn_fail_cb(struct btd_device *dev, uint8_t status) static int policy_init(void) { - service_id = btd_service_add_state_cb(service_cb, NULL); + GError *gerr = NULL; + GKeyFile *conf; - /* TODO: Add overriding default from config file */ - reconnect_uuids = g_strdupv((char **) default_reconnect); + service_id = btd_service_add_state_cb(service_cb, NULL); - btd_add_disconnect_cb(disconnect_cb); + conf = btd_get_main_conf(); + if (!conf) { + reconnect_uuids = g_strdupv((char **) default_reconnect); + goto add_cb; + } - btd_add_conn_fail_cb(conn_fail_cb); + reconnect_uuids = g_key_file_get_string_list(conf, "Policy", + "ReconnectUUIDs", + NULL, &gerr); + if (gerr) { + g_error_free(gerr); + reconnect_uuids = g_strdupv((char **) default_reconnect); + goto add_cb; + } +add_cb: + if (reconnect_uuids) { + btd_add_disconnect_cb(disconnect_cb); + btd_add_conn_fail_cb(conn_fail_cb); + } return 0; } |