#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
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.
*/
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;
}
# makes debug link keys valid only for the duration of the connection
# that they were created for.
#DebugKeys = false
+
+#[Policy]
+#
+# The ReconnectUUIDs defines the set of remote services that should try
+# to be reconnected to in case of a link loss (link supervision
+# timeout). The policy plugin should contain a sane set of values by
+# default, but this list can be overridden here. By setting the list to
+# empty the reconnection feature gets disabled.
+#ReconnectUUIDs=